BMP
(Symbol definitions section) |
|||
Line 11: | Line 11: | ||
Though seemingly a simple format, it is complicated by its many different versions, lack of an official specification, lack of any version control process, and ambiguities and contradictions in the documentation. | Though seemingly a simple format, it is complicated by its many different versions, lack of an official specification, lack of any version control process, and ambiguities and contradictions in the documentation. | ||
− | Images are usually uncompressed, but [[Run-length encoding|RLE]] compression can be used under some conditions. The rare OS/2 2.0 format also supports Huffman 1D compression. | + | Images are usually uncompressed, but [[Run-length encoding|RLE]] compression can be used under some conditions. The rare OS/2 BMP 2.0 format also supports Huffman 1D compression. |
== Identification == | == Identification == | ||
Line 31: | Line 31: | ||
Also known as OS/2 BMP 1.0. | Also known as OS/2 BMP 1.0. | ||
− | Some sources say that the height and width fields in Windows BMP v2 are signed (which would make the Windows v2 and OS/2 1.0 formats slightly different), but modern documentation says they are unsigned. | + | Some sources say that the height and width fields in Windows BMP v2 are signed integers (which would make the Windows BMP v2 and OS/2 BMP 1.0 formats slightly different), but modern documentation says they are unsigned integers. |
=== Windows BMP v3 === | === Windows BMP v3 === | ||
Line 42: | Line 42: | ||
Windows CE also extended it, for example to allow 2 bits/pixel, but its extensions were not migrated to the BMP v4 and v5 formats. | Windows CE also extended it, for example to allow 2 bits/pixel, but its extensions were not migrated to the BMP v4 and v5 formats. | ||
− | It is apparently possible for OS/2 2.0 format to masquerade as Windows v3. The upshot is that if the compression type is 3 and the bit depth is 1, or the compression type is 4 and the bit depth is 24, then the file should be treated as OS/2 BMP 2.0. | + | It is apparently possible for OS/2 BMP 2.0 format to masquerade as Windows BMP v3. The upshot is that if the compression type is 3 and the bit depth is 1, or the compression type is 4 and the bit depth is 24, then the file should be treated as OS/2 BMP 2.0. |
=== Windows BMP v4 === | === Windows BMP v4 === | ||
Line 91: | Line 91: | ||
No details known. | No details known. | ||
+ | |||
+ | == Symbol definitions == | ||
+ | |||
+ | Here are the definitions, from the Windows SDKs, of some of the symbols used in the BMP documentation. | ||
+ | |||
+ | All integers use little-endian [[Endianness|byte order]]. | ||
+ | |||
+ | {| class="wikitable" | ||
+ | ! Symbol | ||
+ | ! Definition | ||
+ | |- | ||
+ | |WORD || unsigned 16-bit integer | ||
+ | |- | ||
+ | |DWORD || unsigned 32-bit integer | ||
+ | |- | ||
+ | |LONG || signed 32-bit integer | ||
+ | |- | ||
+ | |BI_RGB || 0 | ||
+ | |- | ||
+ | |BI_RLE8 || 1 | ||
+ | |- | ||
+ | |BI_RLE4 || 2 | ||
+ | |- | ||
+ | |BI_BITFIELDS || 3 | ||
+ | |- | ||
+ | |(Huffman 1D) || 3 | ||
+ | |- | ||
+ | |BI_JPEG || 4 | ||
+ | |- | ||
+ | |(24-bit RLE) || 4 | ||
+ | |- | ||
+ | |BI_PNG || 5 | ||
+ | |- | ||
+ | |BI_ALPHABITFIELDS || 6 | ||
+ | |- | ||
+ | |BI_SRCPREROTATE || 0x8000 (?) | ||
+ | |- | ||
+ | |LCS_CALIBRATED_RGB || 0 | ||
+ | |- | ||
+ | |LCS_sRGB || <code>'sRGB'</code> = 0x73524742 | ||
+ | |- | ||
+ | |LCS_WINDOWS_COLOR_SPACE || <code>'Win '</code> = 0x57696e20 | ||
+ | |- | ||
+ | |PROFILE_LINKED || <code>'LINK'</code> = 0x4c494e4b | ||
+ | |- | ||
+ | |PROFILE_EMBEDDED || <code>'MBED'</code> = 0x4d424544 | ||
+ | |- | ||
+ | |LCS_GM_BUSINESS || 1 | ||
+ | |- | ||
+ | |LCS_GM_GRAPHICS || 2 | ||
+ | |- | ||
+ | |LCS_GM_IMAGES || 4 | ||
+ | |- | ||
+ | |LCS_GM_ABS_COLORIMETRIC || 8 | ||
+ | |} | ||
== Specifications == | == Specifications == |
Revision as of 21:35, 27 March 2013
Contents |
Overview
BMP is a family of raster graphics image file formats designed to store bitmap digital images independently of a display device. BMP was originally and is primarily used on Microsoft Windows and OS/2 operating systems. The format is sometimes known as Device-Independent Bitmap (DIB), since, when loaded into memory using Windows software, the image is held as a DIB structure.
Though seemingly a simple format, it is complicated by its many different versions, lack of an official specification, lack of any version control process, and ambiguities and contradictions in the documentation.
Images are usually uncompressed, but RLE compression can be used under some conditions. The rare OS/2 BMP 2.0 format also supports Huffman 1D compression.
Identification
No MIME type has been officially registered. Strings found in practice are: image/bmp; image/x-bmp; image/x-ms-bmp
The standard file extension is .bmp. Reportedly, .dib and .rle have occasionally been used.
BMP files start with bytes 'B' 'M' ?? ?? 00 00 00 00
.
Well-known versions
BMP files use a common 14-byte file header, named BITMAPFILEHEADER. Following that is the "Info header", which begins with a 4-byte integer indicating its size. The Info header size (mostly) reveals the version of BMP that the file uses.
Windows BMP v2
- Info header size: 12
- Info header name: BITMAPCOREHEADER or OS21XBITMAPHEADER
- PRONOM: fmt/115
Also known as OS/2 BMP 1.0.
Some sources say that the height and width fields in Windows BMP v2 are signed integers (which would make the Windows BMP v2 and OS/2 BMP 1.0 formats slightly different), but modern documentation says they are unsigned integers.
Windows BMP v3
This is by far the most widely used version of BMP. It was introduced with Windows 3.x. Windows NT extended it to support 16 and 32 bits/pixel.
Windows CE also extended it, for example to allow 2 bits/pixel, but its extensions were not migrated to the BMP v4 and v5 formats.
It is apparently possible for OS/2 BMP 2.0 format to masquerade as Windows BMP v3. The upshot is that if the compression type is 3 and the bit depth is 1, or the compression type is 4 and the bit depth is 24, then the file should be treated as OS/2 BMP 2.0.
Windows BMP v4
- Info header size: 108
- Info header name: BITMAPV4HEADER
- PRONOM: fmt/118
Introduced with Windows 95.
Windows BMP v5
- Info header size: 124
- Info header name: BITMAPV5HEADER
- PRONOM: fmt/119
Introduced with Windows 98.
Other versions
Windows BMP v1
- PRONOM: fmt/114
This is the bitmap file format used by Windows 1.0. It's not really a BMP format. It has a 10-byte file header, and is also called "DDB" (Device-Dependent Bitmap).
OS/2 BMP 2.0
- Info header size: 16–64 (16, 40, 48, and 64 may be most common)
- Info header name: BITMAPCOREHEADER2 or OS22XBITMAPHEADER
- PRONOM: x-fmt/270
See also OS/2 BMP.
OS/2 BMP 2.0 defines several file subtypes; here we are describing only the "Bitmap" subtype (files with a signature of "BM").
The header size can be reduced from its full size of 64 bytes. Omitted fields are assumed to have a value of zero.
The fields in the first 40 bytes of the header are (nearly) identical to those in Windows BMP v3, v4, and v5. The remaining fields are different.
OS/2 BMP 2.0 supports compression types "Huffman 1D" and "RLE24", unlike any other version of BMP.
BITMAPV2INFOHEADER
- Info header size: 52
- Info header name: BITMAPV2INFOHEADER
No details known.
BITMAPV3INFOHEADER
- Info header size: 56
- Info header name: BITMAPV3INFOHEADER
No details known.
Symbol definitions
Here are the definitions, from the Windows SDKs, of some of the symbols used in the BMP documentation.
All integers use little-endian byte order.
Symbol | Definition |
---|---|
WORD | unsigned 16-bit integer |
DWORD | unsigned 32-bit integer |
LONG | signed 32-bit integer |
BI_RGB | 0 |
BI_RLE8 | 1 |
BI_RLE4 | 2 |
BI_BITFIELDS | 3 |
(Huffman 1D) | 3 |
BI_JPEG | 4 |
(24-bit RLE) | 4 |
BI_PNG | 5 |
BI_ALPHABITFIELDS | 6 |
BI_SRCPREROTATE | 0x8000 (?) |
LCS_CALIBRATED_RGB | 0 |
LCS_sRGB | 'sRGB' = 0x73524742
|
LCS_WINDOWS_COLOR_SPACE | 'Win ' = 0x57696e20
|
PROFILE_LINKED | 'LINK' = 0x4c494e4b
|
PROFILE_EMBEDDED | 'MBED' = 0x4d424544
|
LCS_GM_BUSINESS | 1 |
LCS_GM_GRAPHICS | 2 |
LCS_GM_IMAGES | 4 |
LCS_GM_ABS_COLORIMETRIC | 8 |
Specifications
- BITMAPFILEHEADER
- BITMAPCOREHEADER
- BITMAPINFOHEADER
- BITMAPINFOHEADER (Windows CE 5.0)
- BITMAPV4HEADER
- BITMAPV5HEADER
Sample images
Resources
- BMP (file format): Wikipedia
- Bitmap Image File (BMP), Version 5, from Library of Congress resource on Sustainability of Digital Formats
- Microsoft Windows Bitmap File Format Summary From Encyclopedia of Graphics File Formats at FileFormat.Info (1996)
- OS/2 Bitmap File Format Summary From Encyclopedia of Graphics File Formats at FileFormat.Info (1996)