Decoding REXPaint Files in Odin: A Gentle Intro to Binary Formats

REXPaint, the ASCII art tool behind Cogmind, stores its .xp files as gzipped binary with a simple layout: a version integer, a layer count, then per-layer dimensions and 10-byte cells in column-major order. Using Odin, the post builds a small cursor-based reader, handles errors with a custom union, and shows how to validate untrusted counts before allocating memory.
The first two bytes, 1f8b, are the magic number, a fixed byte sequence that identifies a file’s format.