473,397 Members | 1,974 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,397 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 1097

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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.