I've gotten pretty far with my PNG programming, with the help of a document I found on wotsit simply called "draft-bo". However, I'm stuck on one part - I'm at IDAT (where data lies), and I'm trying to use zLib to decompress it. I want to make my own PNG decompression library for myself, for use with VB, as VB doesn't have any good freeware implementations that do alpha well (and dont crash).

Anyway, my dilemma is this. This is the structure of an IDAT data chunk:
Code:
Compression method/flags code: 1 byte
Additional flags/check bits:   1 byte
Compressed data blocks:        n bytes
Check value:                   4 bytes
Unfortunately, the zlib call requires you to know the size of the uncompressed data as well.

This would be no problem if there was only one IDAT in the file (uncompressed data would be channels * bytes_per_channel * width * height). However, there can be several, and there are no definate schemes as to how they're split up. Thus my dilemma; what should I pass for the uncompressed value?