com.lowagie.text.pdf.codec

Class GifImage

public class GifImage extends Object

Reads gif images of all types. All the images in a gif are read in the constructors and can be retrieved with other methods.

Author: Paulo Soares (psoares@consiste.pt)

Nested Class Summary
static classGifImage.GifFrame
Field Summary
protected intbgColor
protected intbgIndex
protected byte[]block
protected intblockSize
protected intdelay
protected intdispose
protected ArrayListframes
protected byte[]fromData
protected URLfromUrl
protected booleangctFlag
protected intheight
protected intih
protected DataInputStreamin
protected booleaninterlace
protected intiw
protected intix
protected intiy
protected booleanlctFlag
protected intlctSize
protected intm_bpc
protected byte[]m_curr_table
protected intm_gbpc
protected byte[]m_global_table
protected intm_line_stride
protected byte[]m_local_table
protected byte[]m_out
protected static intMaxStackSize
protected intpixelAspect
protected byte[]pixels
protected byte[]pixelStack
protected short[]prefix
protected byte[]suffix
protected inttransIndex
protected booleantransparency
protected intwidth
Constructor Summary
GifImage(URL url)
Reads gif images from an URL.
GifImage(String file)
Reads gif images from a file.
GifImage(byte[] data)
Reads gif images from a byte array.
GifImage(InputStream is)
Reads gif images from a stream.
Method Summary
protected booleandecodeImageData()
intgetFrameCount()
Gets the number of frames the gif has.
int[]getFramePosition(int frame)
Gets the [x,y] position of the frame in reference to the logical screen.
ImagegetImage(int frame)
Gets the image from a frame.
int[]getLogicalScreen()
Gets the logical screen.
protected static intnewBpc(int bpc)
voidprocess(InputStream is)
protected intreadBlock()
Reads next variable length block from input.
protected byte[]readColorTable(int bpc)
protected voidreadContents()
protected voidreadGraphicControlExt()
Reads Graphics Control Extension values
protected voidreadHeader()
Reads GIF file header information.
protected voidreadImage()
Reads next frame image
protected voidreadLSD()
Reads Logical Screen Descriptor
protected intreadShort()
Reads next 16-bit value, LSB first
protected voidresetFrame()
Resets frame state for reading next image.
protected voidsetPixel(int x, int y, int v)
protected voidskip()
Skips variable length blocks up to and including next zero length block.

Field Detail

bgColor

protected int bgColor

bgIndex

protected int bgIndex

block

protected byte[] block

blockSize

protected int blockSize

delay

protected int delay

dispose

protected int dispose

frames

protected ArrayList frames

fromData

protected byte[] fromData

fromUrl

protected URL fromUrl

gctFlag

protected boolean gctFlag

height

protected int height

ih

protected int ih

in

protected DataInputStream in

interlace

protected boolean interlace

iw

protected int iw

ix

protected int ix

iy

protected int iy

lctFlag

protected boolean lctFlag

lctSize

protected int lctSize

m_bpc

protected int m_bpc

m_curr_table

protected byte[] m_curr_table

m_gbpc

protected int m_gbpc

m_global_table

protected byte[] m_global_table

m_line_stride

protected int m_line_stride

m_local_table

protected byte[] m_local_table

m_out

protected byte[] m_out

MaxStackSize

protected static final int MaxStackSize

pixelAspect

protected int pixelAspect

pixels

protected byte[] pixels

pixelStack

protected byte[] pixelStack

prefix

protected short[] prefix

suffix

protected byte[] suffix

transIndex

protected int transIndex

transparency

protected boolean transparency

width

protected int width

Constructor Detail

GifImage

public GifImage(URL url)
Reads gif images from an URL.

Parameters: url the URL

Throws: IOException on error

GifImage

public GifImage(String file)
Reads gif images from a file.

Parameters: file the file

Throws: IOException on error

GifImage

public GifImage(byte[] data)
Reads gif images from a byte array.

Parameters: data the byte array

Throws: IOException on error

GifImage

public GifImage(InputStream is)
Reads gif images from a stream. The stream is not closed.

Parameters: is the stream

Throws: IOException on error

Method Detail

decodeImageData

protected boolean decodeImageData()

getFrameCount

public int getFrameCount()
Gets the number of frames the gif has.

Returns: the number of frames the gif has

getFramePosition

public int[] getFramePosition(int frame)
Gets the [x,y] position of the frame in reference to the logical screen.

Parameters: frame the frame

Returns: the [x,y] position of the frame

getImage

public Image getImage(int frame)
Gets the image from a frame. The first frame is 1.

Parameters: frame the frame to get the image from

Returns: the image

getLogicalScreen

public int[] getLogicalScreen()
Gets the logical screen. The images may be smaller and placed in some position in this screen to playback some animation. No image will be be bigger that this.

Returns: the logical screen dimensions as [x,y]

newBpc

protected static int newBpc(int bpc)

process

void process(InputStream is)

readBlock

protected int readBlock()
Reads next variable length block from input.

Returns: number of bytes stored in "buffer"

readColorTable

protected byte[] readColorTable(int bpc)

readContents

protected void readContents()

readGraphicControlExt

protected void readGraphicControlExt()
Reads Graphics Control Extension values

readHeader

protected void readHeader()
Reads GIF file header information.

readImage

protected void readImage()
Reads next frame image

readLSD

protected void readLSD()
Reads Logical Screen Descriptor

readShort

protected int readShort()
Reads next 16-bit value, LSB first

resetFrame

protected void resetFrame()
Resets frame state for reading next image.

setPixel

protected void setPixel(int x, int y, int v)

skip

protected void skip()
Skips variable length blocks up to and including next zero length block.