Package com.itextpdf.text.pdf.codec
Class GifImage
java.lang.Object
com.itextpdf.text.pdf.codec.GifImage
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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected int
protected byte[]
protected int
protected int
protected int
protected ArrayList<GifImage.GifFrame>
protected byte[]
protected URL
protected boolean
protected int
protected int
protected DataInputStream
protected boolean
protected int
protected int
protected int
protected boolean
protected int
protected int
protected byte[]
protected int
protected byte[]
protected int
protected byte[]
protected byte[]
protected static final int
protected int
protected byte[]
protected byte[]
protected short[]
protected byte[]
protected int
protected boolean
protected int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
int
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.getImage
(int frame) Gets the image from a frame.int[]
Gets the logical screen.protected static int
newBpc
(int bpc) (package private) void
process
(InputStream is) protected int
Reads next variable length block from input.protected byte[]
readColorTable
(int bpc) protected void
protected void
Reads Graphics Control Extension valuesprotected void
Reads GIF file header information.protected void
Reads next frame imageprotected void
readLSD()
Reads Logical Screen Descriptorprotected int
Reads next 16-bit value, LSB firstprotected void
Resets frame state for reading next image.protected void
setPixel
(int x, int y, int v) protected void
skip()
Skips variable length blocks up to and including next zero length block.
-
Field Details
-
in
-
width
protected int width -
height
protected int height -
gctFlag
protected boolean gctFlag -
bgIndex
protected int bgIndex -
bgColor
protected int bgColor -
pixelAspect
protected int pixelAspect -
lctFlag
protected boolean lctFlag -
interlace
protected boolean interlace -
lctSize
protected int lctSize -
ix
protected int ix -
iy
protected int iy -
iw
protected int iw -
ih
protected int ih -
block
protected byte[] block -
blockSize
protected int blockSize -
dispose
protected int dispose -
transparency
protected boolean transparency -
delay
protected int delay -
transIndex
protected int transIndex -
MaxStackSize
protected static final int MaxStackSize- See Also:
-
prefix
protected short[] prefix -
suffix
protected byte[] suffix -
pixelStack
protected byte[] pixelStack -
pixels
protected byte[] pixels -
m_out
protected byte[] m_out -
m_bpc
protected int m_bpc -
m_gbpc
protected int m_gbpc -
m_global_table
protected byte[] m_global_table -
m_local_table
protected byte[] m_local_table -
m_curr_table
protected byte[] m_curr_table -
m_line_stride
protected int m_line_stride -
fromData
protected byte[] fromData -
fromUrl
-
frames
-
-
Constructor Details
-
GifImage
Reads gif images from an URL.- Parameters:
url
- the URL- Throws:
IOException
- on error
-
GifImage
Reads gif images from a file.- Parameters:
file
- the file- Throws:
IOException
- on error
-
GifImage
Reads gif images from a byte array.- Parameters:
data
- the byte array- Throws:
IOException
- on error
-
GifImage
Reads gif images from a stream. The stream is not closed.- Parameters:
is
- the stream- Throws:
IOException
- on error
-
-
Method Details
-
getFrameCount
public int getFrameCount()Gets the number of frames the gif has.- Returns:
- the number of frames the gif has
-
getImage
Gets the image from a frame. The first frame is 1.- Parameters:
frame
- the frame to get the image from- Returns:
- the image
-
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
-
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
- Throws:
IOException
-
readHeader
Reads GIF file header information.- Throws:
IOException
-
readLSD
Reads Logical Screen Descriptor- Throws:
IOException
-
readShort
Reads next 16-bit value, LSB first- Throws:
IOException
-
readBlock
Reads next variable length block from input.- Returns:
- number of bytes stored in "buffer"
- Throws:
IOException
-
readColorTable
- Throws:
IOException
-
newBpc
protected static int newBpc(int bpc) -
readContents
- Throws:
IOException
-
readImage
Reads next frame image- Throws:
IOException
-
decodeImageData
- Throws:
IOException
-
setPixel
protected void setPixel(int x, int y, int v) -
resetFrame
protected void resetFrame()Resets frame state for reading next image. -
readGraphicControlExt
Reads Graphics Control Extension values- Throws:
IOException
-
skip
Skips variable length blocks up to and including next zero length block.- Throws:
IOException
-