PCX FILES ***************************************************************************** DESCRIPTION ***************************************************************************** The PCX extention (.pcx) has become a standard used to specify graphic files stored in the PCX File Format. This file format is used to store pictures efficiently using a run-length encoding (RLE) technique to compress the image and save disk space. This file format was originally developed for the PC by Zsoft for a paint program called Paintbrush. Most games today use 256-color PCX files. The race simulators by Papyrus use 256-color PCX files mainly to store the color palettes, but also to store those nifty images that you see at the end of a race and at the end of the season. The cars are painted with colors 16-175 from the palette. ***************************************************************************** STRUCTURE ***************************************************************************** The PCX file is divided into three distint sections. The first section in the header which contains the attributes of the image. The second section contains the image data itself. The third section contains the 256-color palette. SECTION ONE: The Header ----------------------- BYTE PURPOSE ---- -------------------------------------------------- 000 Manufacturer: Always set to zero 001 Version: Always set to five for 256-color 002 Encoding: Always set to one 003 Bits-per-pixel: Always set to 8 for 256-color 004-005 X-MIN: Top left x-coordinate 006-007 Y-MIN: Top left y-coordinate 008-009 X-MAX: Width of the image 010-011 Y-MAX: Height of the image 012-013 H-RES: Horizontal resolution of the image 014-015 V-RES: Vertical resolution of the image 016-063 EGA Palette: Not used in 256-color files 064 Reserved: For future use 065 Color Planes: Number of color planes 066-067 Bytes-per-line: Num of bytes in 1 line of pixels 068-069 Palette Type: Always set to 2 for color palettes 070-127 Filler: Used to round the header out to 128 bytes SECTION TWO: The Image ---------------------- The image of the PCX file begins at byte 128. The PCX file uses a run-length encoding (RLE) technique to compress the image and save disk space. If the first value P in the image is less than 192, it represents one pixel of color value P. If the first value is 192 or more, it represents the count of pixels plus 192 that have the following byte's color value. This is repeated until every pixel in the image is accounted for. SECTION THREE: The 256-Color Palette ------------------------------------ Each color is represented by one value for red, one value for green, and one value for blue. Each of these values is stored as one byte in the palette. Since there are 256 colors, the 256-color palette is the last 768 bytes of the PCX file. The range for each red/green/blue value is 0 to 63, with 0 being darkest and 63 being the brightest. A PCX file stores the red/green/blue values multiplied by four. For tracks, only the last 80 colors (176-255) are editable. The first 175 colors are used for the cars and other things such as the flagman's flags. ------------------------- -Corey Rueckheim -rueck_cw@cslab.uwlax.edu