PCX, standing for PiCture eXchange, is an image file format developed by the now-defunct ZSoft Corporation of Marietta, Georgia, United States. It was the native file format for PC Paintbrush and became one of the first widely accepted DOS imaging standards, although it has since been succeeded by more sophisticated image formats, such as BMP, JPEG, and PNG. 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 formats
PCX was designed during the early development of PC display hardware and most of the formats are no longer used. The table below shows a list of the most commonly used PCX formats. Contemporary image editing programs may not read PCX files that match older hardware.
{| class="wikitable"
|+ Common PCX Image Formats
! Bit Depth || Planes || Number of Colors
|-
| 4 || 1 || 16 colors from a palette
|-
| 8 || 1 || 256 colors from a palette
|-
| 8 || 1 || 256 shades of gray
|-
| 4 || 4 || 4096 colors with 16 levels of transparency
|-
| 8 || 3 || 16.7 million, 24-bit "true color"
|-
| 8 || 4 || 16.7 million with 256 levels of transparency
|-
| 1 || 1 || 2 colors monochrome (1-Bit) (Win 3.1 Paintbrush)
|-
| 1 || 4 || 16 colors RGBi (4-Bit) in 4 planes (Win 3.1 Paintbrush)
|}
PCX is understood and produced by common image processing software including ACDSee, FastStone, GIMP, ImageMagick, IrfanView, LView, Netpbm, PaintShop Pro, Photoshop, Visio, PMview, XnView and GraphicConverter. In version 2.1.4 FFmpeg could encode and decode the PCX pixel formats rgb24, rgb8, bgr8, rgb4_byte, bgr4_byte, gray, pal8, and monob.
There is a multi-page version of PCX, used by some computer fax and document management programs, with file extension <code>.dcx</code>. A DCX file consists of a header introducing a set of following PCX files.
PCX file format
PCX files were designed for use on IBM-compatible PCs and always use little endian byte ordering. A PCX file has three main sections, in the following order
- 128-byte header
- image data
- (optional) 256-color palette
The PCX file header contains an identifier byte (value 10), a version number, image dimensions, 16 palette colors, number color planes, bit depth of each plane, and a value for compression method. PCX version numbers range from 0 to 5, this originally denoted the version of the PC Paintbrush program used to create the PCX file. The header always has space for 16 colors though the number of colors used depends upon the bit depth of the image. The header is composed of 18 fields:
Image data layout
PCX image data is stored in rows or scan lines in top-down order. If the image has multiple planes, these are stored by plane within row, such that all the red data for row 0 are followed by all the green data for row 0, then all the blue data, then alpha data. This pattern is repeated for each line as shown in the next table:
{| class="wikitable"
|+ PCX Image Data Arranged into Color Planes
|-
|align="center" width="60" rowspan="4"| Row 0
|align="center" style="background:#ffafaf;font-family: monospace"| R R R R R R R R R
|-
|align="center" style="background:#afffaf;font-family: monospace"| G G G G G G G G G
|-
|align="center" style="background:#afafff;font-family: monospace"| B B B B B B B B B
|-
|align="center" style="background:#cfcfcf;font-family: monospace"| A A A A A A A A A
|-
|align="center" rowspan="4"| Row 1
|align="center" style="background:#ffafaf;font-family: monospace"| R R R R R R R R R
|-
|align="center" style="background:#afffaf;font-family: monospace"| G G G G G G G G G
|-
|align="center" style="background:#afafff;font-family: monospace"| B B B B B B B B B
|-
|align="center" style="background:#cfcfcf;font-family: monospace"| A A A A A A A A A
|-
|align="center" style="height:64px"| Row 2 etc.||align="center"| ....
|}
When an image is less than 8 bits per pixel, each line is padded to the next even byte boundary.
