Dear all
I have the following code:-
System.Drawing. Image src_image =
System.Drawing. Image.FromStrea m(imgStream);
Bitmap bitmap = new Bitmap(image_wi dth, image_height,
src_image.Pixel Format);
Graphics new_g = Graphics.FromIm age(bitmap);
new_g.Smoothing Mode =
System.Drawing. Drawing2D.Smoot hingMode.HighQu ality;
new_g.Interpola tionMode =
System.Drawing. Drawing2D.Inter polationMode.Hi ghQualityBicubi c;
new_g.Smoothing Mode = SmoothingMode.H ighQuality;
new_g.Compositi ngQuality =
System.Drawing. Drawing2D.Compo sitingQuality.H ighQuality;
new_g.Compositi ngMode =
System.Drawing. Drawing2D.Compo sitingMode.Sour ceCopy;
new_g.DrawImage (src_image, 0, 0, bitmap.Width, bitmap.Height);
new_g.Save();
src_image.Dispo se();
System.Drawing. Imaging.Encoder Enc =
System.Drawing. Imaging.Encoder .Transformation ;
EncoderParamete rs EncParms = new EncoderParamete rs(1);
EncParms.Param = new EncoderParamete r[]
{
new EncoderParamete r(Enc,(long)Enc oderValue.Compr essionLZW),
new EncoderParamete r(System.Drawin g.Imaging.Encod er.Quality,
100L)
};
ImageCodecInfo ici ;
ici = GetProperEncode r(image_name);
string newFullPath = path + image_name;
bitmap.Save(new FullPath, System.Drawing. Imaging.ImageFo rmat.Jpeg);
bitmap.Dispose( );
new_g.Dispose() ;
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
Johann
--
monfu
------------------------------------------------------------------------
monfu's Profile:
http://www.highdots.com/forums/m728
View this thread:
http://www.highdots.com/forums/t2930392