com.klg.jclass.util.swing.encode
Class GIFEncoder
java.lang.Object
|
+--com.klg.jclass.util.swing.encode.AbstractImageEncoder
|
+--com.klg.jclass.util.swing.encode.GIFEncoder
- All Implemented Interfaces:
- Encoder
- public class GIFEncoder
- extends AbstractImageEncoder
This class encodes a Gif file from an Image to an OutputStream. It converts
the palette from 16 bits to 8 bits if necessary. Sometimes the palette
conversion results in slightly changed colors. No color depths except 8 and
16 bpp are supported.
Methods inherited from class com.klg.jclass.util.swing.encode.AbstractImageEncoder |
byteFromChar, byteFromInt, bytesFromInt, bytesFromLong, compressColor, compressColor, createByte, encode, encode, error, snapshot, snapshotJava3d |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GIFEncoder
public GIFEncoder()
saveImage
public void saveImage(Image img,
OutputStream ofile)
throws IOException,
EncoderException
- Save image as a gif file.
- Specified by:
saveImage
in class AbstractImageEncoder
IOException
EncoderException
palettizePixels
public ColorModel palettizePixels(int[] inPixelArray,
byte[] outPixelArray,
ColorModel cmodel)
- Compress all colors in provided pixel array into a palette of 256 colors
resulting in a converted byte pixel array. Conversion is done using
the compressColors().
- Parameters:
inPixelArray
- input array of integer pixelsoutPixelArray
- output array of byte pixelscmodel
- current color model
- Returns:
- an instance of ColorModel that represents the newly created
palette of 256 colors.
writeChar
public void writeChar(OutputStream ofile,
char ochar)
throws IOException
IOException