473,242 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

saving a ".gif" image gives me problems


Dear all

I have the following code:-

System.Drawing.Image src_image =
System.Drawing.Image.FromStream(imgStream);

Bitmap bitmap = new Bitmap(image_width, image_height,
src_image.PixelFormat);
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);
new_g.Save();
src_image.Dispose();

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

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

ImageCodecInfo ici ;

ici = GetProperEncoder(image_name);

string newFullPath = path + image_name;

bitmap.Save(newFullPath, System.Drawing.Imaging.ImageFormat.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

Nov 19 '05 #1
0 1086

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: midtoad | last post by:
I'm trying to display a GIF image in a label as the central area to a Tkinter GUI. The image does not appear, though a space is made for it. Why is this so? I notice that I can display a GIF...
0
by: funcSter | last post by:
I've got this bit of code: Image origImage = Image.FromFile("temp.jpg"); Image newImage = new Bitmap(objNewSize.Width, objNewSize.Height, origImage.Pixelformat); Graphics objGraphic =...
6
by: hb | last post by:
Hi, Would you please give me some idea to convert/decode a Base 64 encoded GIF image string to a *.gif file in ASP.Net? Thank you hb
2
by: Just D. | last post by:
Who knows what should we include into aspx file to show some image as a background picture but only once at the top of the page? I don't want to add the Image control because even if it uses a...
1
by: JimC | last post by:
I use reflection to get a GIF image that contains a transparency mask (the white background should be transparent) that is part of my C# project build. The problem is that the image's...
0
by: skip | last post by:
I'm unclear how PIL handles multi-frame GIF images. I have such a GIF image in a file, bogus.gif. I can view the individual frames like so (ImageSequence is from the PIL tutorial): ... ...
1
by: Miki | last post by:
Hello All, I get an image from a web page (via urlopen), and like to make it twice the size. I'm trying (using PIL): ---- code ---- from ImageFile import Parser def double(image_data):...
3
by: vaniKanabathy | last post by:
Hi , i had problem in import .gif image. I had call the image using Image32.Picture = LoadPicture(App.Path & "\a.gif") the image appear in my form but it not animated as it was. Please help me...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.