Package com.aowagie.text.pdf.codec
Class GifImage
- java.lang.Object
-
- com.aowagie.text.pdf.codec.GifImage
-
public class GifImage extends java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
GifImage.GifFrame
-
Field Summary
Fields Modifier and Type Field Description private byte[]
block
private int
blockSize
private int
dispose
private java.util.ArrayList
frames
private byte[]
fromData
private java.net.URL
fromUrl
private boolean
gctFlag
private int
height
private int
ih
private java.io.DataInputStream
in
private boolean
interlace
private int
iw
private int
ix
private int
iy
private boolean
lctFlag
private int
m_bpc
private byte[]
m_curr_table
private int
m_gbpc
private byte[]
m_global_table
private int
m_line_stride
private byte[]
m_out
private static int
MaxStackSize
private byte[]
pixelStack
private short[]
prefix
private byte[]
suffix
private int
transIndex
private boolean
transparency
private int
width
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
decodeImageData()
int
getFrameCount()
Gets the number of frames the gif has.Image
getImage(int frame)
Gets the image from a frame.int[]
getLogicalScreen()
Gets the logical screen.private static int
newBpc(int bpc)
private void
process(java.io.InputStream is)
private int
readBlock()
Reads next variable length block from input.private byte[]
readColorTable(int bpc)
private void
readContents()
private void
readGraphicControlExt()
Reads Graphics Control Extension valuesprivate void
readHeader()
Reads GIF file header information.private void
readImage()
Reads next frame imageprivate void
readLSD()
Reads Logical Screen Descriptorprivate int
readShort()
Reads next 16-bit value, LSB firstprivate void
setPixel(int x, int y, int v)
private void
skip()
Skips variable length blocks up to and including next zero length block.
-
-
-
Field Detail
-
in
private java.io.DataInputStream in
-
width
private int width
-
height
private int height
-
gctFlag
private boolean gctFlag
-
lctFlag
private boolean lctFlag
-
interlace
private boolean interlace
-
ix
private int ix
-
iy
private int iy
-
iw
private int iw
-
ih
private int ih
-
block
private final byte[] block
-
blockSize
private int blockSize
-
dispose
private int dispose
-
transparency
private boolean transparency
-
transIndex
private int transIndex
-
MaxStackSize
private static final int MaxStackSize
- See Also:
- Constant Field Values
-
prefix
private short[] prefix
-
suffix
private byte[] suffix
-
pixelStack
private byte[] pixelStack
-
m_out
private byte[] m_out
-
m_bpc
private int m_bpc
-
m_gbpc
private int m_gbpc
-
m_global_table
private byte[] m_global_table
-
m_curr_table
private byte[] m_curr_table
-
m_line_stride
private int m_line_stride
-
fromData
private byte[] fromData
-
fromUrl
private java.net.URL fromUrl
-
frames
private final java.util.ArrayList frames
-
-
Constructor Detail
-
GifImage
public GifImage(java.net.URL url) throws java.io.IOException
Reads gif images from an URL.- Parameters:
url
- the URL- Throws:
java.io.IOException
- on error
-
GifImage
public GifImage(byte[] data) throws java.io.IOException
Reads gif images from a byte array.- Parameters:
data
- the byte array- Throws:
java.io.IOException
- on error
-
-
Method Detail
-
getFrameCount
public int getFrameCount()
Gets the number of frames the gif has.- Returns:
- the number of frames the gif has
-
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]
-
process
private void process(java.io.InputStream is) throws java.io.IOException
- Throws:
java.io.IOException
-
readHeader
private void readHeader() throws java.io.IOException
Reads GIF file header information.- Throws:
java.io.IOException
-
readLSD
private void readLSD() throws java.io.IOException
Reads Logical Screen Descriptor- Throws:
java.io.IOException
-
readShort
private int readShort() throws java.io.IOException
Reads next 16-bit value, LSB first- Throws:
java.io.IOException
-
readBlock
private int readBlock() throws java.io.IOException
Reads next variable length block from input.- Returns:
- number of bytes stored in "buffer"
- Throws:
java.io.IOException
-
readColorTable
private byte[] readColorTable(int bpc) throws java.io.IOException
- Throws:
java.io.IOException
-
newBpc
private static int newBpc(int bpc)
-
readContents
private void readContents() throws java.io.IOException
- Throws:
java.io.IOException
-
readImage
private void readImage() throws java.io.IOException
Reads next frame image- Throws:
java.io.IOException
-
decodeImageData
private boolean decodeImageData() throws java.io.IOException
- Throws:
java.io.IOException
-
setPixel
private void setPixel(int x, int y, int v)
-
readGraphicControlExt
private void readGraphicControlExt() throws java.io.IOException
Reads Graphics Control Extension values- Throws:
java.io.IOException
-
skip
private void skip() throws java.io.IOException
Skips variable length blocks up to and including next zero length block.- Throws:
java.io.IOException
-
-