how i can change image size?

T

Tark Siala

hi
i'm wprking with C# 2005 + SP1, and i want load image from image file, and
then resize it (like from 800X600 Pixel to 640X480 Pixel), and then save it
in another image file, i want do that for resize many images to publish it
on the internet, the picture box can load image and resize it on the screen,
but can't save it with new dimension.

can you help me?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Tark said:
hi
i'm wprking with C# 2005 + SP1, and i want load image from image file, and
then resize it (like from 800X600 Pixel to 640X480 Pixel), and then save it
in another image file, i want do that for resize many images to publish it
on the internet, the picture box can load image and resize it on the screen,
but can't save it with new dimension.

Create a new Bitmap object with the desired size, use Graphics.FromImage
to create a graphics object for the bitmap, use the DrawImage method to
draw the original image onto the bitmap, then finally save the bitmap as
a file.
 
N

Nicholas Paldino [.NET/C# MVP]

Tark,

You will want to create a new Bitmap class instance with the dimensions
that you want to resave the image to. Then, you will call the static
FromImage method on the Graphics class to get the Graphics instance for the
new image. Once you have that, you can call the DrawImage method on the
Graphics instance, passing the original image (and the new image
dimensions).
 

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