Package com.bumptech.glide.gifdecoder
Interface GifDecoder
-
- All Known Implementing Classes:
StandardGifDecoder
public interface GifDecoderShared interface for GIF decoders.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceGifDecoder.BitmapProviderAn interface that can be used to provide reusedBitmaps to avoid GCs from constantly allocatingBitmaps for every frame.static interfaceGifDecoder.GifDecodeStatusAndroid Lint annotation for status codes that can be used with a GIF decoder.
-
Field Summary
Fields Modifier and Type Field Description static intSTATUS_FORMAT_ERRORFile read status: Error decoding file (may be partially decoded).static intSTATUS_OKFile read status: No errors.static intSTATUS_OPEN_ERRORFile read status: Unable to open source.static intSTATUS_PARTIAL_DECODEUnable to fully decode the current frame.static intTOTAL_ITERATION_COUNT_FOREVERThe total iteration count which means repeat forever.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidadvance()Move the animation frame counter forward.voidclear()intgetByteSize()Returns an estimated byte size for this decoder based on the data provided tosetData(GifHeader, byte[]), as well as internal buffers.intgetCurrentFrameIndex()Gets the current index of the animation frame, or -1 if animation hasn't not yet started.java.nio.ByteBuffergetData()intgetDelay(int n)Gets display duration for specified frame.intgetFrameCount()Gets the number of frames read from file.intgetHeight()intgetLoopCount()Deprecated.UsegetNetscapeLoopCount()instead.intgetNetscapeLoopCount()Gets the "Netscape" loop count, if any.intgetNextDelay()Gets display duration for the upcoming frame in ms.android.graphics.BitmapgetNextFrame()Get the next frame in the animation sequence.intgetStatus()Returns the current status of the decoder.intgetTotalIterationCount()Gets the total count which represents how many times the animation sequence should be displayed.intgetWidth()intread(byte[] data)Reads GIF image from byte array.intread(java.io.InputStream is, int contentLength)Reads GIF image from stream.voidresetFrameIndex()Resets the frame pointer to before the 0th frame, as if we'd never used this decoder to decode any frames.voidsetData(GifHeader header, byte[] data)voidsetData(GifHeader header, java.nio.ByteBuffer buffer)voidsetData(GifHeader header, java.nio.ByteBuffer buffer, int sampleSize)voidsetDefaultBitmapConfig(android.graphics.Bitmap.Config format)Sets the defaultBitmap.Configto use when decoding frames of a GIF.
-
-
-
Field Detail
-
STATUS_OK
static final int STATUS_OK
File read status: No errors.- See Also:
- Constant Field Values
-
STATUS_FORMAT_ERROR
static final int STATUS_FORMAT_ERROR
File read status: Error decoding file (may be partially decoded).- See Also:
- Constant Field Values
-
STATUS_OPEN_ERROR
static final int STATUS_OPEN_ERROR
File read status: Unable to open source.- See Also:
- Constant Field Values
-
STATUS_PARTIAL_DECODE
static final int STATUS_PARTIAL_DECODE
Unable to fully decode the current frame.- See Also:
- Constant Field Values
-
TOTAL_ITERATION_COUNT_FOREVER
static final int TOTAL_ITERATION_COUNT_FOREVER
The total iteration count which means repeat forever.- See Also:
- Constant Field Values
-
-
Method Detail
-
getWidth
int getWidth()
-
getHeight
int getHeight()
-
getData
@NonNull java.nio.ByteBuffer getData()
-
getStatus
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 frame was decoded successfully and/or completely. Format and open failures persist across frames.
-
advance
void advance()
Move the animation frame counter forward.
-
getDelay
int getDelay(int n)
Gets display duration for specified frame.- Parameters:
n- int index of frame.- Returns:
- delay in milliseconds.
-
getNextDelay
int getNextDelay()
Gets display duration for the upcoming frame in ms.
-
getFrameCount
int getFrameCount()
Gets the number of frames read from file.- Returns:
- frame count.
-
getCurrentFrameIndex
int getCurrentFrameIndex()
Gets the current index of the animation frame, or -1 if animation hasn't not yet started.- Returns:
- frame index.
-
resetFrameIndex
void resetFrameIndex()
Resets the frame pointer to before the 0th frame, as if we'd never used this decoder to decode any frames.
-
getLoopCount
@Deprecated int getLoopCount()
Deprecated.UsegetNetscapeLoopCount()instead. This method cannot distinguish whether the loop count is 1 or doesn't exist.Gets the "Netscape" loop count, if any. A count of 0 means repeat indefinitely.- Returns:
- loop count if one was specified, else 1.
-
getNetscapeLoopCount
int getNetscapeLoopCount()
Gets the "Netscape" loop count, if any. A count of 0 (GifHeader.NETSCAPE_LOOP_COUNT_FOREVER) means repeat indefinitely. It must not be a negative value.
UsegetTotalIterationCount()to know how many times the animation sequence should be displayed.- Returns:
- loop count if one was specified,
else -1 (
GifHeader.NETSCAPE_LOOP_COUNT_DOES_NOT_EXIST).
-
getTotalIterationCount
int getTotalIterationCount()
Gets the total count which 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.getNetscapeLoopCount()The total count GifHeader.NETSCAPE_LOOP_COUNT_FOREVERTOTAL_ITERATION_COUNT_FOREVERGifHeader.NETSCAPE_LOOP_COUNT_DOES_NOT_EXIST1n (n > 0)n + 1- Returns:
- total iteration count calculated from "Netscape" loop count.
- See Also:
- Discussion about the iteration count of animated GIFs (Chromium Issue 592735)
-
getByteSize
int getByteSize()
Returns an estimated byte size for this decoder based on the data provided tosetData(GifHeader, byte[]), as well as internal buffers.
-
getNextFrame
@Nullable android.graphics.Bitmap getNextFrame()
Get the next frame in the animation sequence.- Returns:
- Bitmap representation of frame.
-
read
int read(@Nullable java.io.InputStream is, int contentLength)Reads GIF image from stream.- Parameters:
is- containing GIF file.- Returns:
- read status code (0 = no errors).
-
clear
void clear()
-
setData
void setData(@NonNull GifHeader header, @NonNull byte[] data)
-
setData
void setData(@NonNull GifHeader header, @NonNull java.nio.ByteBuffer buffer)
-
setData
void setData(@NonNull GifHeader header, @NonNull java.nio.ByteBuffer buffer, int sampleSize)
-
read
int read(@Nullable byte[] data)Reads GIF image from byte array.- Parameters:
data- containing GIF file.- Returns:
- read status code (0 = no errors).
-
setDefaultBitmapConfig
void setDefaultBitmapConfig(@NonNull android.graphics.Bitmap.Config format)Sets the defaultBitmap.Configto use when decoding frames of a GIF.Valid options are
Bitmap.Config.ARGB_8888andBitmap.Config.RGB_565.Bitmap.Config.ARGB_8888will produce higher quality frames, but will also use 2x the memory ofBitmap.Config.RGB_565.Defaults to
Bitmap.Config.ARGB_8888This value is not a guarantee. For example if set to
Bitmap.Config.RGB_565and the GIF contains transparent pixels,Bitmap.Config.ARGB_8888will be used anyway to support the transparency.
-
-