Class AnimatedWebPData
This class holds the complete result of decoding an animated WebP file, including individual frames with their timestamps, canvas dimensions, loop count, and background color.
The raw frame data (byte arrays and timestamps) are populated by the
native layer, and then converted to AnimatedWebPFrame objects
by the decoder.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGets the background color of the animation canvas.intGets the canvas height in pixels.intGets the canvas width in pixels.int[]Computes per-frame delays from the cumulative timestamps.intGets the total number of frames in the animation.Gets the list of decoded frames.intGets the loop count for the animation.byte[][]Gets the raw RGBA frame data populated by the native layer.int[]Gets the cumulative timestamps for each frame in milliseconds.voidsetBgcolor(int bgcolor) Sets the background color.voidsetCanvasHeight(int canvasHeight) Sets the canvas height.voidsetCanvasWidth(int canvasWidth) Sets the canvas width.voidsetFrameCount(int frameCount) Sets the frame count.voidsetFrames(List<AnimatedWebPFrame> frames) Sets the list of decoded frames.voidsetLoopCount(int loopCount) Sets the loop count.voidsetRawFrameData(byte[][] rawFrameData) Sets the raw frame data.voidsetTimestamps(int[] timestamps) Sets the timestamps array.toString()
-
Constructor Details
-
AnimatedWebPData
public AnimatedWebPData()Public constructor.
-
-
Method Details
-
getFrames
Gets the list of decoded frames.- Returns:
- List of frames, each containing a BufferedImage and timestamp
-
setFrames
Sets the list of decoded frames.- Parameters:
frames- List of decoded frames
-
getCanvasWidth
public int getCanvasWidth()Gets the canvas width in pixels.- Returns:
- Canvas width
-
setCanvasWidth
public void setCanvasWidth(int canvasWidth) Sets the canvas width.- Parameters:
canvasWidth- Canvas width in pixels
-
getCanvasHeight
public int getCanvasHeight()Gets the canvas height in pixels.- Returns:
- Canvas height
-
setCanvasHeight
public void setCanvasHeight(int canvasHeight) Sets the canvas height.- Parameters:
canvasHeight- Canvas height in pixels
-
getLoopCount
public int getLoopCount()Gets the loop count for the animation.- Returns:
- Loop count (0 = infinite loop)
-
setLoopCount
public void setLoopCount(int loopCount) Sets the loop count.- Parameters:
loopCount- Loop count (0 = infinite loop)
-
getBgcolor
public int getBgcolor()Gets the background color of the animation canvas.- Returns:
- Background color as ARGB integer
-
setBgcolor
public void setBgcolor(int bgcolor) Sets the background color.- Parameters:
bgcolor- Background color as ARGB integer
-
getFrameCount
public int getFrameCount()Gets the total number of frames in the animation.- Returns:
- Frame count
-
setFrameCount
public void setFrameCount(int frameCount) Sets the frame count.- Parameters:
frameCount- Total number of frames
-
getRawFrameData
public byte[][] getRawFrameData()Gets the raw RGBA frame data populated by the native layer.Each element is an RGBA byte array of size canvasWidth * canvasHeight * 4. This data is used internally by the decoder to create BufferedImage objects.
- Returns:
- Array of RGBA frame byte arrays, or null if not yet populated
-
setRawFrameData
public void setRawFrameData(byte[][] rawFrameData) Sets the raw frame data. Called by native code.- Parameters:
rawFrameData- Array of RGBA frame byte arrays
-
getTimestamps
public int[] getTimestamps()Gets the cumulative timestamps for each frame in milliseconds.These are populated by the native layer and represent the time at which each frame should be displayed from the start of the animation.
- Returns:
- Array of timestamps in milliseconds, or null if not yet populated
-
setTimestamps
public void setTimestamps(int[] timestamps) Sets the timestamps array. Called by native code.- Parameters:
timestamps- Array of cumulative timestamps in milliseconds
-
getDelays
public int[] getDelays()Computes per-frame delays from the cumulative timestamps.The delay for each frame is calculated as the difference between consecutive timestamps. The first frame's delay is its timestamp value.
- Returns:
- Array of per-frame delays in milliseconds
- Throws:
IllegalStateException- If frames have not been decoded yet
-
toString
-