A directory of extensions and libraries for the OpenFrameworks creative coding toolkit. Compiled fresh from Github daily.
openframeworks addon to export animated gifs
Originally created: 20 March, 2011
Last updated: 15 January, 2012
Export animated gifs from openframeworks.
There is a simple example included
create an instance of ofxGifEncoder
ofxGifEncoder gifEncoder;
call setup
gifEncoder.setup(frameW, frameH, frameDuration, nColors);
(frameDuration is a float in seconds and nColors is an int from 0 to 256.)
optionally :) (see dithering patterns on the h file)
gifEncoder.setDitherMode(OFX_GIF_DITHER_BAYER4x4);
then add frames, either as ofImages or unsigned char *
gifEncoder.addFrame(foo.getPixels(), frameW, frameH);
when you're ready to save
gifEncoder.save("test.gif");
the saving is now threaded, so it won't block your app. If you want to do something when saving is finished, you can subscribe to the event OFXGIFSAVE_FINISHED
ofAddListener(ofxGifEncoder::OFX_GIF_SAVE_FINISHED, this, &testApp::onGifSaved);
...
onGifSaved(string & fileName)
threaded saving, events, error checking and frame managing adapted from Nick Hardeman.
- Transaparent gifs!
- Provide option to choose palette?
- proper frame compression
one thing that it's not quite there yet is appropiate gif compression, so if your images are big or you have many frames you may end up with unnecesarily fat gifs.
If you use it, I'd love to see what for. Let me know at {myname}@{nameandsurname}.com !