java.lang.Object | |
↳ | org.libpag.PAGDecoder |
PAGDecoder provides a utility to read image frames directly from a PAGComposition, and caches the image frames as a sequence file on the disk, which may significantly speed up the reading process depending on the complexity of the PAG files. You can use the PAGDiskCache::SetMaxDiskSize() method to manage the cache limit of the disk usage.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static PAGDecoder |
Make(PAGComposition pagComposition, float maxFrameRate, float scale)
Creates a PAGDecoder with a PAGComposition, a frame rate limit, and a scale factor for the
decoded image size.
| ||||||||||
static PAGDecoder |
Make(PAGComposition pagComposition)
Creates a new PAGDecoder with the specified PAGComposition, using the composition's frame
rate and size.
| ||||||||||
boolean |
checkFrameChanged(int index)
Returns true if the frame at the given index has changed since the last copyFrameTo(),
readFrameTo(), or frameAtIndex() call.
| ||||||||||
boolean |
copyFrameTo(Bitmap bitmap, int index)
Copies pixels of the image frame at the given index to the specified Bitmap.
| ||||||||||
Bitmap |
frameAtIndex(int index)
Returns the image frame at the specified index.
| ||||||||||
float |
frameRate()
Returns the frame rate of decoded image frames.
| ||||||||||
int |
height()
Returns the height of decoded image frames.
| ||||||||||
int |
numFrames()
Returns the number of frames in the PAGDecoder.
| ||||||||||
boolean |
readFrame(int index, HardwareBuffer hardwareBuffer)
Reads pixels of the image frame at the given index into the specified HardwareBuffer.
| ||||||||||
void |
release()
Free up resources used by the PAGDecoder instance immediately instead of relying on the
garbage collector to do this for you at some point in the future.
| ||||||||||
int |
width()
Returns the width of decoded image frames.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void | finalize() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Creates a PAGDecoder with a PAGComposition, a frame rate limit, and a scale factor for the decoded image size. Please only keep an external reference to the PAGComposition if you need to modify it in the feature. Otherwise, the internal composition will not be released automatically after the associated disk cache is complete, which may cost more memory than necessary. Returns nullptr if the composition is nullptr. Note that the returned PAGDecoder may become invalid if the associated PAGComposition is added to a PAGPlayer or another PAGDecoder.
Creates a new PAGDecoder with the specified PAGComposition, using the composition's frame rate and size. Please only keep an external reference to the PAGComposition if you need to modify it in the feature. Otherwise, the internal composition will not be released automatically after the associated disk cache is complete, which may cost more memory than necessary. Returns nil if the composition is nil. Note that the returned PAGDecoder may become invalid if the associated PAGComposition is added to a PAGPlayer or another PAGDecoder.
Returns true if the frame at the given index has changed since the last copyFrameTo(), readFrameTo(), or frameAtIndex() call. The caller should skip the corresponding call if the frame has not changed.
Copies pixels of the image frame at the given index to the specified Bitmap. Returns false if failed. Note that caller must ensure that the config of Bitmap stays the same throughout every copying call. Otherwise, it may return false.
Returns the image frame at the specified index. It's recommended to read the image frames in forward order for better performance.
Returns the frame rate of decoded image frames. The value may change if the associated PAGComposition was modified.
Returns the height of decoded image frames.
Returns the number of frames in the PAGDecoder. Note that the value may change if the associated PAGComposition was modified.
Reads pixels of the image frame at the given index into the specified HardwareBuffer. Returns false if failed. Reading image frames into HardwareBuffer usually has better performance than reading into memory.
Free up resources used by the PAGDecoder instance immediately instead of relying on the garbage collector to do this for you at some point in the future.
Returns the width of decoded image frames.