-
public interface GifDecoderShared interface for GIF decoders.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public @interfaceGifDecoder.GifDecodeStatusAndroid Lint annotation for status codes that can be used with a GIF decoder.
public interfaceGifDecoder.BitmapProviderAn interface that can be used to provide reused Bitmaps to avoid GCsfrom constantly allocating Bitmaps for every frame.
-
Method Summary
Modifier and Type Method Description abstract intgetWidth()abstract intgetHeight()abstract ByteBuffergetData()abstract intgetStatus()Returns the current status of the decoder. abstract voidadvance()Move the animation frame counter forward. abstract intgetDelay(int n)Gets display duration for specified frame. abstract intgetNextDelay()Gets display duration for the upcoming frame in ms. abstract intgetFrameCount()Gets the number of frames read from file. abstract intgetCurrentFrameIndex()Gets the current index of the animation frame, or -1 if animation hasn't not yet started. abstract voidresetFrameIndex()Resets the frame pointer to before the 0th frame, as if we'd never used this decoder todecode any frames. abstract intgetLoopCount()Gets the "Netscape" loop count, if any. abstract intgetNetscapeLoopCount()Gets the "Netscape" loop count, if any. abstract intgetTotalIterationCount()Gets the total countwhich represents how many times the animation sequence should be displayed. abstract intgetByteSize()Returns an estimated byte size for this decoder based on the data provided to , as well as internal buffers. abstract BitmapgetNextFrame()Get the next frame in the animation sequence. abstract intread(@Nullable() InputStream is, int contentLength)Reads GIF image from stream. abstract voidclear()abstract voidsetData(@NonNull() GifHeader header, @NonNull() Array<byte> data)abstract voidsetData(@NonNull() GifHeader header, @NonNull() ByteBuffer buffer)abstract voidsetData(@NonNull() GifHeader header, @NonNull() ByteBuffer buffer, int sampleSize)abstract intread(@Nullable() Array<byte> data)Reads GIF image from byte array. abstract voidsetDefaultBitmapConfig(@NonNull() Bitmap.Config format)Sets the default Bitmap.Config to use when decoding frames of a GIF. -
-
Method Detail
-
getWidth
abstract int getWidth()
-
getHeight
abstract int getHeight()
-
getData
@NonNull() abstract ByteBuffer getData()
-
getStatus
abstract int getStatus()
Returns the current status of the decoder.
Status will update per frame to allow the caller to tell whether or not the current framewas decoded successfully and/or completely. Format and open failures persist across frames.
-
advance
abstract void advance()
Move the animation frame counter forward.
-
getDelay
abstract int getDelay(int n)
Gets display duration for specified frame.
- Parameters:
n- int index of frame.
-
getNextDelay
abstract int getNextDelay()
Gets display duration for the upcoming frame in ms.
-
getFrameCount
abstract int getFrameCount()
Gets the number of frames read from file.
-
getCurrentFrameIndex
abstract int getCurrentFrameIndex()
Gets the current index of the animation frame, or -1 if animation hasn't not yet started.
-
resetFrameIndex
abstract void resetFrameIndex()
Resets the frame pointer to before the 0th frame, as if we'd never used this decoder todecode any frames.
-
getLoopCount
@Deprecated() abstract int getLoopCount()
Gets the "Netscape" loop count, if any. A count of 0 means repeat indefinitely.
-
getNetscapeLoopCount
abstract int getNetscapeLoopCount()
Gets the "Netscape" loop count, if any.A count of 0 (NETSCAPE_LOOP_COUNT_FOREVER) means repeat indefinitely.It must not be a negative value.Use getTotalIterationCount to know how many times the animation sequence should be displayed.
-
getTotalIterationCount
abstract int getTotalIterationCount()
Gets the total countwhich represents how many times the animation sequence should be displayed.A count of 0 (TOTAL_ITERATION_COUNT_FOREVER) means repeat indefinitely.It must not be a negative value.
The total count is calculated as follows by using getNetscapeLoopCount.This behavior is the same as most web browsers.
-
getByteSize
abstract int getByteSize()
-
getNextFrame
@Nullable() abstract Bitmap getNextFrame()
Get the next frame in the animation sequence.
-
read
abstract int read(@Nullable() InputStream is, int contentLength)
Reads GIF image from stream.
- Parameters:
is- containing GIF file.
-
clear
abstract void clear()
-
setData
abstract void setData(@NonNull() GifHeader header, @NonNull() ByteBuffer buffer)
-
setData
abstract void setData(@NonNull() GifHeader header, @NonNull() ByteBuffer buffer, int sampleSize)
-
read
abstract int read(@Nullable() Array<byte> data)
Reads GIF image from byte array.
- Parameters:
data- containing GIF file.
-
setDefaultBitmapConfig
abstract void setDefaultBitmapConfig(@NonNull() Bitmap.Config format)
Sets the default Bitmap.Config to use when decoding frames of a GIF.
Valid options are ARGB_8888 and RGB_565. ARGB_8888 will produce higher quality frames, but willalso use 2x the memory of RGB_565.
Defaults to ARGB_8888
This value is not a guarantee. For example if set to RGB_565 and the GIF contains transparent pixels, ARGB_8888 will be used anyway to support thetransparency.
-
-
-
-