J2ME Animated GIF encoder
Here’s a free implementation of an animated GIF encoder for Java ME. This class is actually a porting of the original Java version, available here.
Download J2ME AnimatedGifEncoder here.
Usage is quite straightforward, and it requires these steps:
- Instantiate your AnimatedGifEncoder object
- Start it, by passing an OutputStream as argument (e.g.: a ByteArrayOutputStream)
- Add your Image objects by using addFrame() method
- Finalize it by calling finish()
ByteArrayOutputStream bos = new ByteArrayOutputStream(); AnimatedGifEncoder encoder = new AnimatedGifEncoder(); encoder.start(bos); encoder.addFrame(image1); encoder.addFrame(image2); encoder.finish(); return bos.toByteArray(); |
As for the original version, code is free for any kind of usages, but you must refer to the Unisys LZW patent for restrictions on use of the associated LZWEncoder class.
ds 7:55 am on December 11, 2008 Permalink
Thanks! Very useful!
Have just given it a go and it works like a charm.
The only thing is I seem to be able to get much smaller images when I save from photoshop.
Have you any idea if the LZW compression is working properly? The file size I am getting now is just a tad bit smaller in bytes than I have total pixels. On the other hand photoshop, or php for that matter reduces this to 1/5.
Thanks again!
Sajid 10:44 am on August 12, 2011 Permalink
Hey hi, How to use this J2ME Animated GIF encoder in J2ME Application, please tel me.
Thanks