NVGIFv6 specification
Structure
[3 bytes] Magic "NVG"
[1 byte] Version (0x06)
[1 byte] Compression bitfield
|--- 00000GZR
--- G = RGB565 encoding (applied first)
--- R = Run length encoding (applied second)
--- Z = Zlib compression (applied last)
--- 0 = Unused
[1 byte] Alpha flag (cannot be used with RGB565 encoding)
[2 bytes] Width (big-endian)
[2 bytes] Height (big-endian)
[4 bytes] CRC32 of payload (big-endian)
[N bytes] Payload (compressed pixel data)
Payload encoding
The payload is arranged in rows. Each row starts with a 2-byte row header which contains the length of the row as a 16-bit big-endian integer. Each pixel of the row is stored as three bytes:
RRRRRRRR GGGGGGGG BBBBBBBB
If alpha is enabled, there is an alpha byte too:
RRRRRRRR GGGGGGGG BBBBBBBB AAAAAAAA
If RGB565 encoding is enabled instead, each pixel is stored as two bytes:
RRRRRGGG GGGBBBBB
Then for RLE, if RLE is enabled, the entire payload is compressed with RLE. The result is stored in pairs:
TTTTTTTT BBBBBBBB
--- T = number of times the byte is repeated
--- B = the byte in question
If Zlib is enabled, the whole payload is then compressed with Zlib level 9.