randy408 / libspng

Simple, modern libpng alternative
https://libspng.org
BSD 2-Clause "Simplified" License
741 stars 75 forks source link

Example for spng_set_png_stream() #258

Open JanGerber opened 1 year ago

JanGerber commented 1 year ago

Is there an example how to use the spng_set_png_stream() function?

randy408 commented 1 year ago

One example is the spng_set_png_file() function which is essentially spng_set_png_stream(ctx, file_read_fn, file) where file_read_fn looks like this: https://github.com/randy408/libspng/blob/e5c1fc470fceaca08b8c30dc40768c28b82b9e12/spng/spng.c#L5024-L5036

For writing file_write_fn is used, it's right after file_read_fn in the same file.

There is documentation on the read and write callbacks: https://libspng.org/docs/context/#spng_read_fn, https://libspng.org/docs/context/#spng_write_fn