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
A .pcx file dropped on any page of this site opens in the explorer, which
shows the picture, every header field and palette, and each run-length packet with the
row and plane it belongs to.
In this reference
- Header – the 128-byte header, field by field
- Image data – run-length packets, rows and planes
- Palettes – the header palette, CGA colours and the 256-colour palette
Links
Software
- GIMP – free image editor that opens and exports PCX (Windows, macOS, Linux)
- IrfanView – image viewer and converter that opens and saves PCX (Windows)
- XnView MP – image viewer and converter that reads and writes PCX (Windows, macOS, Linux)
- ImageMagick – command-line tools that convert PCX to and from other formats (Windows, macOS, Linux)
- GrafX2 – free pixel-art paint program that opens and saves PCX (Windows, macOS, Linux)
- Netpbm – command-line image tools;
pcxtoppmandppmtopcxconvert PCX (Windows, macOS, Linux)
Developers
- Pillow – imaging library that reads and writes PCX (Python)