com.gif4j
Class GifEncoder

java.lang.Object
  extended bycom.gif4j.GifEncoder

public class GifEncoder
extends java.lang.Object

This class encodes an image into the GIF89a image file format to an outputstream.
The following specification "GRAPHICS INTERCHANGE FORMAT(sm) Version 89a" was referenced for the development of this encoder.
Some of the naming conventions and clarification of some aspects of GIF file format and LZW compression were obtained from the following:
LZW.C
Copyright (c) 1989 Mark R. Nelson
LZW data compression/expansion demonstration program.
May 12, 1997


Method Summary
static void encode(java.awt.image.BufferedImage image, java.io.DataOutput dataOutput)
          Encode and write out the data contained in the BufferedImage to the specified output in the GIF89a file format.
static void encode(java.awt.image.BufferedImage image, java.io.OutputStream outputStream)
          Encode and write out the data contained in the BufferedImage to the output stream in the GIF89a file format.
static void encode(GifImage gifImage, java.io.OutputStream outputStream)
          Encode and write out the data contained in the GifImage to the output stream in the GIF89a file format.
static void encode(GifImage gifImage, java.io.OutputStream outputStream, boolean forceGlobalColorTableUsage)
          Encode and write out the data contained in the GifImage to the output stream in the GIF89a file format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static final void encode(GifImage gifImage,
                                java.io.OutputStream outputStream)
                         throws java.io.IOException
Encode and write out the data contained in the GifImage to the output stream in the GIF89a file format.

Parameters:
gifImage - GifImage to encode
outputStream - the specified stream to output
Throws:
java.io.IOException - If write operation fails
java.lang.NullPointerException - If gifImage is null
java.lang.NullPointerException - If output stream is null

encode

public static final void encode(GifImage gifImage,
                                java.io.OutputStream outputStream,
                                boolean forceGlobalColorTableUsage)
                         throws java.io.IOException
Encode and write out the data contained in the GifImage to the output stream in the GIF89a file format.

Parameters:
gifImage - GifImage to encode
outputStream - the specified stream to output
forceGlobalColorTableUsage - force Global Color Table usage. If true local color tables from all frames will be union to one global color table. It's useful to optimize final image size (every Local Color Table takes up to 768 bytes).
Throws:
java.io.IOException - If write operation fails
java.lang.NullPointerException - If GifImage is null
java.lang.NullPointerException - If output stream is null

encode

public static final void encode(java.awt.image.BufferedImage image,
                                java.io.OutputStream outputStream)
                         throws java.io.IOException
Encode and write out the data contained in the BufferedImage to the output stream in the GIF89a file format. Running this method is equal to running encode(GifImage gifImage, java.io.OutputStream outputStream) where GifImage instance contains the only one GifFrame instance wrapped the specified image.

Parameters:
image - image to encode
outputStream - the specified stream to output
Throws:
java.io.IOException - If write operation fails
java.lang.NullPointerException - If image is null
java.lang.NullPointerException - If output stream is null

encode

public static final void encode(java.awt.image.BufferedImage image,
                                java.io.DataOutput dataOutput)
                         throws java.io.IOException
Encode and write out the data contained in the BufferedImage to the specified output in the GIF89a file format.

Parameters:
image - image to encode
dataOutput - the specified output to write
Throws:
java.io.IOException - If write operation fails
java.lang.NullPointerException - If image is null
java.lang.NullPointerException - If output is null