类 GifDecoder


  • public class GifDecoder
    extends java.lang.Object
    Class GifDecoder - Decodes a GIF file into one or more frames. No copyright asserted on the source code of this class. May be used for any purpose, however, refer to the Unisys LZW patent for any additional restrictions. Please forward any corrections to kweiner@fmsware.com.
    版本:
    1.03 November 2003
    作者:
    Kevin Weiner, FM Software; LZW decoder adapted from John Cristy's ImageMagick.
    • 构造器概要

      构造器 
      构造器 说明
      GifDecoder()  
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      protected void decodeImageData()
      Decodes LZW image data into pixel array.
      protected boolean err()
      Returns true if an error was encountered during reading/decoding
      int getDelay​(int n)
      Gets display duration for specified frame.
      java.awt.image.BufferedImage getFrame​(int n)
      Gets the image contents of frame n.
      int getFrameCount()
      Gets the number of frames read from file.
      java.awt.Dimension getFrameSize()
      Gets image size.
      java.awt.image.BufferedImage getImage()
      Gets the first (or only) image read.
      int getLoopCount()
      Gets the "Netscape" iteration count, if any.
      protected void init()
      Initializes or re-initializes reader
      protected int read()
      Reads a single byte from the input stream.
      int read​(java.io.BufferedInputStream is)
      Reads GIF image from stream
      int read​(java.io.InputStream is)
      Reads GIF image from stream
      int read​(java.lang.String name)
      Reads GIF file from specified file/URL source (URL assumed if name contains ":/" or "file:")
      protected int readBlock()
      Reads next variable length block from input.
      protected int[] readColorTable​(int ncolors)
      Reads color table as 256 RGB integer values
      protected void readContents()
      Main file parser.
      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 void readNetscapeExt()
      Reads Netscape extenstion to obtain iteration count
      protected int readShort()
      Reads next 16-bit value, LSB first
      protected void resetFrame()
      Resets frame state for reading next image.
      protected void setPixels()
      Creates new frame image from current data (and previous frames as specified by their disposition codes).
      protected void skip()
      Skips variable length blocks up to and including next zero length block.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • STATUS_OK

        public static final int STATUS_OK
        File read status: No errors.
        另请参阅:
        常量字段值
      • STATUS_FORMAT_ERROR

        public static final int STATUS_FORMAT_ERROR
        File read status: Error decoding file (may be partially decoded)
        另请参阅:
        常量字段值
      • STATUS_OPEN_ERROR

        public static final int STATUS_OPEN_ERROR
        File read status: Unable to open source.
        另请参阅:
        常量字段值
      • in

        protected java.io.BufferedInputStream in
      • status

        protected int status
      • width

        protected int width
      • height

        protected int height
      • gctFlag

        protected boolean gctFlag
      • gctSize

        protected int gctSize
      • loopCount

        protected int loopCount
      • gct

        protected int[] gct
      • lct

        protected int[] lct
      • act

        protected int[] act
      • bgIndex

        protected int bgIndex
      • bgColor

        protected int bgColor
      • lastBgColor

        protected int lastBgColor
      • 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
      • lastRect

        protected java.awt.Rectangle lastRect
      • image

        protected java.awt.image.BufferedImage image
      • lastImage

        protected java.awt.image.BufferedImage lastImage
      • block

        protected byte[] block
      • blockSize

        protected int blockSize
      • dispose

        protected int dispose
      • lastDispose

        protected int lastDispose
      • transparency

        protected boolean transparency
      • delay

        protected int delay
      • transIndex

        protected int transIndex
      • MaxStackSize

        protected static final int MaxStackSize
        另请参阅:
        常量字段值
      • prefix

        protected short[] prefix
      • suffix

        protected byte[] suffix
      • pixelStack

        protected byte[] pixelStack
      • pixels

        protected byte[] pixels
      • frames

        protected java.util.ArrayList frames
      • frameCount

        protected int frameCount
    • 构造器详细资料

      • GifDecoder

        public GifDecoder()
    • 方法详细资料

      • getDelay

        public int getDelay​(int n)
        Gets display duration for specified frame.
        参数:
        n - int index of frame
        返回:
        delay in milliseconds
      • getFrameCount

        public int getFrameCount()
        Gets the number of frames read from file.
        返回:
        frame count
      • getImage

        public java.awt.image.BufferedImage getImage()
        Gets the first (or only) image read.
        返回:
        BufferedImage containing first frame, or null if none.
      • getLoopCount

        public int getLoopCount()
        Gets the "Netscape" iteration count, if any. A count of 0 means repeat indefinitiely.
        返回:
        iteration count if one was specified, else 1.
      • setPixels

        protected void setPixels()
        Creates new frame image from current data (and previous frames as specified by their disposition codes).
      • getFrame

        public java.awt.image.BufferedImage getFrame​(int n)
        Gets the image contents of frame n.
        参数:
        n - Frame index
        返回:
        BufferedImage representation of frame, or null if n is invalid.
      • getFrameSize

        public java.awt.Dimension getFrameSize()
        Gets image size.
        返回:
        GIF image dimensions
      • read

        public int read​(java.io.BufferedInputStream is)
        Reads GIF image from stream
        参数:
        is - containing GIF file.
        返回:
        read status code (0 = no errors)
      • read

        public int read​(java.io.InputStream is)
        Reads GIF image from stream
        参数:
        is - containing GIF file.
        返回:
        read status code (0 = no errors)
      • read

        public int read​(java.lang.String name)
        Reads GIF file from specified file/URL source (URL assumed if name contains ":/" or "file:")
        参数:
        name - String containing source
        返回:
        read status code (0 = no errors)
      • decodeImageData

        protected void decodeImageData()
        Decodes LZW image data into pixel array. Adapted from John Cristy's ImageMagick.
      • err

        protected boolean err()
        Returns true if an error was encountered during reading/decoding
        返回:
        Boolean
      • init

        protected void init()
        Initializes or re-initializes reader
      • read

        protected int read()
        Reads a single byte from the input stream.
        返回:
        The byte
      • readBlock

        protected int readBlock()
        Reads next variable length block from input.
        返回:
        number of bytes stored in "buffer"
      • readColorTable

        protected int[] readColorTable​(int ncolors)
        Reads color table as 256 RGB integer values
        参数:
        ncolors - int number of colors to read
        返回:
        int array containing 256 colors (packed ARGB with full alpha)
      • readContents

        protected void readContents()
        Main file parser. Reads GIF content blocks.
      • 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
      • readNetscapeExt

        protected void readNetscapeExt()
        Reads Netscape extenstion to obtain iteration count
      • readShort

        protected int readShort()
        Reads next 16-bit value, LSB first
        返回:
        The short
      • resetFrame

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

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