user7343482
user7343482

Reputation:

How zlib headers are stored in multiple IDAT chunks in png

I am learning how png works and trying to create a simple PNG decoder with "pure" C++.

My problem is that I don't know how zlib headers are stored in multiple IDAT-PNG chunks. The first IDAT chunk looks fine - a normal "CM" and "CINFO", but when I read the next IDAT chunk the zlib header looks strange, the "CM" can be a random number - not 8 as default and the "CINFO" can be above 7 - I readed that "CINFO" with a number above 7 is marked as corrupted/not acceptable. So where can I find some information about this? -I didn't find anything about handling multiple IDAT chunks on the web. (Uh, I find something here - in "StackOverFlow", but it doesn't seem to describe how zlib headers are stored in multiple IDAT chunks so it doesn't answer my question)

I read the RFC 1950 about zlib. https://www.rfc-editor.org/rfc/rfc1950

Upvotes: 0

Views: 529

Answers (1)

Mark Adler
Mark Adler

Reputation: 112339

There is only one zlib header, in the first chunk. The series of IDAT chunks is a single zlib stream, broken up into pieces.

You need to read the PNG spec more carefully.

Upvotes: 5

Related Questions