PCX

From Just Solve the File Format Problem
Revision as of 15:37, 11 October 2021 by Thorsted (Talk | contribs)

Jump to: navigation, search
File Format
Name PCX
Ontology
Extension(s) .pcx, .pcc
MIME Type(s) image/vnd.zbrush.pcx, image/x-pcx
PRONOM fmt/86, fmt/87, fmt/88, fmt/89, fmt/90
Kaitai Struct Spec pcx.ksy
Released ~1984

PCX was the native image format of a DOS-based program PC Paintbrush from ZSoft Corporation, and was for a time (especially the late 1980s) a very popular image format among users of IBM PC compatibles and the PC/MS-DOS operating system. Much clip art was distributed in this format. However, it was tied closely to platform-specific attributes such as the particular graphic modes available in early PCs, and later lost ground to more platform-independent graphic formats like GIF, JPEG, and PNG.

PC Paintbrush was licensed to Microsoft, and it evolved into the Paint/Paintbrush application included with Windows. The versions for Windows 3.0 through Windows 95 support PCX format. There was also a product named Microsoft Paintbrush 2.0.

Contents

Identification

The first byte of a PCX file is 0x0a. The second byte (the version number) is 0, 2, 3, 4, or 5. The third byte (the encoding) is 1 or (rarely) 0.

Format details

A PCX file consists of a 128-byte fixed header (48 bytes of which may be used for a palette), followed by the pixel data, followed in some cases by a 769-byte palette segment.

A number of different PCX specifications can be found on the internet, but unfortunately, they tend to be incomplete, and ambiguous about certain details. Part of this may be the fault of the PCX format. PC Paintbrush itself reportedly may interpret the same file differently, depending on the version of the software, and the graphics mode being used.

The variety of a given PCX file is determined primarily by the combination of the bits per pixel per plane field at offset 3, and the number of planes field at offset 65. The following varieties of PCX seem to be common and well-supported:

  • bits=1, planes=1: Bi-level, black and white (other colors may be possible, but are not well-supported)
  • bits=1, planes=4, version≠3: 16-color, using the palette contained in the header
  • bits=8, planes=1: 256-color, using the palette at the end of the file
  • bits=8, planes=3: 24-bit truecolor

Unfortunately, there are many other varieties that are not necessarily so portable.

Compression

The PCX specifications require that all PCX image data be compressed with a form of run-length encoding, indicated by the encoding field having the value 1. However, modern graphics software often supports uncompressed PCX, in which the encoding field is 0. You can use ImageMagick to create such files, if you explicitly disable compression.

Transparency

We haven't located any PCX specification that mentions transparency, yet some modern graphics software supports 32-bit RGBA format (bits=8, planes=4). ImageMagick will readily create such files.

The Wikipedia article also suggests a 16-bit RGBA format (bits=4, planes=4).

Resolution

The PCX header has X- and Y-"resolution" fields, which you might think would help to display PCX images at the correct aspect ratio. Unfortunately, these fields are all but useless. If not set to zero, they might contain any of the following:

  • The dots per inch
  • The pixel dimensions of the target screen mode
  • The pixel dimensions of the image itself
  • A failed attempt at one of the above things

See also

Specifications

Metaformat files

Software

Sample files

Links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox