Prediction-Encoded Pixels image format

https://news.ycombinator.com/rss Hits: 6
Summary

Prediction-Encoded Pixels This format is specifically designed to be for low-color pixel art (<=16 colors works best, up to 256 colors is supported). It uses "Prediction by Partial Matching, Order-2" compression, which is able to compress packed-palette-indices smaller than GIF, PNG, and QOI, while sacrificing a bit of time. It's 2-10x slower than GIF/PNG/QOI (depending on the image), but often compresses the image 20-50% smaller than GIF/PNG (and multiple-times smaller than QOI). If you care about compressed image size, this is for you. It's somewhere between GIF and WEBP (.webp can compress better at times, but it's painfully slow). ( this is currently in the EXPERIMENTAL phase! ) How to use it: Use the C header like: #define PEP_IMPLEMENTATION #include "PEP.h" tree1 112x96 : 4 colors Format Size (bytes) Compression Ratio Compression (ms) Decompression (ms) PEP 901 0.021x 0.383 0.412 PNG 984 0.023x GIF 1,047 0.024x QOI 2,425 0.056x 0.023 0.028 BMP 43,130 1.00x font 192x144 : 2 colors Format Size (bytes) Compression Ratio Compression (ms) Decompression (ms) PNG 1,318 0.368x PEP 1,357 0.378x 0.419 0.602 GIF 1,919 0.535x BMP 3,586 1.00x QOI 6,669 1.860x 0.071 0.078 640x200 : 251 colors Format Size (bytes) Compression Ratio Compression (ms) Decompression (ms) PEP 73,542 0.407x 25.652 32.121 PNG 84,657 0.469x GIF 96,997 0.751x BMP 129,078 1.00x QOI 180,533 1.399x 1.03 1.004 PEP is designed for games too, so the compression outputs a structure that has useful elements. The PEP.data pointer ONLY contains the bytes for the pixels. This library doesn't have a BMP loader, so this is specifically designed for setups where the color bytes already exist. You just feed it into pep_compress() with the correct in_format of the bytes, and then you're able to use it however you like! Often you just use pep_save() after compressing, and then pep_load() + pep_decompress() to access the image data. /* pep_compress() parameters: uint32_t* PIXEL_BYTES = raw RGBA/BGRA pixels uint16_t WID...

First seen: 2025-08-25 14:14

Last seen: 2025-08-25 19:15