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

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

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

Functions

Link copied to clipboard
open fun advance(): Boolean
Move the animation frame counter forward.
Link copied to clipboard
open fun clear()
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.
Link copied to clipboard
Gets the current index of the animation frame, or -1 if animation hasn't not yet started.
Link copied to clipboard
open fun getDelay(n: Int): Int
Gets display duration for specified frame.
Link copied to clipboard
open fun getFrameCount(): Int
Gets the number of frames read from file.
Link copied to clipboard
open fun getHeight(): Int
Link copied to clipboard
open fun getLoopCount(): Int
Gets the "Netscape" iteration count, if any.
Link copied to clipboard
open fun getNextDelay(): Int
Gets display duration for the upcoming frame in ms.
Link copied to clipboard
open fun getNextFrame(): Bitmap
Get the next frame in the animation sequence.
Link copied to clipboard
open fun getWidth(): Int
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.
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.
Link copied to clipboard
open fun resetLoopIndex()
Resets the loop index to the first loop.
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)
Link copied to clipboard
open fun setFrameIndex(frame: Int): Boolean
Sets the frame pointer to a specific frame