resize gif image
am 07.01.2008 03:57:00 von 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?
Re: resize gif image
am 07.01.2008 05:44:30 von sloan
http://www.c-sharpcorner.com/UploadFile/jacquesphilip/Making ThumbnailsOfTransparentImages11162005004933AM/MakingThumbnai lsOfTransparentImages.aspx ?
"SushiSean" wrote in message
news:ABB99F98-370A-4E6A-82D4-29CAF3DA708F@microsoft.com...
> 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?
>