Package noaa.coastwatch.io
Class GIFWriter
java.lang.Object
noaa.coastwatch.io.GIFWriter
The
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:
- http://www.fmsware.com
- http://geosoft.no
- Since:
- 3.1.9
- Author:
- Peter Hollemans
-
Constructor Summary
ConstructorDescriptionGIFWriter
(OutputStream output) Creates a new writer using the specified output stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
encode
(BufferedImage image) Writes a GIF file to the output stream using the specified image data.static BufferedImage
getQuantizedImage
(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
(BufferedImage image) Determines if an image needs to be quantized before writing to a GIF file.
-
Constructor Details
-
GIFWriter
Creates a new writer using the specified output stream.- Parameters:
output
- the output stream for writing.
-
-
Method Details
-
needsQuantization
Determines if an image needs to be quantized before writing to a GIF file.- Parameters:
image
- the image to check.- Returns:
- true if the image needs to be quantized prior to encoding, or false if not.
- See Also:
-
getQuantizedImage
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. Some colours in the original are approximated in the quantized image.- Parameters:
image
- the image to make GIF ready.- Returns:
- the quantized image.
- See Also:
-
encode
Writes a GIF file to the output stream using the specified image data.- Parameters:
image
- the image to write.- Throws:
IOException
- if an error occurred writing to the output stream.
-