Question

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!

Was it helpful?

Solution

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()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top