PCX

From Wikipedia, the free encyclopedia

PCX
File name extension .pcx
Developed by ZSoft Corporation
Type of format lossless bitmap image format

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 = "PC Paintbrush 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.

[edit] Typical file format

The PCX is a device-independent raster image format; the file header stores information about the display hardware (screen resolution, color depth and palette information, bit planes and so on) separately from the actual image information, allowing the image to be properly transferred and displayed on computer systems with different 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.

PCX image data is compressed using run-length encoding (RLE), a simple algorithm which collapses series of three or more consecutive bytes with identical colors into a two-byte pair. As the file is processed, the most-significant bit is used as a control switch (flag) 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.

Due to the use of the two most-significant bits as flags, in PCX files with a 256-color palette, color indexes 192 to 255 (with their most-significant bit already set) must be stored in an RLE byte pair even when they only occur one or two pixels in succession, whereas color indexes 0 to 193 can be stored directly or in RLE byte pairs (whichever is more space-efficient); therefore, the actual compression ratio could be optimized with proper sorting of palette entries (though this would not be feasible if the file must share its color palette with other images). For example, a palette could be optimized with the most commonly-used colors occurring in palette positions 0 to 191 and the least common colors allocated to the remaining quarter of the palette, this RLE scheme makes a trade off, it can have more un-chunked data but the maximum chunk length is 63 (compared to the 128 possible with TGA RLE compression). Another inefficiency with the RLE algorithm is that it is possible to store chunks with a length of 0, which allows whitespace in the file (which could be used for steganography), however this does allow it to be decoded a cycle quicker on some processors (namely on the DOS machines it was originally intended for).

The RLE compression algorithm required very little processor power or memory to apply — a significant concern with the computer systems of its day — but as computers and display hardware grew more sophisticated, the RLE algorithm became less space-efficient, as it was unable to compress dithered images such as photographs or complex computer graphics.

[edit] Multipage PCX

There is a multi-page version of PCX which is used by some computer fax and document management programs, using the file extension DCX.

[edit] Further reading