public class

GifImage

extends Object
implements AnimatedImage AnimatedImageDecoder
java.lang.Object
   ↳ com.facebook.animated.gif.GifImage

Class Overview

A representation of a GIF image. An instance of this class will hold a copy of the encoded data in memory along with the parsed header data. Frames are decoded on demand via GifFrame.

Summary

[Expand]
Inherited Constants
From interface com.facebook.imagepipeline.animated.base.AnimatedImage
Public Constructors
GifImage()
Public Methods
static GifImage createFromByteArray(byte[] source)
Creates a GifImage from the specified encoded data.
static GifImage createFromByteBuffer(ByteBuffer byteBuffer, ImageDecodeOptions options)
Creates a GifImage from a ByteBuffer containing the image.
static GifImage createFromByteBuffer(ByteBuffer byteBuffer)
Creates a GifImage from a ByteBuffer containing the image.
static GifImage createFromFileDescriptor(int fileDescriptor, ImageDecodeOptions options)
Creates a GifImage from a file descriptor containing the image.
static GifImage createFromNativeMemory(long nativePtr, int sizeInBytes, ImageDecodeOptions options)
AnimatedImage decodeFromByteBuffer(ByteBuffer byteBuffer, ImageDecodeOptions options)
Factory method to create the AnimatedImage from a ByteBuffer
AnimatedImage decodeFromNativeMemory(long nativePtr, int sizeInBytes, ImageDecodeOptions options)
Factory method to create the AnimatedImage from a native pointer
void dispose()
Disposes the instance.
boolean doesRenderSupportScaling()
Returns whether renderFrame(int, int, Bitmap) supports scaling to arbitrary sizes or whether scaling must be done externally.
int getDuration()
Gets the duration of the animated image.
GifFrame getFrame(int frameNumber)
Creates an AnimatedImageFrame at the specified index.
int getFrameCount()
Gets the number of frames in the image.
int[] getFrameDurations()
Gets the duration of each frame of the animated image.
AnimatedDrawableFrameInfo getFrameInfo(int frameNumber)
Gets the frame info for the specified frame.
int getHeight()
Gets the height of the image (also known as the canvas in WebP nomenclature).
int getLoopCount()
Gets the number of loops to run the animation for.
int getSizeInBytes()
Gets the size of bytes of the encoded image data (which is the data kept in memory for the image).
int getWidth()
Gets the width of the image (also known as the canvas in WebP nomenclature).
boolean isAnimated()
Protected Methods
void finalize()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.facebook.imagepipeline.animated.base.AnimatedImage
From interface com.facebook.imagepipeline.animated.factory.AnimatedImageDecoder

Public Constructors

public GifImage ()

Public Methods

public static GifImage createFromByteArray (byte[] source)

Creates a GifImage from the specified encoded data. This will throw if it fails to create. This is meant to be called on a worker thread.

Parameters
source the data to the image (a copy will be made)

public static GifImage createFromByteBuffer (ByteBuffer byteBuffer, ImageDecodeOptions options)

Creates a GifImage from a ByteBuffer containing the image. This will throw if it fails to create.

Parameters
byteBuffer the ByteBuffer containing the image (a copy will be made)

public static GifImage createFromByteBuffer (ByteBuffer byteBuffer)

Creates a GifImage from a ByteBuffer containing the image. This will throw if it fails to create.

Parameters
byteBuffer the ByteBuffer containing the image (a copy will be made)

public static GifImage createFromFileDescriptor (int fileDescriptor, ImageDecodeOptions options)

Creates a GifImage from a file descriptor containing the image. This will throw if it fails to create.

Parameters
fileDescriptor the file descriptor containing the image (a copy will be made)

public static GifImage createFromNativeMemory (long nativePtr, int sizeInBytes, ImageDecodeOptions options)

public AnimatedImage decodeFromByteBuffer (ByteBuffer byteBuffer, ImageDecodeOptions options)

Factory method to create the AnimatedImage from a ByteBuffer

Parameters
byteBuffer The ByteBuffer containing the image
options The options for decoding
Returns
  • The AnimatedImage allocation

public AnimatedImage decodeFromNativeMemory (long nativePtr, int sizeInBytes, ImageDecodeOptions options)

Factory method to create the AnimatedImage from a native pointer

Parameters
nativePtr The native pointer
sizeInBytes The size in byte to allocate
options The options for decoding
Returns
  • The AnimatedImage allocation

public void dispose ()

Disposes the instance. This will free native resources held by this instance. Once called, other methods on this instance may throw. Note, the underlying native resources may not actually be freed until all associated instances of AnimatedImageFrame are disposed or finalized as well.

public boolean doesRenderSupportScaling ()

Returns whether renderFrame(int, int, Bitmap) supports scaling to arbitrary sizes or whether scaling must be done externally.

Returns
  • whether rendering supports scaling

public int getDuration ()

Gets the duration of the animated image.

Returns
  • the duration of the animated image in milliseconds

public GifFrame getFrame (int frameNumber)

Creates an AnimatedImageFrame at the specified index.

Parameters
frameNumber the index of the frame
Returns

public int getFrameCount ()

Gets the number of frames in the image.

Returns
  • the number of frames in the image

public int[] getFrameDurations ()

Gets the duration of each frame of the animated image.

Returns
  • an array that is the size of the number of frames containing the duration of each frame in milliseconds

public AnimatedDrawableFrameInfo getFrameInfo (int frameNumber)

Gets the frame info for the specified frame.

Parameters
frameNumber the frame to get the info for
Returns
  • the frame info

public int getHeight ()

Gets the height of the image (also known as the canvas in WebP nomenclature).

Returns
  • the height of the image

public int getLoopCount ()

Gets the number of loops to run the animation for.

Returns
  • the number of loops, or 0 to indicate infinite

public int getSizeInBytes ()

Gets the size of bytes of the encoded image data (which is the data kept in memory for the image).

Returns
  • the size in bytes of the encoded image data

public int getWidth ()

Gets the width of the image (also known as the canvas in WebP nomenclature).

Returns
  • the width of the image

public boolean isAnimated ()

Protected Methods

protected void finalize ()