Update on the PNG file: I’m reading and studying, and getting an education. Apparently the presence of two data blocks is normal with PNG files because limits are imposed on the size of each, whether those limits are traditional or hardware-imposed. Pixels in Q’s file are stored as 16-byte values, which is way overkill for what the human eye can detect, but that’s what was used. The first IDAT (image data) block in this file has a size of 0x80000 which is 32,768 sets of 16 bytes – a very clean, nice, even round number if you’re looking at binary values. 32767 is the max signed (specifies + or -) number you can have with 16-bit values. (Since 0 is included, 0 – 32767 is 32,768 distinct values). The second block is a continuation of the first.
But the problem remains: remove the second block and the image still displays normally.
Since PNG files use a technique called “filtering,” in addition to compression, it’s impossible to tell how many pixels are actually represented without decompressing the data. And here is where I’m hitting the same old merry-go-round that I always hit: bad documentation. There just isn’t any escaping it. It has cost me more time over the years than any other factor – exponentially.
According to documentation, there should be 4 bytes that say the size of the block. That part is good. The next four say IDAT to identify the block type. No problem. Then the data block begins. This is where EVERY SOURCE I can find assumes we’re all psychic and they just gloss over it …. okay then it’s the compressed data. See RFC1950 for that. So I look at RFC 1950 and nothing, nothing, nothing matches up.
Standard fare. Bad, bad, bad documentation.
So this is what I’m fighting. I have downloaded source code for 3 decoders in C++ and none of them compile. Errors galore. I hate high level languages … did I mention that? Say one thing, they do another. Out of control.
So … I’m working on it. I just have to claw my way through this incompetence in documentation and keep on searching until somebody decides to correctly document whatever truly follows IDAT because it is not an RFC1950 compatible compression stream.