Papyrix includes a support library for converting JPEGs to bitmaps it can send to the Xteink's epaper display. This wraps a PicoJPEG library I think I'll study tomorrow.
Its aided by some serialization helpers (why don't they use their Serialization support lib?), routines to output a BMP header for different bitwidths with grayscale palettes, a pass to check for unsupported encodings, & a callback to carefully read more input via a couple buffers.
1/2?
The core logic here logs what its doing, validates the JPEG, invokes PicoJPEG, logs results, validates dimensions, computes scaling parameters, outputs the appropriate BMP header, carefully allocates & validates row buffers while verifying availability of RAM, inits appropriate ditherer, possibly allocates some more buffers for scaling, iterates over Y axis, & cleans up.
There's a handful of wrappers around this core logic.
As for that loop over the Y axis...
2/3?