Understand libspng chunk semantics and error handling
masterChunk data is stored within the spng_ctx.
Error Codes
All spng_get_*() functions return:
0on success.- A non-zero error code on failure.
SPNG_ECHUNKAVAILif the PNG does not contain the requested chunk or it was not previously set.
Behavior for Decoder Contexts
- Reading Chunks: When calling
spng_get_*()orspng_set_*(), all chunks up to the firstIDATare read and validated (exceptspng_get_ihdr(), which only reads the header). After the image is decoded, all chunks up to theIENDmarker are read. - Setting Chunks: A successful
spng_set_*()call replaces any previously set value or list. It does not combine data from the file or multiple calls. - Precedence: Data set via
spng_set_*()is never replaced by input file chunk data; once you set a value, it persists.