First a bit of context. I need to flip a PNG image. I get the info per byte (in order) and I have to flip it as a stream. I manage to divide and parse the chunks. But when I have the IDAT chunk data I don't know what to do with it to flip it.
INFO from the IHDR: Bit depth = 08 (8 bits per sample) and colour type = 06. The image is 800 x 600 = 480000
The IDAT size is 179502 so that is 0.374 of the total of pixel size (weird).
If I flip the pixels (all the IDAT data as it is) I get an image that when I open it just displays a transparent image. I also tried using 4 bytes = 1 pixel as I have RGB + alpha but still no good result. (Always a transparent image... that is also very wierd... I was hoping random images, not transparent images).
I have read that the info is compressed, so my plan is to decompress it, flip the RGB array and then compress again, but... how can I decompress and compress it again? I can't find the info/algorithm to do that.
I also find the 0x78 hex almost always after the IDAT part, so I have deduced that the compress pixel array does not start directly after the IDAT but some bytes after... If so... How is it organized? is it only pixel array directy or does it have some info before and/or after in the IDAT chunk data?