Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparent Animated GIF #11

Open
erviveksoni opened this issue Jan 18, 2017 · 3 comments
Open

Transparent Animated GIF #11

erviveksoni opened this issue Jan 18, 2017 · 3 comments

Comments

@erviveksoni
Copy link

I have a sequence of PNG images which I want to use for generating an animated gif. The library works well by stitching the png images to make a gif but looses the transparency while conversion.

The converted gif appears to be grey and white.

Any fix for this?

@DataDink
Copy link
Owner

Hi erviveksoni,

It is unlikely I will get around to this any time soon. If you do find a solution, please submit a pull request and I'll make sure to get it in.

@zhaDeth
Copy link

zhaDeth commented Apr 6, 2017

@erviveksoni Here's a fix :
I had the same Issue with transforming PNGs to GIF, and found out (after hours of trying with lots of different Gif Encoding libs..) it's not really the BumpKit library misbehaving, it has something to do with how the GIF format handles its palette or something... To be honest I didn't bother with the technical stuff once I had the fix: http://www.nathansokalski.com/code/TransparencyClass.aspx (its in VB but probably not a problem for those VB to C# converter sites)

Basically, with this class in your project, all you have to do is call Transparency.makeTransparent() to obtain a GIF-transparency-friendly copy of each Image/Bitmap frame you add to the GifEncoder:

frames(0) = Image.FromFile("1.png")
frames(1) = Image.FromFile("2.png")
frames(2) = Image.FromFile("3.png")

using (var gif = File.OpenWrite(""))
using (var encoder = new GifEncoder(gif))
	for (var i = 0; i < 2; i ++)
	{
		encoder.AddFrame(Transparency.MakeTransparent(frames(i),color.transparent));
		// you might want to dispose frames(i) here since 'MakeTransparent' creates a new copy
	}

flammie

@DataDink
Copy link
Owner

That sounds like an ideal solution. I'll try to take a look this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants