By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,312 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,312 IT Pros & Developers. It's quick & easy.

saving a ".gif" image gives me problems

P: n/a

Dear all

I have the following code:-

System.Drawing.Image src_image =

Bitmap bitmap = new Bitmap(image_width, image_height,
Graphics new_g = Graphics.FromImage(bitmap);
new_g.SmoothingMode =
System.Drawing.Drawing2D.SmoothingMode.HighQuality ;
new_g.InterpolationMode =
System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic;
new_g.SmoothingMode = SmoothingMode.HighQuality;
new_g.CompositingQuality =
System.Drawing.Drawing2D.CompositingQuality.HighQu ality;
new_g.CompositingMode =
System.Drawing.Drawing2D.CompositingMode.SourceCop y;

new_g.DrawImage(src_image, 0, 0, bitmap.Width, bitmap.Height);

System.Drawing.Imaging.Encoder Enc =
EncoderParameters EncParms = new EncoderParameters(1);

EncParms.Param = new EncoderParameter[]
new EncoderParameter(Enc,(long)EncoderValue.Compressio nLZW),
new EncoderParameter(System.Drawing.Imaging.Encoder.Qu ality,

ImageCodecInfo ici ;

ici = GetProperEncoder(image_name);

string newFullPath = path + image_name;

bitmap.Save(newFullPath, System.Drawing.Imaging.ImageFormat.Jpeg);


which is working fine when i upload a "jpg" image. However, when i
tried to upload a ".gif" image, it is not working fine. It is giving
me the following error:-

"A Graphics object cannot be created from an image that has an indexed
pixel format."

I am not saving the image prior to uploading, just putting it in a
stream and saving the image after the manipulation is done.

Thanks for your help

monfu's Profile:
View this thread:

Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.