E
engwar
I'm writing some file upload code using C# 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);
oGraphic.DrawImage(objImage, oRectangle);
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.
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);
oGraphic.DrawImage(objImage, oRectangle);
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.