I think its this:
Hope it works.Code:HeightLabel.Text = PictureBox1.Image.Height ' Get the height WidthLabel.Text = PictureBox1.Image.Width ' Get the width
Hey, i was wondering how to get an Image Size from the picturebox..
Im making an Image converter and have the PictureBox1.Image = OpenFileDialog yadda yadda yadda.
But how would i show the image size ? ( once the user selects the image, a label will show the image size)
Cheers for the answer's :-)
I think its this:
Hope it works.Code:HeightLabel.Text = PictureBox1.Image.Height ' Get the height WidthLabel.Text = PictureBox1.Image.Width ' Get the width
I didn understand but i think you need to put like this:
In a button or something..Code:PictureBox1.Image = OpenFileDialog.Filename HeightLabel.Text = PictureBox1.Image.Height ' Get the height WidthLabel.Text = PictureBox1.Image.Width ' Get the width
I think is that..
Bare with me here, you're saying you want to select an image, then select another image, then go back to the first one and display it's width height?
Perhaps create a list of images, add to it, make the picturebox display the first image and set the label text in the very next step.
I'm still not 100% sure what your final purpose is though, why the need to open 2 images? A picturebox can only display 1 and can't hold any in memory...
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
yea, maybe he means a listbox with images, and when you select an image it will show the image and the size.....
Try this:
Code:Public WithEvents timer1 As New Timer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x As New OpenFileDialog With {.Title = "Select image.."} x.ShowDialog() ListBox1.Items.Add(x.FileName) timer1.Start() End Sub Private Sub Timer1_Tick() Handles timer1.Tick Try PictureBox1.Image = Image.FromFile(ListBox1.SelectedItem.ToString) Label1.Text = PictureBox1.Image.Height Label2.Text = PictureBox1.Image.Width Catch ex As Exception End Try End Sub
[highlight="vb"]' Load the Image
Dim objImage As System.Drawing.Image = _
System.Drawing.Image.FromFile("C:\MyImage.gif")
' Get Height and Width
Dim Width as integer = objImage.Width
Dim Height as integer = objImage.Height
[/highlight]
Bla, nvm <_<.
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
The video will sort of explain whats going on!
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
Here is all my code i've got so far.. the code is under ' TextBox1_TextChanged ' event..
[highlight=vb.net]
Public Class Form1
Dim OpenFileDialog1 As New OpenFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With OpenFileDialog1
.CheckFileExists = True
.ShowReadOnly = False
.Filter = "ICO(*.ico)|*.ico|JPG(*.jpg)|*.jpg*|BMP(*.bmp)|*.b mp|TIFF(*.tiff)|*.tiff|GIF(*.gif)|*.gif|PNG(*.png) |*.png"
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
TextBox1.Text = OpenFileDialog1.FileName
PictureBox3.Image = Image.FromFile(OpenFileDialog1.FileName)
End If
End With
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
If TextBox1.Text = "" Then
Dim OpenFileDialog1 As New OpenFileDialog
With OpenFileDialog1
.CheckFileExists = True
.ShowReadOnly = False
.Filter = "ICO(*.ico)|*.ico|JPG(*.jpg)|*.jpg*|BMP(*.bmp)|*.b mp|TIFF(*.tiff)|*.tiff|GIF(*.gif)|*.gif|PNG(*.png) |*.png"
.FilterIndex = 1
If .ShowDialog = DialogResult.OK Then
TextBox1.Text = OpenFileDialog1.FileName
' Load the specified file into a PictureBox control.
PictureBox3.Image = Image.FromFile(.FileName)
End If
End With
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Button2.Enabled = True
Try
HeightLabel.Text = PictureBox3.Image.Height ' Get the height
WidthLabel.Text = PictureBox3.Image.Width ' Get the width
Catch ax As Exception
End Try
End Sub
Private Sub OpenImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenImageToolStripMenuItem.Click
If TextBox1.Text = "" Then
MsgBox("Please select your image before clicking this!", MsgBoxStyle.Critical, "")
Else
Process.Start(TextBox1.Text)
End If
End Sub
Private Sub CloseMenuToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseMenuToolStripMenuItem.Click
ContextMenuStrip1.Hide()
End Sub
End Class
' ooo.Filter = "ICO(*.ico)|*.ico|JPG(*.jpg)|*.jpg*|BMP(*.bmp)|*.b mp|TIFF(*.tiff)|*.tiff|GIF(*.gif)|*.gif|PNG(*.png) |*.png"
[/highlight]
Last edited by Jason; 02-12-2011 at 11:34 PM. Reason: Nicer tags :3
Okay, firstly remove the TextChanged event and all it's code completely, we'll handle it differently
Now remove your definition of "OpenFileDialog1" completely as well, we'll recode the Button2_Click sub to this:
[highlight=vb.net]
Using ofd As New OpenFileDialog With {.CheckFileExists = True, .ShowReadOnly = False, .Filter = "ICO(*.ico)|*.ico|JPG(*.jpg)|*.jpg*|BMP(*.bmp)|*.b mp|TIFF(*.tiff)|*.tiff|GIF(*.gif)|*.gif|PNG(*.png) |*.png"}
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim nextImg As Image = Image.FromFile(ofd.FileName)
HeightLabel.Text = nextImg.Height.ToString
WidthLabel.Text = nextImg.Width.ToString
PictureBox1.Image = nextImg
End If
End Using
[/highlight]
Now when you press okay in the OFD, it will set the pictureboxes image correctly, and display the image's height and width straight away. It's always best to call relevant code in the same event that you start from, rather than from another event which might not sync correctly.
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)