Introduction
An .xp file is an image from
REXPaint, the free ASCII-art editor
from Grid Sage Games. REXPaint was made for drawing the art and maps of roguelike games,
whose screens are grids of text characters, and many such games read .xp
files directly.
The picture is not stored as pixels. It is a grid of cells, and each cell holds one glyph from a 256-glyph code page 437 font, a foreground colour and a background colour. An image can have up to nine layers, drawn one over another, and a cell on any layer can be transparent.
Structure
The whole file is gzip-compressed: REXPaint writes it through zlib’s gzip stream, so it
starts with the gzip bytes 1F 8B. Decompressed, the data is a version number,
the number of layers, and then each layer: its width and height in cells, and then every
cell, column by column.
0Gzip header1F 8B 08, flags, time, operating system10 bytes or more10Deflate data the decompressed data below, compressedvaries…Gzip trailer CRC-32 and size of the decompressed data8 bytes
Numbers in the decompressed data are 32 bits, little-endian. Colours are three bytes: red, green and blue.
0Version a negative number; REXPaint writes −14 bytes4Layer count 1 to 94 bytes8Layer 1 size width and height in cells8 bytes16Layer 1 cells width × height cells, column by column10 bytes a cell…Layer 2 and the rest size and cells, the same wayvaries
0Code the glyph’s number in the font4 bytes4Foreground red, green, blue3 bytes7Background red, green, blue; 255, 0, 255 is transparent3 bytes
An .xp file dropped on any page of this site opens in the explorer. It
shows the gzip wrapper and its Deflate blocks, draws each layer and all layers together,
gives the text of each layer, and lists the glyphs and colours used. The decompressed data
opens as a file of its own, where every cell of the pictures leads to its 10 bytes. The
explorer draws the glyphs with the IBM PC’s 8 × 8 code page 437 font, so its pictures
differ in detail from REXPaint’s own font.
Versions
Versions of REXPaint before release R9 wrote no version number: their files start straight with the layer count. Later versions store the version as a negative number, so that a reader can tell the two apart by the sign of the first number. The layout after that is the same. The manual does not list other changes, and a reader can ignore the version otherwise.
In this reference
- Compression and header – the gzip wrapper, the version number and the layer count
- Layers and cells – each layer’s size, the 10 bytes of a cell, column order and transparency
- Glyphs and drawing – code page 437, and how the layers are drawn over one another
Links
Software
- REXPaint – Grid Sage Games’ free ASCII-art editor, which makes and opens .xp images (Windows)
Developers
- REXSpeeder – library that loads and saves .xp images (C++)
- rexpaint – crate that reads and writes .xp images (Rust)
Reference
- REXPaint manual – Appendix B describes the .xp format, and Appendix C lists libraries for many languages