The Quite OK Image Format for Fast, Lossless Compression
Created on 2023-06-27T04:02:44-05:00
A simple lossless image format meant to require very little source code to implement support for.
Performance is approximal to an unoptimized PNG (libpng's output) but is about 2-3x faster to load.
Consists of a header and a number of instructions to reconstruct the original image. An interpreter walks over each instruction and decants the raw pixel data from there.
When a pixel is decoded it is hashed and stored in a 64-bucket hash table. These are the colors of recent memory, and can be referenced by opcodes to repeat a color.
RGBA: Sets a full RGBA pixel.
RGB: Sets a raw RGB pixel, retaining the current alpha channel.
Index: Reference one of the 64 colors in recent memory.
Diff: Stores the difference between the previous pixel and this one. Does not encode the alpha channel.
Luma: Stores difference of the previous green channel and this one. Then the (smaller) difference of the green channel to red, and difference of green to blue.
Run: Invoke the previous pixel a given number of times; run length encoding.