| R | R | R | R | R | G | G | G | G | G | G | B | B | B | B | B |
###Gray-scale
Each pixel is encoded using a 4-bit value. Each byte contains color of two pixels, so it looks like this:
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|
| Po | Po | Po | Po | Pe | Pe | Pe | Pe |
Where Po is odd pixel and Pe is even pixel.
##Compression
Pixel data is compressed using DEFLATE algorithm with 10-bit sliding window and no header. This can be achieved with ZLIB library by using the following:
``` python
import zlib
z = zlib.compressobj(level=9, wbits=10)
zdata = z.compress(pixeldata) + z.flush()
zdata = zdata[2:-4] # strip header and checksum
```
##Tools
* [png2toi](../tools/png2toi) - tool for converting PNG into TOI format