Format:PCX
| Magic | 0A (manufacturer) at offset 0 |
|---|---|
| Extensions | .pcx |
| Endianness | little |
| On this wiki | Facts · Code · Notes · Topics |
ZSoft PCX image: a 128-byte header, RLE-compressed scan lines and, for 256-colour images, a 769-byte palette trailer (0x0C followed by 256 RGB triples) at the end of the file.
Header
The header is 128 bytes: manufacturer (0x0A), version, encoding (1 = RLE), bits per pixel, Xmin/Ymin/Xmax/Ymax (u16), horizontal and vertical DPI (u16), a 48-byte 16-colour map, a reserved byte, number of planes, bytes per line (u16), palette info (u16), screen sizes (u16 x2) and 54 filler bytes. This is the field list of the PCXHeader struct in DevilutionX (Source/utils/pcx.hpp).
Palette trailer
256-colour PCX files store the palette at the end of the file: one byte 0x0C followed by 256 R,G,B triples (1 + 768 bytes). DevilutionX's PCX loader checks the byte at fileSize-769 for 0x0C and fails with "PCX has no palette" otherwise (Source/utils/pcx_to_clx.cpp).
Where it appears
- Diablo and Hellfire user-interface art and palettes (Format:Diablo CEL and CL2 sprites).
Code & repositories
- https://github.com/diasurgical/devilutionX @
a927236209828a1f1dcb7ef32bdd03a288710c29· license: LicenseRef-Sustainable-Use-1.0 (declared by the contributor; GitHub's detector did not recognize LICENSE.md)
Portable Diablo/Hellfire port; CEL/CL2/PCX to CLX converters
Tested on: source read, not run: Diablo data files (not run) · checked 2026-10-18
Pitfalls
- The RLE encoding is the usual PCX one, corrected on the threshold: devilutionX Source/utils/pcx_to_clx.cpp (a927236209, lines 145-160) treats a byte <= 0xBF as a single pixel and any byte >= 0xC0 as a run whose length is byte & 0x3F (1-63), followed by the pixel value; runs may not cross a scanline. The writer (Source/engine/load_pcx.cpp, lines 108-126) also emits a run of length 1 for a single pixel above 0xBF.