How to resize an image in .NET or ASP.NET?
public static System.Drawing.Image ResizeImage(System.Drawing.Image sourceImage, int width, int height)
{
System.Drawing.Image oThumbNail = new Bitmap(sourceImage, width, height);
Graphics oGraphic = Graphics.FromImage(oThumbNail);
oGraphic.CompositingQuality = CompositingQuality.HighQuality;
oGraphic.SmoothingMode = SmoothingMode.HighQuality;
oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
Rectangle oRectangle = new Rectangle(0, 0, width, height);
oGraphic.DrawImage(sourceImage, oRectangle);
return oThumbNail;
}
Posted on March 19, 2008 by Viktar Karpach