# GifDecoder

open class GifDecoder

Reads frame data from a GIF image source and decodes it into individual frames for animation purposes. Image data can be read from either and InputStream source or a byte[]. This class is optimized for running animations with the frames, there are no methods to get individual frame images, only to decode the next frame in the animation sequence. Instead, it lowers its memory footprint by only housing the minimum data necessary to decode the next frame in the animation sequence. The animation must be manually moved forward using advance before requesting the next frame. This method must also be called before you request the first frame or an error will occur. Implementation adapted from sample code published in Lyons. (2004). Java for Programmers, republished under the MIT Open Source License

## Constructors

GifDecoder
Link copied to clipboard
constructor(provider: GifDecoder.BitmapProvider, gifHeader: GifHeader, rawData: ByteBuffer)
constructor(provider: GifDecoder.BitmapProvider, gifHeader: GifHeader, rawData: ByteBuffer, sampleSize: Int)
constructor(provider: GifDecoder.BitmapProvider)
constructor()

## Properties

loopIndex
Link copied to clipboard
open val loopIndex: Int
status
Link copied to clipboard
open val status: Int

## Functions

advance
Link copied to clipboard
open fun advance(): Boolean
Move the animation frame counter forward.
clear
Link copied to clipboard
open fun clear()
getByteSize
Link copied to clipboard
open fun getByteSize(): Int
Returns an estimated byte size for this decoder based on the data provided to setData, as well as internal buffers.
getCurrentFrameIndex
Link copied to clipboard
open fun getCurrentFrameIndex(): Int
Gets the current index of the animation frame, or -1 if animation hasn't not yet started.
getDelay
Link copied to clipboard
open fun getDelay(n: Int): Int
Gets display duration for specified frame.
getFrameCount
Link copied to clipboard
open fun getFrameCount(): Int
Gets the number of frames read from file.
getHeight
Link copied to clipboard
open fun getHeight(): Int
getLoopCount
Link copied to clipboard
open fun getLoopCount(): Int
Gets the "Netscape" iteration count, if any.
getNextDelay
Link copied to clipboard
open fun getNextDelay(): Int
Gets display duration for the upcoming frame in ms.
getNextFrame
Link copied to clipboard
open fun getNextFrame(): Bitmap
Get the next frame in the animation sequence.
getWidth
Link copied to clipboard
open fun getWidth(): Int
read
Link copied to clipboard
open fun read(data: Array<Byte>): Int
Reads GIF image from byte array.
open fun read(is: InputStream, contentLength: Int): Int
Reads GIF image from stream.
resetFrameIndex
Link copied to clipboard
open fun resetFrameIndex()
Resets the frame pointer to before the 0th frame, as if we'd never used this decoder to decode any frames.
resetLoopIndex
Link copied to clipboard
open fun resetLoopIndex()
Resets the loop index to the first loop.
setData
Link copied to clipboard
open fun setData(header: GifHeader, data: Array<Byte>)
open fun setData(header: GifHeader, buffer: ByteBuffer)
open fun setData(header: GifHeader, buffer: ByteBuffer, sampleSize: Int)
setFrameIndex
Link copied to clipboard
open fun setFrameIndex(frame: Int): Boolean
Sets the frame pointer to a specific frame