[C#] Making Animated Gif Transparent?

Started by G_G, August 16, 2010, 11:49:20 am

Previous topic - Next topic

G_G

Okay so I found this nifty thing.
http://www.codeproject.com/KB/GDI-plus/NGif.aspx

Anyways I was able to pull off an animated gif with it. However, if any of the images are transparent when added to the gif, the background becomes black. If you set the encoders transparency to black, it'll still make the 2nd or 3rd frame black still.

Now I just placed a magenta background behind the sprite and it made the gifs perfect that way. But it had the colored background. I tried doing this to erase the magenta color.
Bitmap img = new Bitmap(pictureBox1.Image);
img.MakeTransparency(img.GetPixel(0, 0));
pictureBox1.Image = (Image)img;


Which erases the magenta but stops the gif from animating. Any help please?

Blizzard

An animated GIF is composed of frames, not just one bitmap. It probably messes up the animation data structure. Except if you knew how to not mess it up, you can't really do it.
Image and Bitmap instances in C# do not work with the original file but with the data. Once loaded, all file become the same kind of data that is being displayed and you probably can't put it back as it was before.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Well the thing is, each sprite has the same background color. Not sure why it can't take transparent images either.

Anyone know of a way making a gif? :(