[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


convert 24 bit jpeg to 256 color gif

Posted on 2006-03-20
Medium Priority
Last Modified: 2013-11-19

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.

Question by:vaibhavmishra062201
LVL 92

Accepted Solution

objects earned 375 total points
ID: 16244527
LVL 30

Expert Comment

by:Mayank S
ID: 16244556
I think you need to search for Graphics Gems II III.2 by Xialoin Wu.
LVL 35

Expert Comment

ID: 16244791
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

Author Comment

ID: 16245878
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.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This video teaches viewers about errors in exception handling.
Learn the basics of inputting and editing your text components in Prezi. We will cover how to set styles, position, and group your text components. In your Prezi editor, click anywhere on the canvas to add text: A flashing cursor informs you that yo…
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question