The PCX File Format

The PCX File Format

Original Documentation

The PCX files are created by the programs of the ZSoft Paintbrush family
and the FRIEZE package by the same manufacturer. A PCX file contains only
one image, the data for this image and possibly palette information for
this image. The encoding scheme used for PCX encoding is a simple RLE
mechanism, see ALGRTHMS.txt for further information. A PCX image is stored
from the upper scan line to the lower scan line.

The size of a decoded scan line is always an even number, thus one additional
byte should always be allocated for the decoding buffer.

The header has a fixed size of 128 bytes and looks like this :
OFFSET              Count TYPE   Description
0000h                   1 byte   Manufacturer.
0001h                   1 byte   Version information
								  0=PC Paintbrush v2.5
								  2=PC Paintbrush v2.8 w palette information
								  3=PC Paintbrush v2.8 w/o palette information
								  4=PC Paintbrush/Windows
								  5=PC Paintbrush v3.0+
0002h                   1 byte   Encoding scheme, 1 = RLE, none other known
0003h                   1 byte   Bits per pixel
0004h                   1 word   left margin of image
0006h                   1 word   upper margin of image
0008h                   1 word   right margin of image
000Ah                   1 word   lower margin of image
000Ch                   1 word   Horizontal DPI resolution
000Eh                   1 word   Vertical DPI resolution
0010h                  48 byte   Color palette setting for 16-color images
								 16 RGB triplets
0040h                   1 byte   reserved
0041h                   1 byte   Number of color planes
0042h                   1 word   Number of bytes per scanline (always even,
								 use instead of right margin-left margin).
0044h                   1 word   Palette information
								  1=color/bw palette
								  2=grayscale image
0046h                   1 word   Horizontal screen size
0048h                   1 word   Vertical screen size
004Ah                  54 byte   reserved, set to 0

The space needed to decode a single scan line is "NCP"*"NBS" bytes, the last
byte may be a junk byte which is not displayed.

After the image data, if the version number is 5 (or greater?) there possibly
is a VGA color palette. The color ranges from 0 to 255, 0 is zero intensity,
255 is full intensity. The palette has the following format :

OFFSET              Count TYPE   Description
0000h                   1 byte   VGA palette ID (=0Ch)
0001h                 768 byte   RGB triplets with palette information

PROGRAMS:PC Paintbrush

This information is from and is used with permission.

More Resources