com.eteks.awt.image
Class GIFDecoder
java.lang.Object
|
+--com.eteks.awt.image.GIFDecoder
- All Implemented Interfaces:
- ImageProducer
- public class GIFDecoder
- extends Object
- implements ImageProducer
An ImageProducer
implementation that builds an image from a GIF
input stream.
Image data is sent to consumers only when image build is complete.
This class can be used without any link to java.awt
package and an AWT toolkit.
The color model for this image is either an instance of java.awt.image.IndexColorModel
or the default ARGB model. Default RGB model is used if java.awt.image.ColorModel
class can't be instantiated for security or other reason (java.awt.image.ColorModel
requires AWT library to be loaded). In that case, the method setPixels ()
of the interface java.awt.image.ImageConsumer
will be called with the color model parameter
set to null
.
No support for animated GIFs.
- Since:
- PJA1.2
- Author:
- Emmanuel Puybaret
Constructor Summary |
GIFDecoder(InputStream input)
Creates an instance of a GIF decoder for further reading from input . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
consumers
private Vector consumers
bytePixels
private byte[] bytePixels
intPixels
private int[] intPixels
width
private int width
height
private int height
colorModel
ColorModel colorModel
imageStatus
private int imageStatus
fullInfo
private String fullInfo
shortInfo
private String shortInfo
comment
private String comment
input
private InputStream input
classColorModelAccessible
private boolean classColorModelAccessible
bitOffset
private int bitOffset
XC
private int XC
YC
private int YC
pass
private int pass
ptr
private int ptr
oldYC
private int oldYC
r
private byte[] r
g
private byte[] g
b
private byte[] b
transparentIndex
private int transparentIndex
id87
private static final String id87
id89
private static final String id89
EGA_PALETTE
private static final short[][] EGA_PALETTE
EXTENSION
private static final byte EXTENSION
IMAGESEP
private static final byte IMAGESEP
TRAILER
private static final byte TRAILER
INTERLACEMASK
private static final byte INTERLACEMASK
COLORMAPMASK
private static final byte COLORMAPMASK
GIFDecoder
public GIFDecoder(InputStream input)
- Creates an instance of a GIF decoder for further reading from
input
.
Image reading from the stream starts only at startProduction ()
or
addConsumer ()
call.
void ()
- Overrides:
in class Object
startProduction
public void startProduction(ImageConsumer ic)
ImageProducer
implementation.
- Specified by:
startProduction
in interface ImageProducer
addConsumer
public void addConsumer(ImageConsumer ic)
ImageProducer
implementation.
- Specified by:
addConsumer
in interface ImageProducer
isConsumer
public boolean isConsumer(ImageConsumer ic)
ImageProducer
implementation.
- Specified by:
isConsumer
in interface ImageProducer
removeConsumer
public void removeConsumer(ImageConsumer ic)
ImageProducer
implementation.
- Specified by:
removeConsumer
in interface ImageProducer
requestTopDownLeftRightResend
public void requestTopDownLeftRightResend(ImageConsumer ic)
ImageProducer
implementation.
- Specified by:
requestTopDownLeftRightResend
in interface ImageProducer
loadGIF
private void loadGIF(InputStream input)
throws IOException
readImage
private void readImage(DataInputStream dataInput,
int bitsPerPixel,
int bitMask,
boolean hasColormap,
boolean gif89)
throws IOException
readCode
private int readCode(DataInputStream input,
byte[] raster,
int codeSize,
int readMask)
throws IOException
- Fetch the next code from the raster data stream. The codes can be
any length from 3 to 12 bits, packed into 8-bit bytes, so we have to
maintain our location in the raster array as a BIT Offset. We compute
the byte Offset into the raster array by dividing this by 8, pick up
three bytes, compute the bit Offset into our 24-bit chunk, shift to
bring the desired code to the bottom, then mask it off and return it.
doInterlace
private void doInterlace(int index)
gifWarning
private void gifWarning(InputStream input,
String st)
throws IOException