PCX

related topics
{system, computer, user}
{math, number, function}
{style, bgcolor, rowspan}
{@card@, make, design}

PCX is an image file format developed by the ZSoft Corporation of Marietta, Georgia, USA. It was the native file format for PC Paintbrush (PCX = "Personal Computer eXchange") and became one of the first widely accepted DOS imaging standards, although its use has since been succeeded by more sophisticated image formats such as GIF, JPEG and PNG.

The PCX is a device-independent raster image format; the file header stores metadata about the image (pixel resolution, color bit depth AND number of bitplanes, color palettes, etc) separately from the actual image bitmap, allowing the image to be properly transferred and displayed on computer systems with different software applications and arbitrary hardware. PCX files commonly store palette-indexed images ranging from 2 or 4 colors to 16 and 256 colors, although the format has been extended to record true-color (24-bit) images as well.

Contents

File structure

A PCX file has three main sections: a 128 byte header which is followed by image data and an optional 256 color palette. PCX files were designed for use on IBM-compatible PCs and always use little endian byte ordering.

File header

(256 color palletted/greyscale)

3x greyscale planes with optional 8-bit alpha channel)

The PCX file header contains an identifier byte (value 10), a version number, image dimensions, a 16 color palette, number color planes and the bit depth of each plane. While the file header could describe a wide variety of image formats, many are not of practical use. Convention has limited the supported combinations of plane count and bit depth to match specific PC display hardware. Many image editing programs will not read PCX files which do not match one of these conventions. Table A shows the most commonly supported combinations.

The header also contains a value for compression method. All PCX files are written with the same compression scheme and this value is always 1. No other values have been defined and there are no uncompressed PCX files.

PCX version numbers range from 0 to 5, though the file format does not change between versions.

The header is always 128 bytes long, though only 74 bytes are used. The rest of the 128 bytes is padded, and the image data always begins 128 bytes after the start of the file.

Image data

PCX image data is stored in rows or scan lines in top-down order. Where the image has multiple planes these are stored by plane within row. Such that all the red data for row 0 is followed by all the green data for row 0, then all the blue data, then alpha (or intensity) data. This pattern is repeated for each line as shown in Table B.

When an image is less than 8 bits per pixel, each line is padded to the next byte boundary. For example, if an image has 1 plane of 1-bit data (monochrome) with a width of 22 pixels, each row will be 3 bytes long, having 24 bits per row with 2 bits unused.

PCX image data is compressed using run-length encoding (RLE), a simple lossless compression algorithm which collapses a series of three or more consecutive bytes with identical colors into a two-byte pair. As the file is processed, the two most-significant bits of a byte are used to determine whether the given data represents a single pixel of a given palette index or color value, or an RLE pair representing a series of several pixels of a single value. This RLE scheme makes a trade off, it can have more single pixel data but the maximum run length is 63 (compared to the 128 possible with TGA RLE compression).

Full article ▸

related documents
Windows 1.0
Windows Me
Electronics
Hercules emulator
Intel 8085
LINC
Accelerated Graphics Port
Audio Video Interleave
AOL Instant Messenger
Intelligent network
Apple Lisa
Amiga 500
Windows NT
ISCSI
Gentoo Linux
Colossus computer
Java Message Service
Solaris (operating system)
DECnet
XScale
Digital audio
User Datagram Protocol
Internet Protocol
Parallel port
Slave clock
Intel 8051
Dial-up internet access
ARCNET
Motorola 6800
Game Boy line