Class GIFWriter

java.lang.Object
noaa.coastwatch.io.GIFWriter

public class GIFWriter extends Object
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 Details

    • GIFWriter

      public GIFWriter(OutputStream output)
      Creates a new writer using the specified output stream.
      Parameters:
      output - the output stream for writing.
  • Method Details

    • needsQuantization

      public static boolean needsQuantization(BufferedImage image)
      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

      public 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. 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

      public void encode(BufferedImage image) throws IOException
      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.