Reputation: 213
I have the problem setting the size of an Image to a maximum value. Do you have a code example how to set the Image Size ?
System.Drawing.Image image = System.Drawing.Image.FromStream(stream, true);
In the first step I am loading the image from Stream and in the next step i want to set the image.Site.width to 800
Upvotes: 0
Views: 2689
Reputation: 38077
You can resize the image by creating a new Image from it and specifying the size:
System.Drawing.Image resizedImage = new Bitmap(image, new Size(100,100));
If you want more control over the resize, you can draw it to a new image and set the interpolation mode:
System.Drawing.Image resizedImage = new Bitmap(100,100);
using (Graphics graphicsHandle = Graphics.FromImage(resizedImage))
{
graphicsHandle.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphicsHandle.DrawImage(image, 0, 0, 100, 100);
}
return resizedImage;
Upvotes: 1