Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encode GIF in J2ME

I have an Image object in J2ME and I'd like to enconde it to GIF. I've already found a JPEG and PNG encoder as well, but I'm wondering if it's possible to encode my Image in the GIF format, returning it's byte array.

I'm doing something like this:

...

  Image img = Image.createImage(width, height);
    Graphics graphics = img.getGraphics();
//do some drawing stuff here
...  

And finally I have an Image object.

Now I'd like to encode it to GIF like:

 byte[] gifBytes = GIFEncoder.encode(img);

Where can I find one?

thanks!

like image 668
Eduardo Abreu Avatar asked Dec 16 '25 22:12

Eduardo Abreu


1 Answers

See J2ME Animated GIF encoder,

Usage:

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()
like image 195
jmj Avatar answered Dec 19 '25 14:12

jmj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!