Package com.bumptech.glide.gifdecoder
Interface GifDecoder
- All Known Implementing Classes:
StandardGifDecoder
public interface GifDecoder
Shared interface for GIF decoders.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic @interfaceAndroid Lint annotation for status codes that can be used with a GIF decoder. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFile read status: Error decoding file (may be partially decoded).static final intFile read status: No errors.static final intFile read status: Unable to open source.static final intUnable to fully decode the current frame.static final intThe total iteration count which means repeat forever. -
Method Summary
Modifier and TypeMethodDescriptionvoidadvance()Move the animation frame counter forward.voidclear()intReturns an estimated byte size for this decoder based on the data provided tosetData(GifHeader, byte[]), as well as internal buffers.intGets the current index of the animation frame, or -1 if animation hasn't not yet started.getData()intgetDelay(int n) Gets display duration for specified frame.intGets the number of frames read from file.intintDeprecated.intGets the "Netscape" loop count, if any.intGets display duration for the upcoming frame in ms.Get the next frame in the animation sequence.intReturns the current status of the decoder.intGets 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(InputStream is, int contentLength) Reads GIF image from stream.voidResets the frame pointer to before the 0th frame, as if we'd never used this decoder to decode any frames.voidvoidsetData(GifHeader header, ByteBuffer buffer) voidsetData(GifHeader header, ByteBuffer buffer, int sampleSize) voidsetDefaultBitmapConfig(Bitmap.Config format) Sets the defaultBitmap.Configto use when decoding frames of a GIF.
-
Field Details
-
STATUS_OK
static final int STATUS_OKFile read status: No errors.- See Also:
-
STATUS_FORMAT_ERROR
static final int STATUS_FORMAT_ERRORFile read status: Error decoding file (may be partially decoded).- See Also:
-
STATUS_OPEN_ERROR
static final int STATUS_OPEN_ERRORFile read status: Unable to open source.- See Also:
-
STATUS_PARTIAL_DECODE
static final int STATUS_PARTIAL_DECODEUnable to fully decode the current frame.- See Also:
-
TOTAL_ITERATION_COUNT_FOREVER
static final int TOTAL_ITERATION_COUNT_FOREVERThe total iteration count which means repeat forever.- See Also:
-
-
Method Details
-
getWidth
int getWidth() -
getHeight
int getHeight() -
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.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:
-
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
Get the next frame in the animation sequence.- Returns:
- Bitmap representation of frame.
-
read
Reads GIF image from stream.- Parameters:
is- containing GIF file.- Returns:
- read status code (0 = no errors).
-
clear
void clear() -
setData
-
setData
-
setData
-
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
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.
-
getNetscapeLoopCount()instead.