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:
“A common and natural result of an undue respect for law is, that you may see a file of soldiers, colonel, captain, corporal, privates, powder-monkeys, and all, marching in admirable order over hill and dale to the wars, against their wills, ay, against their common sense and consciences, which makes it very steep marching indeed, and produces a palpitation of the heart.”
—Henry David Thoreau (18171862)
“What is the most rigorous law of our being? Growth. No smallest atom of our moral, mental, or physical structure can stand still a year. It growsit must grow; nothing can prevent it.”
—Mark Twain [Samuel Langhorne Clemens] (18351910)