libpng load file from memory buffer

大兔子大兔子 提交于 2019-12-07 04:47:21

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/14547765/libpng-load-file-from-memory-buffer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!