convert 24 bit jpeg to 256 color gif

Hi,

I have a 24 bit jpeg image which I am reading into an buffered image.
I am using BufferedImage.TYPE_INT_RGB.

Now, I have a class called GIFEncoder (downloaded, author: Adam Doppelt) which takes a BufferedImage and encodes it into gif image. But, it does not accepts 24 bit buffered image.

Should I go for another GIF Encoder which does 24 bit to 8 bit quantization also?
If yes, please tell a GIFEncoder which is freely available, can take BufferedImage as input and encodes a gif out of it.

Thanks,
Vaibhav
vaibhavmishra062201Asked:
Who is Participating?
 
objectsCommented:
0
 
Mayank SAssociate Director - Product EngineeringCommented:
I think you need to search for Graphics Gems II III.2 by Xialoin Wu.
0
 
TimYatesCommented:
Assuming your 24 bit image is in an image called "frame", you can do:

      BufferedImage indexedImage = new BufferedImage( frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_BYTE_INDEXED ) ;
      Graphics g = indexedImage.getGraphics() ;
      g.drawImage( frame, 0, 0, null ) ;
      g.dispose() ;

Then, "indexedImage" contains your 256 color image which should be addable to the GifEncoder
0
 
vaibhavmishra062201Author Commented:
Thanks objects, but you forgot to mention other 2 classes used in AnimatedGifEncoder (LZWEncoder & NeuQuant)
TimYates: I tried AnimatedGifEncoder suggested by objects and it worked fine. Thanks anyway.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.