Image Size

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
 
Z

zacks

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.
 
S

Samuel

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
 
S

si_owen

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
 
R

rowe_newsgroups

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top