After the header come the layers, as many as the layer count says, one after another. Each is its width and height, then all of its cells. Offsets on this page are in the decompressed data, and numbers are 32 bits, little-endian.
Layer size
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | width | The width in cells. |
| 4 | 4 | u32 | height | The height in cells. |
| 8 | width × height × 10 | cells | cells | Every cell of the layer, column by column. |
The width and height are stored with every layer, but REXPaint gives all the layers of an image the same size, so they are always the same as the first layer’s. The manual says they are repeated only because of the way REXPaint writes its data. A layer takes 8 + width × height × 10 bytes, so layer n starts where layer n − 1 ends; the first starts at 8, or at 4 in a file from before R9.
Cells
Each cell is 10 bytes: the glyph, then two colours. The colours are a byte each for red, green and blue, 0 to 255.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | code | The glyph’s number in the font: its code page 437 number in REXPaint’s default font. The manual calls it the ASCII code and notes it is little-endian. |
| 4 | 1 | u8 | foreground red | The glyph’s colour. |
| 5 | 1 | u8 | foreground green | |
| 6 | 1 | u8 | foreground blue | |
| 7 | 1 | u8 | background red | The colour behind the glyph. 255, 0, 255 makes the cell transparent. |
| 8 | 1 | u8 | background green | |
| 9 | 1 | u8 | background blue |
0Code for example41 00 00 00, glyph 65, “A”4 bytes4Foreground for exampleFF FF FF, white3 bytes7Background for example00 00 80, dark blue3 bytes
Column order
The cells are stored column by column: the first column from top to bottom, then the second, and so on to the right. The manual calls this column-major order. Cell number i in a layer is at
- x = i ÷ height, rounded down
- y = i mod height
and the cell at x, y is number x × height + y, 10 × that many bytes after the layer’s cells start. Code that works row by row, as most image code does, has to turn the grid round.
For example, the cells of a layer 3 wide and 2 high, starting at offset 8 as the first layer of a current file does:
8Width03 00 00 004 bytes12Height02 00 00 004 bytes16Cell 0, 0 top left10 bytes26Cell 0, 1 bottom left10 bytes36Cell 1, 0 top middle10 bytes46Cell 1, 1 bottom middle10 bytes56Cell 2, 0 top right10 bytes66Cell 2, 1 bottom right10 bytes
Transparency
A cell whose background colour is exactly 255, 0, 255 (a bright magenta) is transparent: it is not drawn, and whatever is below it shows through. This holds on every layer, the base layer too. Only the background marks it: 255, 0, 255 is an ordinary colour for a glyph, but it can never be a background in a REXPaint image.
Cells that have not been drawn on are transparent, and REXPaint fills every new layer with transparent cells. A transparent cell still has a code and a foreground colour, which are not drawn. Drawing the layers says how to put an image together.