Package org.ngengine.stbimage
Class GifDecoder
java.lang.Object
org.ngengine.stbimage.GifDecoder
- All Implemented Interfaces:
StbDecoder
GIF decoder.
Supports regular stbi_load-like first-frame decode through
load(int),
streaming frame-by-frame decode through loadNextFrame(int), and
full materialization through loadAllFrames(int).-
Constructor Summary
ConstructorsConstructorDescriptionGifDecoder(ByteBuffer buffer, IntFunction<ByteBuffer> allocator, boolean flipVertically) Creates a GIF decoder instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns the allocator used by this decoder for output buffers.intReturns the number of frames in the GIF stream.intReturns delay in milliseconds for the last frame returned byload(int)orloadNextFrame(int).info()Reads image metadata without fully decoding pixel data.booleanIndicates whether the GIF contains more than one frame.static booleanisGif(ByteBuffer buffer) Tests whether the source starts with a GIF87a/GIF89a signature.load(int desiredChannels) Decodes and returns the first frame (stb-style load behavior).loadAllFrames(int desiredChannels) Decodes all frames and returns them.loadNextFrame(int desiredChannels) Loads the next GIF frame in streaming mode.voidsetFillFirstFrameBackground(boolean fillFirstFrameBackground) Controls whether first-frame untouched pixels are filled using GIF logical screen background color.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ngengine.stbimage.StbDecoder
load16, loadf
-
Constructor Details
-
GifDecoder
Creates a GIF decoder instance.- Parameters:
buffer- source dataallocator- output allocatorflipVertically- true to flip decoded rows
-
-
Method Details
-
isGif
Tests whether the source starts with a GIF87a/GIF89a signature.- Parameters:
buffer- source bytes- Returns:
- true if the signature indicates GIF
-
getAllocator
Description copied from interface:StbDecoderReturns the allocator used by this decoder for output buffers.- Specified by:
getAllocatorin interfaceStbDecoder- Returns:
- allocator function
-
info
Description copied from interface:StbDecoderReads image metadata without fully decoding pixel data.- Specified by:
infoin interfaceStbDecoder- Returns:
- image information
-
load
Decodes and returns the first frame (stb-style load behavior).- Specified by:
loadin interfaceStbDecoder- Parameters:
desiredChannels- requested output channels (0 keeps source/default behavior)- Returns:
- decoded image result
-
loadNextFrame
Loads the next GIF frame in streaming mode. Once the trailer is reached, already decoded frames are replayed in a loop.- Specified by:
loadNextFramein interfaceStbDecoder- Parameters:
desiredChannels-- Returns:
-
loadAllFrames
Decodes all frames and returns them.- Specified by:
loadAllFramesin interfaceStbDecoder- Parameters:
desiredChannels- requested channel count- Returns:
- all frames in playback order
-
getFrameCount
public int getFrameCount()Returns the number of frames in the GIF stream. -
isAnimated
public boolean isAnimated()Indicates whether the GIF contains more than one frame. -
getLastFrameDelayMs
public int getLastFrameDelayMs()Returns delay in milliseconds for the last frame returned byload(int)orloadNextFrame(int). -
setFillFirstFrameBackground
public void setFillFirstFrameBackground(boolean fillFirstFrameBackground) Controls whether first-frame untouched pixels are filled using GIF logical screen background color.Enabled matches stb behavior. Disabling is useful for UI preview flows that prefer transparent untouched pixels.
-