Loading animated gif with alpha


What I’m trying to do is to load a animated .gif with a alpha channel.
I successfully loaded the gif with these few lines:


Does anyone have any idea how to make the transparent areas of my gif invisible in my application?

have you tried ?


then you can disable with


Thanks for the quick reply but this has no effect on the gif.
Any other suggestions?

try setting the pixel format


Nope, this too didn’t have any effect.
watch screenshot

I can display a single frame from a gif in an ofImage using alpha, which makes me wonder if it’s a problem with the gif itself? There is an addon for working with animated gifs https://github.com/robotconscience/ofxGifDecoder but it hasn’t been updated in a while and throws errors for me on load. Might be worth looking into a little bit?

I already encountered that addon but I’m not sure I need that. The gifs are animated and work perfectly except for the alpha and there’s nothing wrong with the gif itself. when I open the gif there’s no white background fill.

My question is maybe silly but what are you using right now to play your animated gif ? Is it quicktime ? The stock version of the quicktime videoplayer addon on windows won’t play any transparent thing. And it might also be the case on Mac too. There are plugins to play transparent videos (google ofxVideoplayeralpha for instance… might be a bit outdated though).

Another solution if it’s in the scope of what you want to do is to use png sequences instead of animated gif.

I followed some other topics related to ofxVideoplayeralpha. I tried editing the video player .cpp file suggested here, but that didn’t solve anything. Since I’m kind of running out of time I solved it with a spritesheet and the ofImage::crop method. That works but I thought there would be some kind of way to load transparant movies. If someone still have a suggestion, I’ll try it out later!

glad you got it to work! another option is to export the gif animation as an image sequence, and then load them in (since ofImage supports alpha channel, where ofVideoPlayer generally doesn’t)

For better performance I prefer a spritesheet since he only has to load one image.

I am trying to load a GIF created with ofxGifEncoder (using ofImage, ofxGifDecoder, or ofVideoPlayer)
I can open the gif in windows.
I can open it in Quicktime.
But trying to open it with ofxGifDecoder produces a mostly blue image (palatte issue I guess).
and opening with ofVideoPlayer, looks correct but doesn’t animate. (first frame only)
using this basic method: http://openframeworks.cc/learning/03_video/how_to_load_and_play_a_video/