|
File Header Every Windows BMP begins with a BITMAPFILEHEADER structure whose layout is shown in Table 2.1. The main function of this structure is to serve as the signature that identifies that file format. Three checks can be made to ensure that the file you are reading is in fact a BMP file:-
When decoding a BMP file you must use the bfOffbits field to determine the offset from the beginning of the file to where the pixel data starts. Most applications place the pixel data immediately following the BITMAPINFOHEADER structure or palette, if it is present. However, some applications place filler bytes between these structures and the pixel data so you must use the bfOffbits to determine the number of bytes from the BITMAPFILEHEAOER structure to the pixel data. |
Field Name | Size in Bytes | Description |
bfType | 2 | Contains the characters "BM" that identify the file type |
bfsize | 4 | File size |
bfReservedl | 2 | Unused |
bfReserved2 | 2 | Unused |
bfOffBits | 4 | Offset to start of pixel data |
Field Name | Size | Description |
biSize | 4 | Header size-Must be at least 40 |
biWidth | 4 | Imagewidth |
biHeight | 4 | Image height |
biPlanes | 2 | Must be 1 |
biBitCount | 2 | Bits per pixel- 1, 4, 8, 16, 24, or 32 |
biCompression | 4 | Compression type- BI_RGB=O, BI_RLE8=1, |
BI_RLE4=2, or BI_BITFIELDS=3 | ||
biSizelmage | 4 | Image Size-May be zero if not compressed |
bixPelsPerMeter | 4 | Preferred resolution in pixels per meter |
biyPelsPerMeter | 4 | Preferred resolution in pixels per meter |
biClrUsed | 4 | Number of entries in the color map that are actually used |
biClrlmportant | 4 | Number of significant colors |
Field | Size | Description |
rgbBlue | 1 | Blue color value |
rgbGreen | 1 | Redcolorvalue |
rgbRed | 1 | Green color value |
rgbReserved | 1 | Must be zero |