.BMP Image File Format Specification

Q

What are specifications of the .BMP image file format?

✍: FYIcenter.com

A

BMP, short name for Bitmap, is used as the file extension for bitmap image files.

.BMP file format was originally designed by Microsoft as part of their Windows Metafile (WMF) specification.

.BMP image file format is composed of structures in the following order:

1. Bitmap file header - Required with 14 bytes. Used to store general information about the bitmap image file. The following table provides details of the 14-byte .BMP file header:

00-01 (2-bytes) - The BMP file identifier with these possible values:
        BM – Windows 3.1x, 95, NT, ... etc.
        BA – OS/2 struct bitmap array
        CI – OS/2 struct color icon
        CP – OS/2 const color pointer
        IC – OS/2 struct icon
        PT – OS/2 pointer
02-05 (4 bytes) - The size of the BMP file in bytes
06-07 (2 bytes) - Reserved for the application that creates the image
08-09 (2 bytes) - Reserved for the application that creates the image
0A-0D (4 bytes) - The offset, i.e. starting address, of the byte 
        where the bitmap image data (pixel array) can be found.

2. DIB (Device Independent Bitmaps) header - Required with different lengths for different versions. Used to store detailed information about the bitmap image and define the pixel format.

3. Extra bit masks - Optional with 12 or 16 bytes. Used to define the pixel format. Present only in case the DIB header is the BITMAPINFOHEADER and the Compression Method member is set to either BI_BITFIELDS or BI_ALPHABITFIELDS

4. Color table - Optional with variable-size. Used to define colors used by the bitmap image data (Pixel array). Mandatory for color depths = 8 bits

5. Gap1 - Required with variable-size. used as a structure alignment

6. Pixel array - Required with variable-size. Used 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

7. Gap2 - Optional with variable-size. Used as a structure alignment.

8. ICC color profile - Optional with variable-size. Used to define the color profile for color management. Can also contain a path to an external file containing the color profile.

The picture below provides a visual illustration of the .BMP image file structure with details of the DIB header:

2015-11-30, 4520👍, 0💬