The PCX format was developed by ZSoft, publishing the PaintBrush software which Microsoft Windows operating systems were equipped with in a standard way as from the eighties.
The PCX format is a bitmap format that allows images, whose dimensions may range up to 65536 by 65536 and which may be coded on 1 bit, 4 bits, 8 bits or 24 bits (corresponding to 2, 16, 256 or 16 million colors respectively).
The structure of a PCX file is the following:
- A bitmap information header) with a length of 128 bytes
- The image body
- Color palette (optional). This is a field of 768 bytes allowing the various values of red, green and blue (RGB) for each palette element to be stored.
Bitmap information header
The bitmap information header provides information on the image, particularly its dimensions and its colors.
The bitmap information header comprises the following fields:
- The file signature (on one byte), allowing the file type to be identified. The hexadecimal value 0A indicates a PCX file.
- The version (on one byte):
- 0= Version 2.5
- 2= Version 2.8 with palette
- 3= Version 2.8 without palette
- 5= Version 3.0
- The format (on one byte), that is, the encoding method used. A value of 1 indicates RLE encoding.
- The number of bits per pixel per plane (on one byte)
- Xmin (on two bytes), the X-coordinate of the upper left hand corner
- Ymin (on two bytes), the Y-coordinate of the upper left hand corner
- Xmax (on two bytes), the X-coordinate of the lower right hand corner
- Ymax (on two bytes), the Y-coordinate of the lower right hand corner
- The horizontal resolution (on two bytes)
- The vertical resolution (on two bytes)
- The palette (on 48 bytes)
- Reserved (on one byte)
- Number of color planes (on a byte)
- Number of bits per line (on 2 bytes)
- Type of palette (on 2 bytes)
- Filling (58 bytes)
It is interesting to note that "Xmax - Xmin + 1" represents the width of the image and that "Ymax - Ymin + 1" represents the height of the same.
The coding of the image is done by writing the bits corresponding to each pixel successively, line by line, starting with the pixel in the upper left hand corner and then continuing from left to right and from top to bottom.