File types · Explainer

The PCX file (.pcx)

A PCX file is a PC Paintbrush image: one of the first widely used image formats on IBM PCs, from ZSoft in the mid-1980s, with a 128-byte header, simple run-length compression and a palette of up to 256 colours. This guide explains what's inside one, its versions and palette quirks, and how to open and convert PCX files today.

At a glance

Full name
ZSoft PC Paintbrush image (PCX)
Extensions
.pcx; .dcx for multi-page files that bundle several PCX images
MIME type
image/vnd.zbrush.pcx, registered with IANA in 2015; image/x-pcx is the older, deprecated name
Kind
Binary raster image, run-length encoded (lossless); palette or 24-bit colour
Standard or owner
ZSoft Corporation, now defunct; described in ZSoft's PCX technical reference
First released
Mid-1980s, with ZSoft's PC Paintbrush for MS-DOS; IANA's registration dates the format to 1985 and its last update to 1991
Colours
2, 4, 16 or 256 from a palette, or about 16.7 million in 24-bit files (version 5)
Magic number
0A (10), followed by the version (usually 05) and 01 for run-length encoding
Opens with
GIMP, IrfanView, XnView, Photoshop, PaintShop Pro, ImageMagick, FFmpeg; browsers can't display it

The basics

What is a PCX file?

PCX is the native format of PC Paintbrush, a paint program for MS-DOS from ZSoft Corporation, first released in 1984. Microsoft published PC Paintbrush with its mouse drivers in 1985 and licensed versions of it for Windows: the original Windows Paint and, in Windows 3.0, Paintbrush. That spread PCX across early PCs, and it became one of the first widely accepted image formats on DOS.

Through the late 1980s and the 1990s, PCX was used for screenshots, clip art, scanned images, fax software and the graphics of DOS games. ZSoft extended it from the 2-, 4- and 16-colour displays of the time to 256-colour VGA and finally 24-bit colour, and the company itself was merged and sold several times from 1989 onwards.

Today PCX is a legacy format. You find it in old software, game files and archives, and some document and fax systems still use the multi-page DCX variant. Image editors and converters still read it, but browsers don't, and for new images PNG does everything PCX did, with better compression.

Anatomy

What's inside a PCX file

A PCX file is a 128-byte header, the run-length encoded pixels, and for 256-colour images a palette at the very end. All numbers are little-endian. Below is the structure of a 904-byte file we made for this page with Pillow and checked with ImageMagick and FFmpeg: 4 × 2 pixels, red, red, red, green on top and blue, blue, white, white below. It isn't offered for download.

tiny.pcx (hex, 904 bytes)
tiny.pcx: 4 × 2 pixels, 8-bit palette, 904 bytes

offset  bytes                       part
000000  0A                          manufacturer: 10 = ZSoft
000001  05                          version 5: PC Paintbrush 3.0 and later
000002  01                          encoding 1: run-length
000003  08                          8 bits per pixel per plane
000004  00 00 00 00 03 00 01 00     window: x 0 to 3, y 0 to 1 → 4 × 2
00000C  64 00 64 00                 resolution: 100 × 100 dpi
000010  00 … FF (48 bytes)          16-colour palette: unused here
000040  00                          reserved
000041  01                          1 colour plane
000042  04 00                       4 bytes per line, per plane
000044  01 00                       palette info: 1 = colour
000046  04 00 02 00                 screen size: 4 × 2
00004A  00 … (54 bytes)             filler, to 128 bytes

000080  C3 02                       row 1: 3 × colour 2
000082  01                          then colour 1, as a single byte
000083  C2 03                       row 2: 2 × colour 3
000085  C2 00                       then 2 × colour 0

000087  0C                          12: a 256-colour palette follows
000088  FF FF FF                    colour 0: white
00008B  00 FF 00                    colour 1: green
00008E  FF 00 00                    colour 2: red
000091  00 00 FF                    colour 3: blue
000094  00 00 00 …                  colours 4 to 255: unused
                                    end of file: 136 + 768 = 904 bytes
  1. 10A

    Manufacturer

    Always 10, for ZSoft. It's the only fixed byte, so on its own it's a weak signature: check the version and encoding bytes too.

  2. 205

    Version

    Which PC Paintbrush version the file is compatible with, and so what kind of palette to expect. 5 is by far the most common and the only one with a 256-colour palette or 24-bit colour.

  3. 301 08

    Encoding and bit depth

    Encoding 1 means PCX run-length encoding, the only one defined. Then the bits per pixel in each plane: 1, 2, 4 or 8.

  4. 400 00 00 00 03 00 01 00

    The window

    The image's left, top, right and bottom edges. Both ends are inclusive, so the size is right − left + 1 by bottom − top + 1: 4 × 2. Forgetting the + 1 is a classic off-by-one bug.

  5. 500 … FF (48 bytes)

    The 16-colour palette

    16 RGB triples, used by images with up to 16 colours. A 256-colour image ignores it, so writers fill it with anything; Pillow writes zeros and FF bytes.

  6. 601 04 00

    Planes and bytes per line

    1 plane of 8-bit pixels; each row takes 4 bytes per plane once decoded. The specification says this number is always even, so rows can carry a padding byte that isn't part of the picture.

  7. 7C3 02

    A run

    A byte with its top two bits set (C0 or above) is a count: C3 means 3, and the next byte, 02, is repeated 3 times. Palette colour 2 is red.

  8. 801

    A literal byte

    Any byte below C0 stands for itself, once: colour 1, green. A pixel value of C0 or above can't be written this way; it needs a count of 1 first (C1 C5).

  9. 90C

    The palette marker

    Byte 12, exactly 769 bytes before the end of the file, announces a 256-colour palette. Readers find it by counting back from the end, not by decoding up to it.

  10. 10FF FF FF 00 FF 00 …

    The 256-colour palette

    768 bytes: 256 colours of red, green and blue, one byte each. Here colours 0 to 3 are white, green, red and blue, and the rest are unused.

Under the hood

The PCX header and versions

Every PCX file starts with a 128-byte header:

OffsetSizeField
01Manufacturer: always 10
11Version (see below)
21Encoding: 1 = run-length
31Bits per pixel, per plane
48Window: Xmin, Ymin, Xmax, Ymax
124Horizontal and vertical resolution
164816-colour palette
641Reserved, 0
651Number of colour planes
662Bytes per line, per plane (even)
682Palette info: 1 = colour or black and white, 2 = greyscale
704Screen size (PC Paintbrush IV and later)
7454Filler to 128 bytes
The version byte, from ZSoft's documentation
ValueMeaning
0PC Paintbrush 2.5
2PC Paintbrush 2.8, with palette information
3PC Paintbrush 2.8, without palette information: use a default palette
4PC Paintbrush for Windows
5PC Paintbrush 3.0 and later, PC Paintbrush Plus and Publisher's Paintbrush; needed for 256 colours and 24-bit

The bit depth and the number of planes together give the colour mode. Planes split each row into separate parts, one per colour component, a layout inherited from the way EGA and VGA graphics cards stored their memory:

Bits per pixelPlanesColoursPalette
112 (monochrome)None, or header
214 (CGA)Header
1416 (EGA)Header
81256 (VGA)At the end of the file
83About 16.7 million (24-bit)None: rows are stored as red, then green, then blue

Compression

How PCX run-length encoding works

PCX compresses each row with a byte-oriented run-length scheme:

  1. 1Read a byte. If its top two bits are set (C0 to FF), the low six bits are a count from 1 to 63, and the next byte is repeated that many times.
  2. 2Otherwise the byte is a single data byte.
  3. 3Repeat until the row is complete: number of planes × bytes per line.
pcx-rle.js
// decode one PCX row (all planes) from data, starting at pos
function decodeRow(data, pos, rowBytes) {
  const out = [];
  while (out.length < rowBytes) {
    let count = 1;
    let value = data[pos++];
    if ((value & 0xc0) === 0xc0) {
      count = value & 0x3f;
      value = data[pos++];
    }
    for (let i = 0; i < count; i++) out.push(value);
  }
  return { row: out, pos };
}

Two consequences are worth knowing. First, a single byte of C0 or more costs two bytes (C1 and the value), so images with many bright palette indices or lots of noise compress badly, and a photo can end up larger than uncompressed. Second, the encoding is the same for every kind of PCX, which made it fast on 1980s computers but leaves it far behind GIF's LZW or PNG's Deflate on anything but flat colour.

Colour

PCX palettes: in the header and at the end

PCX has two places for a palette, because it grew with the graphics cards of its time:

  • The 16-colour palette sits in the header at offset 16: 16 colours of 3 bytes. Images with 16 colours or fewer use it.
  • The 256-colour palette was added for VGA. There was no room in the header, so ZSoft appended it to the end of the file: a byte with the value 12 (0C), then 768 bytes of red, green and blue. To find it, check that the version is 5, go to 769 bytes before the end of the file, and check for the 12.

The palette stores 8 bits per component, from 0 to 255. VGA hardware took values from 0 to 63, so old DOS programs divided each value by 4 before loading it into the card. A reader that skips this conversion is fine; a writer that stores the 0 to 63 values directly produces an image that looks very dark in modern software.

24-bit PCX

24-bit files (version 5, 8 bits per pixel, 3 planes) have no palette. Each row holds all the red values, then all the green, then all the blue. Some old readers don't support them, so 8-bit PCX is the safer choice for old software.

Comparison

PCX vs BMP, GIF and PNG

PCXBMPGIFPNG
FromZSoft, mid-1980sMicrosoft and IBM, late 1980sCompuServe, 1987PNG Development Group, 1996
CompressionRun-lengthUsually none; RLE for palette imagesLZWDeflate
ColoursUp to 256, or 24-bitUp to 256, or 16, 24 and 32-bitUp to 256 per frameUp to 16 bits per channel, plus alpha
TransparencyNoPatchyOne colourFull alpha
BrowsersNoAllAllAll

Converting a PCX to PNG loses nothing: every pixel and palette entry carries over, and the file almost always gets smaller. That's the usual way to preserve PCX images for modern use.

Troubleshooting

Common PCX problems

  • Wrong or psychedelic colours. The reader missed the 256-colour palette (no 0C 769 bytes from the end, or a version other than 5), or the file uses the default 16-colour palette of version 3. Try another reader; IrfanView and ImageMagick handle most variants.
  • Nearly black image. The palette holds VGA values from 0 to 63 instead of 0 to 255. Multiply the palette by 4 (or adjust levels) to recover it.
  • An extra column or a shifted image. Bytes per line is even, so odd-width images carry a padding byte per row, and some readers draw it. Or the reader forgot the + 1 when computing the size from the window.
  • The image is skewed or streaky. A decoder that stops runs at the end of each plane, or doesn't, when the file was written the other way. ZSoft's documentation says decoding breaks happen at the end of each row, not each plane.
  • It opens as just one page. It may be a DCX file with several PCX pages inside. Use a viewer that supports DCX, or ImageMagick, which reads every page.
  • It won't open at all. Make sure it really is a PCX: the first byte should be 0A, the third 01.

How to

How to open and convert a PCX file

  • Open it: GIMP (Windows, macOS, Linux), IrfanView, XnView, Photoshop and PaintShop Pro; GraphicConverter on a Mac.
  • Convert to PNG: export from any of these, or run magick image.pcx image.png with ImageMagick or ffmpeg -i image.pcx image.png with FFmpeg.
  • Make a PCX for old software: magick input.png -colors 256 output.pcx gives an 8-bit palette image, which old programs read more reliably than 24-bit PCX.
  • Inspect it: identify -verbose image.pcx (ImageMagick) shows the size, depth and palette; the header is short enough to read in any hex editor.

PCX files hold only pixels, a palette and a resolution, with no other metadata, scripts or links. As with any old format, decoders that trust the header's sizes have had bugs; keep your software updated and check dimensions before processing uploaded files.

Sample files

There are no sample PCX files on this page yet. To make one for testing, run magick input.png output.pcx with ImageMagick, or export from GIMP.

Put it online

Have a PCX file? Give it a link.

Drop a PCX image on 99helpers and it gets its own web address. Browsers can't display PCX, so anyone who opens the link downloads the file to view it in an image editor or converter; add a PNG copy for people who just want to see it.

Questions

PCX files, frequently asked

What is a PCX file?

An image in ZSoft's PC Paintbrush format, from the mid-1980s: a 128-byte header, run-length compressed pixels and up to 256 palette colours, or 24-bit colour in later versions. It was common on DOS and early Windows.

How do I open a PCX file?

Use IrfanView, XnView, GIMP, Photoshop or PaintShop Pro, or convert it with ImageMagick or FFmpeg. Browsers can't display PCX.

How do I convert PCX to PNG or JPG?

Open it in GIMP or IrfanView and export, or run magick image.pcx image.png. PNG keeps every pixel and is usually smaller; JPG is lossy and not a good fit for flat-colour images.

Is PCX lossless?

Yes. Its run-length encoding stores every pixel exactly. Converting from PCX to PNG also loses nothing.

Does PCX support transparency?

No. There is no alpha channel or transparent colour in the format. Programs that needed transparency, such as DOS games, usually treated one palette colour as transparent themselves.

What is a DCX file?

A multi-page variant: a small header listing the offsets of several PCX images stored one after another. It was used by fax and document software.

Why are the colours of my PCX wrong?

The reader missed the 256-colour palette at the end of the file, or the palette was stored in VGA's 0 to 63 range. Try a different program, such as IrfanView or ImageMagick.

Related formats

Other file types explained

Keep going

Related

Sources

Last reviewed 27 October 2026.