PNG IDAT块数据计算
我正在尝试学习,建议用C语言编写自己的PNG文件。 我已经阅读了PNG文件格式规范,现在可以编写基本的PNG(签名,IHDR块,1PX-IDAT块和Iend Chunk)。 但是现在,我想在PNG中写下一系列像素,所有块都在okk,但我不明白如何生成IDAT数据块。 在libpng文档中,他们向deflate()扫描线解释,之前为fileer byte方法。
我对这个问题的理解:
扫描线是水平像素的数组,然后是滤波器方法(0),然后是大小:(3*ScreenWidth + 1) 对于每行(ScreenHeight值),我用Zlib压缩()扫描线,然后将其存储在文件中。
但是在生成PNG之后,它始终是黑色的,在十六进制编辑器中的值始终为0。
我在做什么错?还是生成IDAT数据值的好方法?
I'm trying for learning propose to write my own png file in c language.
I have already read the PNG file format specification and i am now able to write a basic PNG(signature, IHDR CHUNK, 1px-IDAT CHUNK AND IEND CHUNK).
But now i want to write a array of pixels into the PNG, all chunks are going okk but I don't understand how to generate the IDAT data CHUNK.
In libPNG documentation they explain to deflate() the scanline, preced by the filer byte method.
My understanding of this problem:
A scanline is an array of horizontal pixels preceded by the filter method(0) then of size: (3*screenWidth + 1)
for each line (screenHeight value), I compress() the scanline with zlib and store it in a file.
But After generating the png, it is always black and the value is always 0 in hex editor.
what am i doing wrong? or is the the good way to generate IDAT data values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有在问题中提出任何代码,因此我们无法知道您实际在做什么。 “我用zlib压缩()扫描线,然后将其存储在文件中。”听起来错误。您需要按照所述组装所有扫描线,然后一次用Zlib压缩整个内容。
You did not put any code in your question, so we have no way of knowing what you're actually doing. "I compress() the scanline with zlib and store it in a file." sounds wrong. You need to assemble all of the scan lines as described, and then compress the entire thing with zlib, once.