| Previous | Table of Contents | Next |
Digital images are stored as data files. Because of file size considerations, image data is usually compressed to conserve disk storage space or transmission times. This requires files to contain descriptive information that assists programs to reconstruct the image. This chapter discusses one simple image format in detail, the PCX file format developed by ZSoft Corp. of Marietta, Georgia. It then presents an overview of two other popular World Wide Web image file formats.
Among other things, images
Therefore, compressed image data requires separate description information, usually contained in a file header, that allows programming to reconstruct the associated image.
Some of these file formats, such as the Tagged Information File Format (TIFF), are extremely flexible, providing considerations for numerous variations of dozens of different image characteristics. In fact, most folks feel the TIFF file format is too flexible because no single program can possibly decode all potential image variations and must resort to decoding well-defined subsets.
Further complicating matters, the Windcrest/McGraw-Hill book Graphics File Formats by David C. Kay and John R. Levine lists nearly 50 different file formats. So, it becomes obvious why image file conversions have proven profitable for their developers. Rather than becoming distracted by image file format minutia, we select a single simple file format as a basis for detailed discussion on the processing necessary to reconstruct compressed image data faithfully.
The PCX file format is one of the oldest, simplest, and easiest to understand image file formats. Developed for its popular PC Paintbrush program, ZSoft extensively documented the PCX file format, eventually allowing it to achieve the status of a leading PC image file format. Moreover, because its several extensions complement PC display adapter evolution, it remains pervasive though it is less popular than it once was.
The PCX file format exhibits the symptoms of an originally well-conceived design that technology eventually made obsolete. For example, the original file format consisted of a fixed-length 128-byte header that described the compressed image data that immediately followed. The files header reserved 48 bytes for a 16-entry color palette which is now completely useless since todays palettes have 256 entries requiring 768 bytes.
Therefore, in file format version 3.0 format five, the larger palette was appended to the files end following a signature byte located 769 bytes from the files end and having a value of 0x0C. This is intellectually clumsy in theory, but works well in practice.
Since the PCX file format version 3.0 also supports direct color files, it is important to check the headers NumberOfColorPlanes field value to determine the number of color planes the image contains. If Number-OfColorPlanes has a value of 0x01, the image is a palette image and the palette is located 768 bytes from the end of the file as described. Otherwise, NumberOfColorPlaness value must be 0x03 indicating three color planesone each for red, green, and blue. Programs in this book only deal with file format version 3.0, format five files.
Another significant reason for the decline of PCX file format popularity is due to its compression scheme. To its credit, the compression scheme is very simple and losslessdecompressed data is identical to the original data. However, it is relatively inefficient as compared to popular compression schemes such as LZW that other file formats use. However, LZW is, unfortunately, a patented compression scheme, and software that uses it requires a license from Unisys Corp.
The PCX header describes the files single compressed image that begins at file offset 128L. It defines the images horizontal and vertical resolution and whether the image is a direct color image or a palette image. The headers BitsPerPixel field indicates the number of bits per pixel for direct color images. The PCX.H header file contains the header fields which are summarized in Table 10-1:
| Offset | Field Type | Field Name | Comment |
| 00 | USGC | ManufacturerFlag | Must have 0x0A for value |
| 01 | USGC | FileFormatVersionNumber | Must be 0x05 for this book |
| 02 | USGC | EncodingMethod | Must have a value of 0x01 for run length encoding |
| 03 | USGC | BitsPerPixelPerPlane | Palette images => 8; Direct color images =>24 |
| 04 | USGI | XMin, YMin, XMax, YMax | Image Width = XMax XMin +1, Height = YMax YMin + 1 |
| 12 | USGI | SuggestedHorizontalDPI | Horizontal scanning resolution |
| 14 | USGI | SuggestedVerticalDPI | Vertical scanning resolution |
| 16 | USGC | SixteenColorPalette[48] | Obsolete |
| 64 | USGC | Reserved | |
| 65 | USGC | NumberOfColorPlanes | 0x01 => Palette image; 0x03 => Direct color image |
| 66 | USGI | BytesPerScanLine | For each color plane, the number of bytes to allocate for scan lines |
| 68 | USGI | PaletteInformation | Ignore for this book |
| 70 | USGI | ScreenHorizontalPixelCount | Horizontal screen size in pixels |
| 72 | USGI | ScreenVerticalPixelCount | Vertical screen size in pixels |
| 74 | USGC | Filler[54] |
Table 10-1: PCX.H header file fields
| Previous | Table of Contents | Next |