Introduction
PCX is the format of PC Paintbrush, a paint program from ZSoft first released in 1985. It became one of the most common image formats on MS-DOS, used by scanners, fax software and many games, and grew through several versions from monochrome and 16-colour EGA images to 256-colour VGA and 24-bit colour.
Its compression is a simple run-length encoding, so it suits flat-coloured artwork far better than photographs.
Structure
A PCX file starts with a 128-byte header. Its first byte is always 0A,
followed by the version, the encoding (1 for run-length encoding) and the bits per pixel
in each plane. The image bounds come next as four little-endian numbers, so the width is
xmax − xmin + 1. A 16-colour palette sits inside the header, and later fields
give the number of colour planes and the bytes per line of each plane.
The image data follows as run-length encoded lines. A byte with its top two bits set
(C0 or above) is a count in its low six bits, and the next byte is repeated
that many times; any other byte is a single pixel value. A 256-colour image ends with the
byte 0C and a 768-byte palette of 256 RGB colours.
0Header marker, version, bounds, resolution, 16-colour palette, planes128 bytes128Image data run-length encoded lines, one plane after anothervaries…256-colour palette0Cand 768 bytes, version 5 only769 bytes
Links
Software
Developers
- Pillow, Python imaging library that reads and writes PCX