Project Proposal: Extending the PNG image loader to handle APNGs

Ethan Hall ethan.hall.1080 at gmail.com
Thu Dec 1 01:51:48 UTC 2022


I am new here, but I have contributed to other open source projects before.
I have signed the contributor agreement and read through the
contributor info provided on the GitHub repository.
The GitHub page says to discuss new features here, so here is my proposal.

Summary
-------

I would like to contribute code with the purpose of extending the PNG image
loader to handle animated PNGs as specified by the APNG standard.
The APNG specification can be found here:
https://wiki.mozilla.org/APNG_Specification

Goals
-----

Enable JavaFX to be able to load APNGs as animated images.

Motivation
----------

APNG is an extension of the PNG format that allows for animation.
APNG images can be used as a higher quality alternative to GIF.
The APNG standard is supported by all major modern internet browsers.

JavaFX can already load animated GIFs, so additionally supporting animated
PNGs makes sense.

Description
-----------

To support APNGs, the PNGImageLoader2 and PNGIDATChunkInputStream classes
need to be modified so they can process the animation chunks acTL, fcTL,
fdAT.

Values from the acTL and fcTL chunks can simply be read like the image
header chunk.
The metadata for the frame can be updated based on these values.

The fdAT chunks store data in exactly the same way as the IDAT chunks and
can be handled by the PNGIDATChunkInputStream class with little
modification.

Once a new frame of image data has been decompressed, it will need to be
composited with the frame buffer based on the blend OP code.
Then, the frame buffer needs to be updated based on the disposal OP code.
The composting process can be handled in a similar way to how JavaFX
handles GIFs.

After compositing, the ImageFrame can be returned.

Testing
-----------

Other than unit tests, I am not sure.
I would like some advice on what to include for testing.

Dependencies
------------

This change should not require any additional dependencies.


Thanks,
-Ethan Hall
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20221130/7d159296/attachment.htm>


More information about the openjfx-dev mailing list