I’m trying to use ofxGifEncoder to generate short GIF animations, and I thought that I had everything set up correctly as per the given example (and a couple other examples I found on the web), but I’m not getting any GIFs in my data folder.
I’m uploading my ofApp.h and ofApp.cpp for faster reference, but maybe I can explain some of what I’ve got going on.
First I set up my encoder in my setup() function like so:
gifEncoder.setup(ofGetWidth(), ofGetHeight(), .25, 8); ofAddListener(ofxGifEncoder::OFX_GIF_SAVE_FINISHED, this, &ofApp::onGifSaved); fboImage.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR); fboPixels.allocate(ofGetWidth(), ofGetHeight(), 8);
Next, I am using an FBO to render some graphics, then grabbing the FBO’s pixels and stuffing them into an ofImage in order to supply the ofxGifEncoder add-on with a set of pixels to save for each frame.
Right now, each frame is being saved automatically through a call in my update() function to the following code:
ca->fbo.readToPixels(fboPixels); fboImage.setFromPixels(fboPixels); fboImage.update(); gifEncoder.addFrame(fboImage.getPixels(), ofGetWidth(), ofGetHeight(), 8, .25);
Finally, when I hit “s”, the GIF encoder add-on is directed to save the GIF like so:
case 's': cout <<"start saving\n" << endl; gifEncoder.save("test.gif"); break;
When I run my program and hit the “s” key for the first time, I get the following message:
[warning] ofThread - name: Thread 1 - Calling startThread with verbose is deprecated.
gif saved as test.gif
Each subsequent time I hit ‘s’ I don’t get the [warning], only the first and last lines.
No gif file shows up in my bin/data folder and I don’t see it anywhere else either.
Any thoughts on what I’m doing wrong?