com.lowagie.text.pdf.codec

## Class GifImage

- java.lang.Object
- - com.lowagie.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.
  Author:
    Paulo Soares (psoares@consiste.pt)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `GifImage.GifFrame`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `bgColor`
    `protected int` | `bgIndex`
    `protected byte[]` | `block`
    `protected int` | `blockSize`
    `protected int` | `delay`
    `protected int` | `dispose`
    `protected java.util.ArrayList` | `frames`
    `protected byte[]` | `fromData`
    `protected java.net.URL` | `fromUrl`
    `protected boolean` | `gctFlag`
    `protected int` | `height`
    `protected int` | `ih`
    `protected java.io.DataInputStream` | `in`
    `protected boolean` | `interlace`
    `protected int` | `iw`
    `protected int` | `ix`
    `protected int` | `iy`
    `protected boolean` | `lctFlag`
    `protected int` | `lctSize`
    `protected int` | `m_bpc`
    `protected byte[]` | `m_curr_table`
    `protected int` | `m_gbpc`
    `protected byte[]` | `m_global_table`
    `protected int` | `m_line_stride`
    `protected byte[]` | `m_local_table`
    `protected byte[]` | `m_out`
    `protected static int` | `MaxStackSize`
    `protected int` | `pixelAspect`
    `protected byte[]` | `pixels`
    `protected byte[]` | `pixelStack`
    `protected short[]` | `prefix`
    `protected byte[]` | `suffix`
    `protected int` | `transIndex`
    `protected boolean` | `transparency`
    `protected int` | `width`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GifImage(byte[] data)` Reads gif images from a byte array.
    `GifImage(java.io.InputStream is)` Reads gif images from a stream.
    `GifImage(java.lang.String file)` Reads gif images from a file.
    `GifImage(java.net.URL url)` Reads gif images from an URL.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `decodeImageData()`
    `int` | `getFrameCount()` 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.
    `Image` | `getImage(int frame)` Gets the image from a frame.
    `int[]` | `getLogicalScreen()` Gets the logical screen.
    `protected static int` | `newBpc(int bpc)`
    `(package private) void` | `process(java.io.InputStream is)`
    `protected int` | `readBlock()` Reads next variable length block from input.
    `protected byte[]` | `readColorTable(int bpc)`
    `protected void` | `readContents()`
    `protected void` | `readGraphicControlExt()` Reads Graphics Control Extension values
    `protected void` | `readHeader()` Reads GIF file header information.
    `protected void` | `readImage()` Reads next frame image
    `protected void` | `readLSD()` Reads Logical Screen Descriptor
    `protected int` | `readShort()` Reads next 16-bit value, LSB first
    `protected void` | `resetFrame()` 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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### in

          protected java.io.DataInputStream 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:
        Constant Field Values

    - #### 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

          protected java.net.URL fromUrl

    - #### frames

          protected 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(java.lang.String file)
                   throws java.io.IOException

      Reads gif images from a file.
      Parameters:
        `file` - the file
      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

    - #### GifImage

          public GifImage(java.io.InputStream is)
                   throws java.io.IOException

      Reads gif images from a stream. The stream is not closed.
      Parameters:
        `is` - the stream
      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

    - #### 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

          void process(java.io.InputStream is)
                 throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readHeader

          protected void readHeader()
                             throws java.io.IOException

      Reads GIF file header information.
      Throws:
        `java.io.IOException`

    - #### readLSD

          protected void readLSD()
                          throws java.io.IOException

      Reads Logical Screen Descriptor
      Throws:
        `java.io.IOException`

    - #### readShort

          protected int readShort()
                           throws java.io.IOException

      Reads next 16-bit value, LSB first
      Throws:
        `java.io.IOException`

    - #### readBlock

          protected 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

          protected byte[] readColorTable(int bpc)
                                   throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### newBpc

          protected static int newBpc(int bpc)

    - #### readContents

          protected void readContents()
                               throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readImage

          protected void readImage()
                            throws java.io.IOException

      Reads next frame image
      Throws:
        `java.io.IOException`

    - #### decodeImageData

          protected boolean decodeImageData()
                                     throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### setPixel

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

    - #### resetFrame

          protected void resetFrame()

      Resets frame state for reading next image.

    - #### readGraphicControlExt

          protected void readGraphicControlExt()
                                        throws java.io.IOException

      Reads Graphics Control Extension values
      Throws:
        `java.io.IOException`

    - #### skip

          protected void skip()
                       throws java.io.IOException

      Skips variable length blocks up to and including next zero length block.
      Throws:
        `java.io.IOException`