public class GIFWriter
extends java.lang.Object
GIFWriter
class writes non-interlaced GIF87a
images from a rendered Java image. If more than 256 colors are
found, an optimal 256 color map is generated prior to writing the
file. The following web sites were used for neural network color
quantization and GIF encoding source code:
Constructor and Description |
---|
GIFWriter(java.io.OutputStream output)
Creates a new writer using the specified output stream.
|
Modifier and Type | Method and Description |
---|---|
void |
encode(java.awt.image.BufferedImage image)
Writes a GIF file to the output stream using the specified image
data.
|
static java.awt.image.BufferedImage |
getQuantizedImage(java.awt.image.BufferedImage image)
Creates a GIF ready image by quantizing an image with a colour map that is
greater than 256 colours in size to an image with a 256 colour map.
|
static boolean |
needsQuantization(java.awt.image.BufferedImage image)
Determines if an image needs to be quantized before writing to
a GIF file.
|
public GIFWriter(java.io.OutputStream output)
output
- the output stream for writing.public static boolean needsQuantization(java.awt.image.BufferedImage image)
image
- the image to check.getQuantizedImage(java.awt.image.BufferedImage)
public static java.awt.image.BufferedImage getQuantizedImage(java.awt.image.BufferedImage image)
image
- the image to make GIF ready.needsQuantization(java.awt.image.BufferedImage)
public void encode(java.awt.image.BufferedImage image) throws java.io.IOException
image
- the image to write.java.io.IOException
- if an error occurred writing to the output
stream.