resize gif image

S

SushiSean

Hello. I have something like image gallery and I need make preview of images.
It means resize them to 100x100.
I have code
// create Graphics object
System.Drawing.Image oThumbNail = new Bitmap(FileWidth, FileHeight,
oImg.PixelFormat);
Graphics oGraphic = Graphics.FromImage(oThumbNail);
oGraphic.CompositingQuality = CompositingQuality.HighQuality;
oGraphic.SmoothingMode = SmoothingMode.HighQuality;
oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;

//make rectangle from Graphics object (resize)
Rectangle oRectangle = new Rectangle(0, 0, FileWidth, FileHeight);
oGraphic.DrawImage(oImg, oRectangle);
oThumbNail.Save(NewPhysicalPath);

It works well for jpeg images, but I get error when work with gif
"A Graphics object cannot be created from an image that has an indexed pixel
format."
What can I do here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top