JClass DesktopViews 6.3.0 API
Documentation

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.


Constructor Summary
GIFEncoder()
           
 
Method Summary
 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.
 void saveImage(Image img, OutputStream ofile)
          Save image as a gif file.
 void writeChar(OutputStream ofile, char ochar)
           
 
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
 

Constructor Detail

GIFEncoder

public GIFEncoder()
Method Detail

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 pixels
outPixelArray - output array of byte pixels
cmodel - 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

Copyright © 2004 Quest Software Inc..
All rights reserved.