File Structure
The bitmap image file consists of fixed-size structures (headers) as well as variable-size structures appearing in a predetermined sequence. Many different versions of some of these structures can appear in the file, due to the long evolution of this file format.
Referring to the diagram 1, the bitmap file is composed of structures in the following order:
Structure Name | Optional | Size | Purpose | Comments |
---|---|---|---|---|
Bitmap File Header | No | 14 Bytes | To store general information about the Bitmap Image File | Not needed after the file is loaded in memory |
DIB Header | No | Fixed-size (however 7 different versions exist) |
To store detailed information about the bitmap image and define the pixel format | Immediately follows the Bitmap File Header |
Extra bit masks | Yes | 3 or 4 DWORDs (12 or 16 Bytes) |
To define the pixel format | Present only in case the DIB Header is the BITMAPINFOHEADER |
Color Table | Semi-optional | Variable-size | To define colors used by the bitmap image data (Pixel Array) | Mandatory for color depths <= 8 |
Gap1 | Yes | Variable-size | Structure alignment | An artifact of the File Offset to PixelArray in the Bitmap File Header |
Pixel Array | No | Variable-size | To define the actual values of the pixels | The pixel format is defined by the DIB Header or Extra bit masks. Each row in the Pixel Array is padded to a multiple of 4 bytes in size |
Gap2 | Yes | Variable-size | Structure alignment | An artifact of the ICC Profile Data offset field in the DIB Header |
ICC Color Profile | Yes | Variable-size | To define the color profile for color management | Can also contain a path to an external file containing the color profile. When loaded in memory as "non-packed DIB", it is located between the color table and gap1. |
Read more about this topic: BMP File Format
Famous quotes containing the words file and/or structure:
“I have been a soreheaded occupant of a file drawer labeled Science Fiction ... and I would like out, particularly since so many serious critics regularly mistake the drawer for a urinal.”
—Kurt Vonnegut, Jr. (b. 1922)
“The philosopher believes that the value of his philosophy lies in its totality, in its structure: posterity discovers it in the stones with which he built and with which other structures are subsequently built that are frequently betterand so, in the fact that that structure can be demolished and yet still possess value as material.”
—Friedrich Nietzsche (18441900)