B4A Library [B4X] APNG - animated PNG

Erel

Administrator
Staff member
Licensed User

(image source: https://apng.onevcat.com/demo/)

APNG is a format that extends PNG with support for animations, similar to animated gifs.
This class, which is implemented in B4X, extracts the frames from the APNG file and creates the animation.

It doesn't support all possible formats. If you encounter a file that is not supported then post it.


It depends on B4XCollections v1.08+ which is an internal library. B4XCollections v1.08 is attached (should be copied to the internal libraries folder if your version is older).

Under the hood it uses RandomAccessFile + BytesBuilder + BitmapCreator + native CRC32 implementation to extract the frames, build temporary images that are loaded as regular bitmaps and then animate them.

Tip: You can use this tool to create APNG images: http://apngasm.sourceforge.net/

Versions history

- V1.10 - Adds support for images with inter-frame optimizations: http://littlesvr.ca/apng/inter-frame.html
 

Attachments

Last edited:

Jorge M A

Well-Known Member
Licensed User
Is possible to have this with animated WEBP?
I don't know if it's related to your question, but maybe you missed this:
 

asales

Well-Known Member
Licensed User
I don't know if it's related to your question, but maybe you missed this:
Nope. Animated WebP is different.
It used in the new animated stickers to WhatsApp.
This lib works fine in B4J (in Android/B4A WebP has native support).
My goal is show the animated WebP like Erel made with this animated PNG.
 

HAH

Well-Known Member
Licensed User
wow, this is the first time i read about APNG. i never knew that there is another filetype that is animated like gif file.
me too :) we are keep learning ..
 

saeed10051

Active Member
Licensed User
I am getting following error on running the example

Error description: Unknown member: internalbuffer
Error occurred on line: 246
CRC32.RunMethod("update", Array(Buffer.InternalBuffer, Start, Buffer.Length - Start))
Word: internalbuffer

Also in the log it says
unknown member append2
 

pkarim

Member
Licensed User
I am getting following error on running the example

Error description: Unknown member: internalbuffer
Error occurred on line: 246
CRC32.RunMethod("update", Array(Buffer.InternalBuffer, Start, Buffer.Length - Start))
Word: internalbuffer

Also in the log it says
unknown member append2
B4XCollections v1.08 should be copied to the internal libraries folder.
 
Top