PNG的大小的libpng [英] libpng size of png

查看:154
本文介绍了PNG的大小的libpng的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序从不定长的数据流中读取。当它读取PNG文件就需要把它存储供以后,而不是去code吧。是否为libpng的,所以它知道有多少个字节来存储提供PNG的大小提供任何功能?

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 providing the size of the PNG so it knows how many bytes to store?

如果不是这样,我必须写我自己的PNG块分析器通过块跳过,直至结束块?我想,我也可以包括CRC校验,但它似乎很复杂,这就是为什么我希望会了libpng提供一种方式来透明地做到这一点。

If it does not, do I have to write my own PNG chunk parser to skip through the chunks until the ending chunk? I figured that I might as well include CRC verification, but it seems very complicated, which is why I was hoping libpng would provide a way to do this transparently.

推荐答案

简短的回答是否定的。 libpng的甚至不返回各个块的长度,所以如果你使用了libpng你确实有通过所有的块跳过找到PNG数据流的结束。

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.

的的libpng不返回块长度的原因是的libpng设计用于流式传输,所以它不一定知道你的不定长度的数据流多长时间将是。它只知道它的头它已经阅读块的长度。

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.

您可以使用pngcheck读取PNG文件并生成与它们的长度块的列表。请参见 http://www.libpng.org/pub/png/apps/pngcheck。 HTML Pngcheck是开源的,所以你可以使其适应自己的需要。

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.

这篇关于PNG的大小的libpng的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆