Friday, June 06, 2008

Image Resize using ASP.NET C# and displaying as Thumbnails dynamically

The following code helps us to Resize images and display them as thumbnails dynamically using ASP.NET C#.

protected void Page_Load(object sender, EventArgs e)
string BasePath = Server.MapPath(".");
Bitmap Img, ImgTemp;

ImgTemp = new Bitmap(BasePath + "\\images\\Balaji.jpg");
Img = new Bitmap(ImgTemp, 200, 300);

Graphics Graph;
Graph = Graphics.FromImage(Img);

Img.Save(Response.OutputStream, ImageFormat.Jpeg);
Graph.DrawImage(Img, 0, 0);



This function helps us to set the height and width of the new image Bitmap(ImgTemp, 200, 300);

No comments: