Picture exchange
Surname | PCX |
abbreviation | PCX |
file extension | .pcx |
Manufacturer | ZSoft, 1982 |
Color space | Monochrome grayscale palette RGB |
Color depth | 1 bit - 2 colors 4 bit - 16 colors 8 bit - 256 colors 24 bit - 16.7 million |
compression | no RLE (lossless) |
Byte order | Little endian |
Picture exchange ( PCX ) is a file format for storing picture data .
The PCX format was developed in 1982 by the company ZSoft and used in its own products Paintbrush and FRIEZE (resident utility program for importing images from other applications, e.g. Lotus 1-2-3 ). Today the format is hardly supported by most graphics programs .
At the time PCX was developed, only Hercules and CGA graphics adapters were available. Over the years the graphics cards got better and new graphics modes emerged ( EGA , MCGA, VGA ). These were then covered by newer versions of the PCX format. The changes to the format definition were essentially limited to the color palette.
Structure of a PCX file
general structure
Header (128 bytes) |
Image data |
Color palette (optional, only with 256 colors) |
Header
Regardless of the version, PCX files have a 128-byte header.
Offset | Bytes | meaning |
---|---|---|
0 | 1 | Identification: 10 (0A hex ) = PCX file |
1 | 1 | PCX file version: 0 = version 2.5 2 = version 2.8 with pallet 3 = version 2.8 without pallet 4 = Windows without pallet 5 = version 3.0 |
2 | 1 | Compression 0 = none 1 = RLE coding |
3 | 1 | Bits per pixel (or per plane) |
4th | 8th | Coordinates of the original image XMIN, YMIN, XMAX, YMAX |
12 | 2 | horizontal resolution in DPI (dots per inch) |
14th | 2 | vertical resolution in DPI (dots per inch) |
16 | 48 | Color Map with the definition of the color palette. Organized as a 16 * 3 byte field. |
64 | 1 | reserved |
65 | 1 | Number of color levels (planes), max. 4th |
66 | 2 | Bytes per image line (even number) |
68 | 2 | Palette Information 1 = Color - B / W 2 = Grayscale |
70 | 2 | Screen width in pixels |
72 | 2 | Screen height in pixels |
74 | 54 | Empty bytes to fill the header |
Image data
Without compression, each color byte is an index (reference) to the color palette. With compression, length bytes are also possible, which specify how often the following color byte is to be repeated ( run length coding ). The compression is therefore particularly effective for graphics with large, single-colored areas. Length bytes are recognized by the fact that their two highest bits are set. The remaining bits are used to specify the length so that the maximum length that can be specified is 63 bytes. Individual color bytes can be specified directly. They only have to be listed with a preceding length byte with the value 193 if their value is 192 or more, otherwise they would be interpreted as a length byte.
Color palette
Color palettes with more than 16 colors are listed behind the image data. In this case, a byte with the value 12 is inserted between the image data and the palette. This is followed by three color bytes for the RGB value for each color index .
Color planes
A special feature of the PCX format is the storage of the image data in color planes. The coding order is Y-axis> color plane> X-axis . This is due on the one hand to the fact that PCX (in contrast to BMP ) is a hardware-related format that represents a (compressed) image of the screen memory, and on the other hand that Truecolor images or images with dithering can be compressed better with run length coding.
According to the official PCX standard, "runs" of the RLE may extend over several color levels, but some decoders do not support this. For good compatibility, encoders should avoid this, while decoders should support it. Runs can never span multiple lines.
Common formats
Color depth | Bits per level | Levels | sequence | origin |
---|---|---|---|---|
1 (2 colors) | 1 | 1 | - | MDA / Hercules monochrome |
2 (4 colors) * | 2 | 1 | - | CGA 4 color mode |
4 (16 colors) | 1 | 4th | Blue-Green-Red Intensity ** | EGA 16-color mode |
8 (256 colors) | 8th | 1 | Palette: red-green-blue | VGA 256 color mode |
24 (truecolor) | 8th | 3 | Red-Green-Blue | None *** |
Remarks
* 2-bit color mode has been deprecated and is no longer officially supported by the standard.
** Actually determined by the pallet, but this arrangement is the most common.
*** Common graphics cards use the sequence blue-green-red and display the pixels as 32-bit blocks.
literature
- Thomas W. Lipp: Graphic formats. Microsoft Press, Unterschleißheim 1997, ISBN 3-86063-391-0
- Günter Born: Reference manual file formats. Addison-Wesley, Bonn 1997, ISBN 3-8273-1241-8
Individual evidence
- ↑ The file MARBLES.PCX there is an example for runs over several color levels: http://www.fileformat.info/format/pcx/sample/index.htm