lt.monarch.image.gif
Class GIFEncoder

java.lang.Object
  extended by lt.monarch.image.AbstractEncoder
      extended by lt.monarch.image.gif.GIFEncoder
All Implemented Interfaces:
java.io.Serializable

public class GIFEncoder
extends AbstractEncoder

GIFEncoder create a GIF file with or without LZW algorithm.

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
static int COLOR_PALETTE_ADAPTIVE_OCTREE
          Indicates that gif color palette will be created using adaptive Octree-based quantization algorithm.
static int COLOR_PALETTE_EXACT
          Indicates color palette that contains the exact colors used in the graphic.
static int COLOR_PALETTE_WEB
          Indicates web-save color palette (216 colors).
 
Fields inherited from class lt.monarch.image.AbstractEncoder
image
 
Constructor Summary
Constructor and Description
GIFEncoder()
          Constructor for GIFEncoder.
 
Method Summary
Modifier and Type Method and Description
 void encode(java.awt.Image _image, java.io.OutputStream outputStream)
          Encodes image to the output stream.
 int getColorPalette()
          Returns value indicating color palette used in gif compression.
 java.lang.String getContentType()
          Returns content type string - 'gif'
 void setColorPalette(int palette)
          Sets color palette used for gif compression.
 void setLZW(boolean useLZW)
          Used to indicate whether of not we are using LZW algorithm.
 void setTransparent(boolean useTransparent)
          Used to indicate background is transparent or not.
 
Methods inherited from class lt.monarch.image.AbstractEncoder
readObject, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLOR_PALETTE_WEB

public static final int COLOR_PALETTE_WEB
Indicates web-save color palette (216 colors).

See Also:
Constant Field Values

COLOR_PALETTE_EXACT

public static final int COLOR_PALETTE_EXACT
Indicates color palette that contains the exact colors used in the graphic.

See Also:
Constant Field Values

COLOR_PALETTE_ADAPTIVE_OCTREE

public static final int COLOR_PALETTE_ADAPTIVE_OCTREE
Indicates that gif color palette will be created using adaptive Octree-based quantization algorithm.

See Also:
Constant Field Values
Constructor Detail

GIFEncoder

public GIFEncoder()
Constructor for GIFEncoder.

Method Detail

getContentType

public java.lang.String getContentType()
Returns content type string - 'gif'

Specified by:
getContentType in class AbstractEncoder
Returns:
content type string

setTransparent

public void setTransparent(boolean useTransparent)
Used to indicate background is transparent or not.

Parameters:
useTransparent - - True if background is transparent.

setLZW

public void setLZW(boolean useLZW)
Used to indicate whether of not we are using LZW algorithm.

Parameters:
useLZW - - True if LZW algorithm will be used.

setColorPalette

public void setColorPalette(int palette)
Sets color palette used for gif compression. COLOR_PALETTE_WEB is set by default.

Parameters:
palette - one of these values: GIFEncoder.COLOR_PALETTE_WEB, GIFEncoder.COLOR_PALETTE_EXACT, GIFEncoder.COLOR_PALETTE_ADAPTIVE_OCTREE

getColorPalette

public int getColorPalette()
Returns value indicating color palette used in gif compression.

Returns:
value equals to one of these constants: GIFEncoder.COLOR_PALETTE_WEB, GIFEncoder.COLOR_PALETTE_EXACT, GIFEncoder.COLOR_PALETTE_ADAPTIVE_OCTREE

encode

public void encode(java.awt.Image _image,
                   java.io.OutputStream outputStream)
            throws java.io.IOException,
                   java.lang.InterruptedException
Encodes image to the output stream.

Specified by:
encode in class AbstractEncoder
Parameters:
_image - image which must be encoded to GIF format.
outputStream - GIF encoded image output stream.
Throws:
java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
java.lang.InterruptedException