Image Size

  • Thread starter Thread starter si_owen
  • Start date Start date
S

si_owen

Hi All,

I have created an application that allows users to upload images to
their listed events. When a user views their event their uploaded
image is also displayed.

However does anyone know if it is possible to resize the image at run
time??? As at the moment the images uploaded just get squashed and
distorted in the image control. Or alternatively is there a way to
obtain the height and width values from an image file when it is
uploaded??

Thanks in advance,

Simon
 
Hi All,

I have created an application that allows users to upload images to
their listed events. When a user views their event their uploaded
image is also displayed.

However does anyone know if it is possible to resize the image at run
time??? As at the moment the images uploaded just get squashed and
distorted in the image control. Or alternatively is there a way to
obtain the height and width values from an image file when it is
uploaded??

Thanks in advance,

Simon

Are you using a PictureBox control to display the image? If so, what
is the value for the SizeMode property? If you set it to Zoom, the
image displayed in the picture box will be adjusted to fill out the
picturebox while maintaining the image's original aspect ratio.
 
Generally you may create a new bitmap then read the image file content into
the bitmap and then check the Height and the Width members
 
Guys,

I am using Visual Studio 2003, and my project is a web application. So
I cant use picturebox as this is limited to win forms.

Any other sugggestions?

Cheers,

Simon
 
Guys,

I am using Visual Studio 2003, and my project is a web application. So
I cant use picturebox as this is limited to win forms.

Any other sugggestions?

Cheers,

Simon

You can still use the System.Drawing members to read the width and
height values of the uploaded image. Then to resize it, you just need
to draw the image onto a new image object that is the proper size. As
with most GDI+ topics, Bob Powell has a sample on his site that does a
high quality resize. This is actually the link for generating a
thumbnail, but it seems to do a terrific job. You can browse his other
topics for a few more samples.

http://www.bobpowell.net/highqualitythumb.htm

Thanks,

Seth Rowe
 
Back
Top