To actually decode the PNG images Papyrix depends on an Arduino library called "Pngle" (PNG Loader for Embedding), so how does it work?
Its aided by some macros & enum for enforcing bounds, logging, & error reporting. There's an enum & a few globals declaring some of PNG's magic numbers, & a struct holding the parsed data & some buffers.
There's some deserialization utilities, & further clamping utils. There's a reset routine freeing any buffers & resetting properties.
1/?
The initializer & finalizer wraps that reset routine with additional memory-management. There's various getters.
There's a check over parsed palettes, a routine to write into the ringbuffer, a routine to read applying different formulas for different bitdepths, a routine which branches over a `color_type` bitmask to determine lookup the final colour, & a wrapper around these routines plus a provided callback.
There's routine implementing PNG's "paeth" grabbing a minimum-adjacent difference.
2/