libspng
libspng copied to clipboard
Streaming API improvements
The streaming API is similar to libpng's which is great when it comes porting code but it has some drawbacks, this issue is for listing potential improvements.
The current streaming API expects the read callback to copy data to a library-controlled buffer, this introduces unnecessary copying if the user is also storing the PNG in memory.
Add a new function spng_set_png_stream2() that takes a different type of callback:
typedef int spng_read_fn2(spng_ctx *ctx, void *user, void **dest, size_t length);
This callback function assigns the pointer dest to the requested amount of bytes.
It also might be nice to allow a push-style or asynchronous decoding interface. For example, in netsurf's png handler, it receives image data in chunks, and pushes it into libpng with png_process_data:
http://git.netsurf-browser.org/netsurf.git/tree/content/handlers/image/png.c#n315
I'm don't believe there is a way to do this with the current libspng API.
I created a new issue for that: https://github.com/randy408/libspng/issues/39