Determining image sizes

  • Thread starter Thread starter timm.wong
  • Start date Start date
T

timm.wong

Hi,

I have a program where I load images to a screen. How would I go about
determining the size of an image prior to loading it on the screen?
Thanks,
Tim
 
Hi Tim,

Um, Image.Size would be a good start :)
With Framework 2.0 the PictureBox has a PictureBoxSizeMode.Zoom that will
fill the PictureBox while also retaining proportions. In the mean time,
you could set the PictureBox.SizeMode to StretchImage and adjust the size
of the PictureBox to retain proportions

Scale = Math.Min(Screen.Width/Image.Size.Width,
Screen.Height/Image.Size.Height)
PictureBox.Size = Image.Size * Scale
 
Back
Top