com.raritantechnologies.utils.graphics
Class GifEncoder

java.lang.Object
  extended bycom.raritantechnologies.utils.graphics.GifEncoder

public class GifEncoder
extends java.lang.Object

Class for converting images to GIF files.

Contribution:

Author:
Jacob Dreyer

Constructor Summary
GifEncoder(byte[][] r, byte[][] g, byte[][] b)
          Create a GIF encoder.
GifEncoder(java.awt.Image image)
          Constructing a GIF encoder.
 
Method Summary
 void write(java.io.OutputStream stream)
          Writes the image out to a stream in GIF format.
static void writeFile(java.awt.Component component, java.io.File file)
          Write AWT/Swing component to GIF file.
static void writeFile(java.awt.Image image, java.io.File file)
          Write image to GIF file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GifEncoder

public GifEncoder(java.awt.Image image)
           throws java.awt.AWTException
Constructing a GIF encoder.

Parameters:
image - The image to encode. The image must be completely loaded.
Throws:
java.awt.AWTException - If memory is exhausted or image contains more than 256 colors.

GifEncoder

public GifEncoder(byte[][] r,
                  byte[][] g,
                  byte[][] b)
           throws java.awt.AWTException

Create a GIF encoder.

r[i][j] refers to the pixel at column i, row j

Parameters:
r - Red intensity values.
g - Green intensity values.
b - Blue intensity values.
Throws:
java.awt.AWTException - If memory is exhausted or image contains more than 256 colors.
Method Detail

writeFile

public static void writeFile(java.awt.Image image,
                             java.io.File file)
                      throws java.awt.AWTException,
                             java.io.IOException
Write image to GIF file.

Parameters:
image - Image to write.
file - File to erite to.
Throws:
java.awt.AWTException
java.io.IOException

writeFile

public static void writeFile(java.awt.Component component,
                             java.io.File file)
                      throws java.awt.AWTException,
                             java.io.IOException
Write AWT/Swing component to GIF file.

Parameters:
file - File to erite to.
Throws:
java.awt.AWTException
java.io.IOException

write

public void write(java.io.OutputStream stream)
           throws java.io.IOException
Writes the image out to a stream in GIF format. This will be a single GIF87a image, non-interlaced, with no background color.

Parameters:
stream - The stream to which to output.
Throws:
java.io.IOException - Thrown if a write operation fails.