Last post Jan 06, 2006 03:21 AM by webbes
Dec 28, 2005 09:34 AM|engwar|LINK
I'm writing some file upload code for users on my website. If the image is too large I want to resize it smaller to a thumbnail size. It's working fine for jpegs but the thumbnails of the gifs look pretty bad.
I assume it's something to do with the color palette. I don't know a whole lot about graphics programming. Can anyone assist?
Here's the code I'm currently using.
System.Drawing.Image img2 = new Bitmap(iImgWidthNew, iImgHeightNew, PixelFormat.Format24bppRgb);
Graphics oGraphic = Graphics.FromImage(img2);
oGraphic.CompositingQuality = CompositingQuality.HighQuality ;
oGraphic.SmoothingMode = SmoothingMode.HighQuality ;
oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic ;
Rectangle oRectangle = new Rectangle(0, 0, iImgWidthNew, iImgHeightNew);
I get the same poor results if I don't pass a PixelFormat in the first line.
I can see having quality suffer if I INCREASED the size of the image but don't see why it suffers when I DECREASE it.
Would I have better results if I convert it to a .jpg and save it that way? Most images uploaded will be photos but there might be some illustrations uploaded as gifs.
Will I have a similar problem with png files?
Thanks for helping this newbie.
Jan 06, 2006 03:21 AM|webbes|LINK
Have a look over here:
or here: http://forums.asp.net/1064190/ShowPost.aspx