Strange results using ofxGifEncoder

Hello,

I am trying to use the ofxGifEncoder addon to export a gif, where an ofFbo is the source for each frame.
When the spacebar is depressed, a frame is added to gifEncoder:

fbo.readToPixels(fboPixels);
image.setFromPixels(fboPixels);
if(bSpaceDown) { gifEncoder.addFrame(fboPixels.getPixels(), fboW, fboH); }

When the spacebar is released, the gif is saved:

void keyReleased(int key) {
    if(key == ' ') {
        if(bSpaceDown) gifEncoder.save("test.gif");
        bSpaceDown = false;
    }
 }

The output is indeed an animated gif, but I get glitchy bands of solid color. Here is a frame from the running sketch, and a frame from the output gif for comparison.

This is the main cpp file for reference. Basically the app just loads gifs from URLs that are pasted into the window and draws them onto a mesh, using the ofFbo for a texture.

Let me know if I can provide more detail or clarify something. At the moment, I am stumped.

I should note that I am using ofSketch 0.2.2 to test / compile the app.

Thanks!

Just trying to reproduce this – what http URL are you using to get the gif?

(also, just from the images, it looks like a an rgb vs rgba issue … somewhere the formats are getting mixed up)

Thanks. The same thing happened with every gif I tried, but I believe this is the gif I used for that test.

@bakercp You were right! This line fixed it:

fbo.allocate(fboW, fboH, GL_RGB);

1 Like