I'm going over the W3 PNG specification (creating a PNG library from scratch) and I've finally found how to create a green 1x1 image.
Now I'm trying to create a bigger image of mixed Red, Green and Blue pixels. Let's say a 4x4 image. Sadly I'm getting all the pixels mixed and some of them are Black or Pink.
Details:
- Signature: OK
- IHDR: OK
- Width: 4
- Heigh: 4
- Bit depth: 8
- Color: 2
- Filter: 0
- Compression: 0
- Interlace: 0
- IDATA: 4 chunks*
- IEND: OK
*IDATA chunks:
- 4 bytes length: Number of bytes of the DATA after Zlib deflate
- 4*1 byte type: IDAT
- X bytes data: 4*4bytes unsigned integers, Zlib deflated, one after the other, Network byte order
- 255 for blue**
- 65280 for green**
- 16711680 for red**
- 4 bytes crc: OK
**Bitwise results of:
alpha<<24 | red<<16 | green<<8 | blue
With alpha, blue, green and red taking values from 0 to 255
What's wrong with this?