libpng size of png

前端 未结 3 569
夕颜
夕颜 2021-01-15 14:06

My program reads from a data stream of indeterminate length. When it reads a PNG file it needs to store it for later and not decode it. Does libpng provide any function for

3条回答
  •  失恋的感觉
    2021-01-15 14:45

    The short answer is NO. Libpng doesn't even return the length of the individual chunks, so if you are using libpng you do indeed have to skip through all the chunks to find the end of the PNG datastream.

    The reason libpng doesn't return chunk lengths is that libpng is designed for streaming, so it does not necessarily know how long your datastream of indeterminate length is going to be. All it knows is the length of the chunk whose header it has already read.

    You can use "pngcheck" to read a PNG file and produce a list of chunks with their lengths. See http://www.libpng.org/pub/png/apps/pngcheck.html‎ Pngcheck is open source, so you can adapt it to your own needs.

提交回复
热议问题