Hi
This code seems correct, but the result image had not been displayed correcly... Do you have any idea?
-------------------------------------------------------------------
public static Stream ResizeImage(Stream imageStream, int w)
{
System.Drawing.Image objImage = System.Drawing.Image.FromStream(imageStream);
int h;
if (objImage.Width < w)
{
w = objImage.Width;
h = objImage.Height;
}
else
{
decimal rate = (decimal)objImage.Height / (decimal)objImage.Width;
h = (int)(rate * w);
}
Bitmap objBitmap = new Bitmap(objImage, new Size(w, h));
MemoryStream objStream = new MemoryStream();
objBitmap.Save(objStream, ImageFormat.Jpeg);
return objStream;
}
Kind Regards,
Shery
Go to the complete details ...