Introduction
BMP is the bitmap image format that Microsoft and IBM shared in Windows and OS/2 in the late 1980s. A BMP file holds a device independent bitmap (DIB): a header describing the image, an optional palette and the pixels, usually uncompressed. It begins with a 14-byte file header whose first two bytes are a type code.
Windows only ever writes the type BM, and almost every .bmp
file is one of those. A BM file can still be one of three formats, told
apart by the size of the DIB header that follows the file header. The Windows 3.0
header of 40 bytes and its later versions, up to 124 bytes, each keep every field of the
one before and add more at the end, so they are one format. The older 12-byte header of
Windows 2 and OS/2 1.x has 16-bit sizes and 3-byte palette entries, a different layout.
The OS/2 2.x header, of 16 to 64 bytes, lines up with the start of the Windows one but
gives two compression values other meanings and adds fields of its own, so it is a third
format.
OS/2’s Presentation Manager also reused the file header for its icons, mouse pointers and collections of bitmaps, giving each a type code of its own. These files are built from the same parts as a bitmap, but are put together differently, so each has its own page here.
Variations
| Format | Variation | About | Open |
|---|---|---|---|
.BMP | Windows bitmap (BM) | Windows 3.0 and later bitmaps: a 40- to 124-byte header, palette and pixel rows. | Open |
.BMP | Windows 2 and OS/2 1.x bitmap (BM) | The first bitmaps: a 12-byte header with 16-bit sizes and 3-byte palette entries. | Open |
.BMP | OS/2 2.x bitmap (BM) | OS/2 2.x bitmaps: a 16- to 64-byte header, with Huffman 1D and RLE24 compression. | Open |
.BMP | OS/2 bitmap array (BA) | Several OS/2 bitmaps, icons or pointers for different screens, chained in one file. | Open |
.ICO | OS/2 icon (IC) | A black and white OS/2 icon: AND and XOR masks in one 1-bit bitmap. | Open |
.ICO | OS/2 colour icon (CI) | A colour OS/2 icon: a 1-bit mask bitmap followed by a colour image. | Open |
.PTR | OS/2 pointer (PT) | A black and white OS/2 mouse pointer, with its hotspot in the header. | Open |
.PTR | OS/2 colour pointer (CP) | A colour OS/2 mouse pointer: masks, a colour image and a hotspot. | Open |
Windows bitmap (BM)
The ordinary bitmap of Windows 3.0 and later, written by nearly every image program. A file header is followed by a DIB header, an optional colour table or set of bit masks, and the rows of pixels, usually bottom row first. The DIB header grew from 40 bytes in Windows 3.0 to 124 bytes in Windows 98, each version adding to the one before, and its first four bytes give its size and so its version.
The file starts with BM (42 4D), and the four bytes at
offset 14 hold the DIB header size: 40, 52, 56, 108 or 124.
Windows 2 and OS/2 1.x bitmap (BM)
The first bitmaps, from Windows 2.0 and OS/2 1.x. The 12-byte header has 16-bit width and height and only 1, 4, 8 or 24 bits per pixel. The pixels are never compressed, and the colour table uses 3-byte entries instead of 4.
The file starts with BM (42 4D), and the DIB header size at
offset 14 is 12.
OS/2 2.x bitmap (BM)
The bitmap of OS/2 2.x. Its header, of up to 64 bytes, lines up with the first 40 bytes of the Windows header but can be cut short, with the missing fields taken as zero, and adds OS/2’s own fields. Compression 3 means Huffman 1D and 4 means RLE24, where Windows uses them for bit masks and JPEG.
The file starts with BM (42 4D), and the DIB header size at
offset 14 is from 16 to 64. A size of 40, 52 or 56 is read as a Windows bitmap, unless
compression 3 at 1 bit per pixel, compression 4 at 24 bits per pixel, or (at 52 and 56
bytes) OS/2’s halftoning fields in place of the Windows masks show it is OS/2’s own.
OS/2 bitmap array (BA)
A chain of bitmaps in one file, each made for a different screen. OS/2 used it so one icon, pointer or picture could carry versions for low and high resolution displays, and let the system pick the best fit. Each entry is an array header followed by a complete bitmap, icon or pointer.
The file starts with BA (42 41). At offset 14 a second type
code begins the first entry’s own file header, usually BM,
IC, CI, PT or CP. These files may
be named .bmp, .ico or .ptr.
OS/2 icon (IC)
A black and white OS/2 icon. It is a single 1-bit bitmap twice the icon’s height, holding two masks one above the other: together they make each pixel black, white, transparent or the inverse of what is behind it.
The file starts with IC (49 43), and the bitmap’s height is
twice its width. It is usually named .ico, which on Windows means a
different format.
OS/2 colour icon (CI)
A colour OS/2 icon. It holds two bitmaps one after the other: the same 1-bit pair of masks as a black and white icon, then a colour image that fills in the visible pixels.
The file starts with CI (43 49), and a second
CI file header follows the first bitmap’s headers and palette. It is
usually named .ico.
OS/2 pointer (PT)
A black and white OS/2 mouse pointer. It is laid out exactly like a black and white icon; the two fields that are reserved in a bitmap give the hotspot, the pixel that marks where the pointer points.
The file starts with PT (50 54) and is usually named
.ptr.
OS/2 colour pointer (CP)
A colour OS/2 mouse pointer. It is laid out exactly like a colour icon, with the hotspot in the file header.
The file starts with CP (43 50), followed later by a second
CP file header for the colour image. It is usually named
.ptr.
Not described
Known, not yet covered
- Reference and viewer: the video codecs a bitmap header can name by FOURCC (MP42, MP43, DIV3, WMV1, WMV2, CVID, IV32, IV41, IV50, MSVC, CRAM). None has an official public specification, but open source decoders such as FFmpeg’s handle them. Pixels in these codecs are named and shown as labelled bytes.
- Viewer: some tag types of an embedded ICC profile are shown as bytes; open the profile itself to see it in full.
- Viewer: OS/2 2.x and the V4 and V5 headers are read, but have only been tested on files the site built, since no real ones were available.
Unknown
- Viewer: pixels with an unregistered FOURCC, which only their maker knows. Named and shown as labelled bytes.
Also used for
- Windows icon – Windows icons and cursors: one picture in several sizes, as bitmaps or PNGs.
Links
Reference
- Bitmap Storage – Microsoft’s description of the BMP file layout