Bitmap files vary greatly in their details, but they all share the same general structure. This chapter looks at the components of a typical bitmap file. Later on in this chapter we'll get into explanations of the details, but for now let's just get a feel for the overall structure. We'll explain as necessary as we go along.
Contents:
How Bitmap Files Are Organized
Header
Examples of Bitmap Headers
Bitmap Data
Footer
Other Bitmap File Data Structures
Other Bitmap File Features
Pros and Cons of Bitmap File Formats
Bitmap files consist of a header, bitmap data, and other information, which may include a color palette and other data.
A warning: inexplicably, people continue to design applications which use what are sometimes called raw formats. Raw format files consist solely of image data and omit any clues as to their structure. Both the creator of such files and the rendering applications must somehow know, ahead of time, how the files are structured. Because you usually can't tell one raw format file from another (except perhaps, by examining their relative sizes), we'll confine our discussion in this chapter to bitmap files, which at least contain headers.
The basic components of a simple bitmap file are the following:
Header |
Bitmap Data |
If a file contains no image data, only a header will be present. If additional information is required that does not fit in the header, a footer will usually be present as well:
Header |
Bitmap Data |
Footer |
An image file may store a palette in the header, but it will more likely appear immediately after the header:
Header |
Palette |
Bitmap Data |
Footer |
A palette can also appear immediately after the image data, like a footer, or be stored in the footer itself:
Header |
Bitmap Data |
Palette |
Scan-line tables and color correction tables may also appear after the header and before or after the image data:
Header |
Palette |
Scan Line Table |
Color Correction Table (here) |
Bitmap Data |
Color Correction Table (or here) |
Footer |
If an image file format is capable of holding multiple images, then an image file index may appear after the header, holding the offset values of the starting positions of the images in the file:
Header |
Palette |
Bitmap Index |
Bitmap 2 Data |
... |
Bitmap n Data |
Footer |
If the format definition allows each image to have its own palette, the palette will most likely appear before the image data with which it is associated:
Header |
Palette |
Bitmap Index |
Palette 1 |
Bitmap Data |
Palette 2 |
Bitmap 2 Data |
... |
Palette n |
Bitmap n Data |
Footer |
We'll now look at the parts of a bitmap file piece by piece.
Copyright © 1996, 1994 O'Reilly & Associates, Inc. All Rights Reserved.