Detect Image Size in 2 TextBox's
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts
Page 1 of 1
What I have: 1 OpenFileDialog, 1 PictureBox, 2 TextBox's
I already have it setup so when you browse, and select a image it'll show in a picturebox. Now I'm trying to figure out how it'll automatically detect the image's width, and height, but put the height in 1 textbox, and the width in another.
Anyone know how to achieve this?
Here's the coding so far...
I already have it setup so when you browse, and select a image it'll show in a picturebox. Now I'm trying to figure out how it'll automatically detect the image's width, and height, but put the height in 1 textbox, and the width in another.
Anyone know how to achieve this?
Here's the coding so far...
Code: Select all
Public Class Form1
Private sizew As Integer
Private sizey As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
OpenFileDialog1.CheckFileExists = True
OpenFileDialog1.ShowReadOnly = False
OpenFileDialog1.Filter = "All Files|*.*|Bitmap |*.bmp;*.dib|JPEG |*.jpg;*.jpeg;*.jpe;*.jfif|TIFF |*.tif;*.tiff |PNG |*.png"
OpenFileDialog1.FilterIndex = 1
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
End If
End Sub
End Class
Last edited by mikethedj4 on Mon May 07, 2012 2:13 am, edited 1 time in total.
You can do this to put the image into a variable:

Code: Select all
Then you can use these to get the dimensions:
Dim bm as new bitmap("Image File Name Here")
Code: Select all
I hope this helps textbox1.text = bm.width
textbox2.text = bm.height

Thanks, but that won't work for what I'm trying to accomplish. However my question was answered on StackOverflow.
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023