Question

I tried looking through the libpng documentation, but didn't find what I was looking for.

I have a PNG file fully in a memory buffer, how can I load this file (apart from the obvious solution of creating a temporary file)?

Not sure if it's relevant, but I'm calling libpng from Python using ctypes.

Was it helpful?

Solution

I found this article which describes pretty well how to read a PNG file from memory.

Summarized, you have to create a custom callback function and give it to libpng using png_set_read_fn. Then in that callback function you read from your memory buffer rather than a file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top