HomepageStartseite

Products
Information


 
Family Tree Software
Experience Ages!

Genealogy made easy - complete with graphic family trees and easy-to-use interface.
More than 10 languages supported
Download.

status of this document: work in progress

Table of Contents 
Last updated: Jan 14, 1998  

to topBasic Description

PCX files can hold the following Images: 4-color palletized CGA, 16-color palletized EGA,  256-color palletized VGA, and 24-bit truecolor. 
Derived Formats:  SCR. 

to topBasic File Format

Name Size Description
Signature 1 byte =$0A   ($CD for  SCR 
>$0A: This is a PCX font file ! (not described here)
Version 1 byte 0= Version 2.5  
2= Version 2.8 with Palette  
3= Version 2.8 without Palette  
5= Version 3.0
Compression 1 byte 1 = RLE compressed
BitsPerPixel 1 byte number of bits per pixel per plane
Xmin 2 bytes column of upper left corner of image. Most commonly = 0
Ymin 2 bytes row of upper left corner of image. Most commonly = 0
Xmax 2 bytes XSize = Xmax - Xmin + 1
Ymax 2 bytes YSize = Ymax - Ymin + 1
Xdpi 2 bytes  used inconsistently across versions (info needed)
Ydpi 2 bytes used inconsistently across versions (info needed)
ColorTable 48 bytes Palette Information (one of the 3 following formats) 
  CGA / Monochrome 48 bytes see CGA Palette paragraph below
  BackgroundColor 1 byte high-order 4 bits = Color (CGA hardware palette) 
filler 2 byte unused
PaletteInfo 1 byte only 3 bits used
  MonoFlag bit 7 0 = Color  
1 = Monochrome
Palette bit 6 0 = Green, Red, Brown (Yellow)  
1 = Cyan, Magenta, White
Intensity bit 5 0 = dark  
1 = light
reserved bits 4-0 unused
filler 44 bytes unused =0
16 color 48 bytes present, if NumColorPlanes = 1, and  BitsPerPixel < 8
  Red 1 byte Red intensity
Green 1 byte Green intensity
Blue 1 byte Blue intensity
repeated 16 times
256 color 48 bytes present if BitsPerPixel =8
  filler 48 bytes unused, but for 256 color images, the first 16color map entries of the image may be stored here in addition to the full palette at the end of this file.
reserved 1 byte =0
NumColorplanes 1 byte 1 = Monochrome / Palletized   
3 = RGB  (valid ? 
4 = RGBI
BytesPerScanline 2 bytes size of uncompressed data per scan line. must be even. 
(can be any number for SCRs)
ColorTableType 2 bytes 1 = Color or B&W  
2 = Grayscale
filler 58 bytes makes the header a total of 128 bytes
Raster Data cannot be pre calculated The pixel data
Palette Header 1 byte =12, should be present if: 
  • Version = 2 or 
  • Version = 5, BitsPerPixel = 8, NumColorplanes = 1, ColorTableType = 1
Palette 768 bytes present under same conditions as Palette Header
 
 

to topThe CGA Palette

Since almost nobody has a CGA Card anymore, here are the two CGA Palettes in RGB. (Guesswork!, I neither have a CGA PCX file, nor a CGA Card anywhere) 
 
CGA Palette 0, dark Green 0,128,0
Red 128,0,0
Brown 128,128,0
CGA Palette 0, light light Green 0,255,0
light Red 255,0,0
Yellow 255,255,0
CGA Palette 1, dark Cyan 0,128,128
Magenta 128,0,128
Gray 128,128,128
CGA Palette 1, light light Cyan 0,255,255
light Magenta 255,0,255
White 255,255,255
 

to topRaster Data encoding

The raster data immediately follows the 128byte header. It uses a run length encoding for compression purposes. Data is stored top-down, left-to-right, with a possible filler byte between scan lines. The encoding is dependent on the number of bits/pixel.
 

to topRaster Data encoding for 2bit 4-color images (CGA)

unknown. If you find out how this is done, please drop me a note.
 

to topRaster Data encoding for 4bit 16color images

unknown. If you find out how this is done, please drop me a note.
 

to topRaster Data encoding for 8bit 256color/256 grayscale images

n Byte 1 c Byte 2 Result
>=$C0 any n consecutive pixels of color c
<$C0 - a pixel with color n. (c is already part of the next code)
Every scan line with an odd number of bytes will have a zero appended, to match a 16 bit alignment. Single pixels with a color >= $C0 have to be stored as a ($C1, color) -tuple. Only pixels on the same line may be combined to form a 2-byte sequence.
 

to topRaster Data encoding for 24/32bit truecolor images

Every row of pixels is written as four 8bit single color component scan lines, each having the same scheme as the 8bit version. These scan lines have the following order: Red, Green, Blue, Alpha. The fifth scan line in the file will be the Red component of pixel row 2. 
Whether it is valid to store only three scan lines, skipping the Alpha Channel, is unresolved.

to topPortability

The CGA Palette is portable via translation table. 2-byte values are stored in Intel order (Least significant byte first) 

to topTrademarks, Patents and Royalties

To my knowledge: none. 
(please read the disclaimer) 

to topCross-Checking Software

This section is for programmers, who wish to cross-check their implementation with others. This is an incomplete list of programs, which are available as freeware / shareware / try-before-buy etc. 

The following software is able to decode PCXs: 

  • MS-Paintbrush, MS-Paint (included in MS-Windows)
  • JASC Paintshop Pro
The following software is able to encode PCXs: 
  • MS-Paintbrush, MS-Paint (included in MS-Windows)
  • JASC Paintshop Pro

to topOnline Resources


to topDisclaimer
This is not the official format documentation. Although we're doing our best to keep this information as accurate as possible, there is no way of checking all of it under all possible circumstances. We're not taking any responsibility for the results of this information or lack thereof. The 'trademarks, patents and royalties' section is here just for your convenience, and is in no way complete. Please send us a note, if you find any incorrect of missing information to fileformats@daubnet.com. 
© Jörn Daub EDV-Beratung - Glashütter Weg 105 - 22889 Tangstedt - Germany