473,594 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

saving a ".gif" image gives me problems


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

Nov 19 '05 #1
0 1112

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

Similar topics

1
6328
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 image in the central area of a simple menu-bar app as shown below in the first code sample. But, when I set up my app with a class, as shown below in the second code sample, the image disappears. How can I correct this? I'm sure the answer would...
0
898
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 = Graphics.FromImage(newImage); objGraphic.CompositingQuality = CompositingQuality.HighQuality; objGraphic.SmoothingMode = SmoothingMode.HighQuality;
6
3989
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
2519
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 transparent gif image I can't use LinkButtons over this image. The string that I'm using now is: <body background="BMP/Header.gif" MS_POSITIONING="GridLayout"> Maybe I should use something else in place of GridLayout?
1
1647
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 transparency property disappears when I render it making it look as if were a JPEG image. The code I use is: Assembly assem = this.GetType().Assembly; Stream streamTransPic =
0
1306
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): ... frame.show() All but the first image appears black-and-white. They apparently lose the color palette associated with the overall image. The palette for the original image and the individual frames is the same, the histograms suggest they have more...
1
1483
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): image_parser = Parser() image_parser.feed(image_data)
3
6160
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 to import gif images in vb6?
0
8253
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8009
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8240
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6661
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5739
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5411
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3867
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1482
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.