How to resize 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;

}


Wednesday, March 19, 2008 | Comments (1) | Add Comment

Comments

Gravatar

Re:How to resize image in .NET or ASP.NET?

how we use it. if i send value in function then source image has problem

5/20/2009 10:05:10 AM | by enam
Gravatar

You can save it:

oThumbNail.Save(...)

or use it as described here:

http://www.karpach.com/Server-side-thumbnail-generation.htm

New Comment

Your Name:
Email (for internal use only):
Subject:
Comment:
 
Code above:

Categories

Recent Tweets

Valid XHTML 1.0 Transitional