Image size

  • Thread starter Thread starter Jon Cosby
  • Start date Start date
J

Jon Cosby

How do you resize an image object? The Size property is read-only.


Jon Cosby
 
Jon,

In order to do this, you will have to create a new Image object (or
rather, a class that derives from it, since Image is an abstract class),
with the size that you wish it to be. Then, you will have to get the
Graphics instance for that image, and call the DrawImage method on that,
specifiying the original image, and the scaling options you want to apply.

Hope this helps.
 
There are couple of ways to resize image

Method 1

Put your image into the PictureBox Control. PictureBox has a property
SizeMode, where you can resize the fashion you want

Method 2.

Create a Bitmap Object and place the image with new co-ordinates

example -

//create new image
Image TestImage = Image.FromFile (blah blah)

//define new resize size
Size newSize = new Size(400,400)

//display the image with new size
Bitmap newBmp = new Bitmap(TestImage,newSize.width, newSize.height)

Shak
 

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

Back
Top