The BMP file format, or bitmap, is a raster graphics image file format used to store bitmap digital images, independently of the display device (such as a graphics adapter), especially on Microsoft Windows and OS/2
Device-independent bitmaps and the BMP file format
Microsoft has defined a particular representation of color bitmaps of different color depths, as an aid to exchanging bitmaps between devices and applications with a variety of internal representations. They called these device-independent bitmaps or DIBs, and the file format for them is called DIB file format or BMP image file format.
According to Microsoft support: <blockquote>A device-independent bitmap (DIB) is a format used to define device-independent bitmaps in various color resolutions. The main purpose of DIBs is to allow bitmaps to be moved from one device to another (hence, the device-independent part of the name). A DIB is an external format, in contrast to a device-dependent bitmap, which appears in the system as a bitmap object (created by an application...). A DIB is normally transported in metafiles (usually using the StretchDIBits() function), BMP files, and the Clipboard ( data format).</blockquote>
The following sections discuss the data stored in the BMP file or DIB in detail. This is the standard BMP file format.
|}
DIBs in memory
A bitmap image file loaded into memory becomes a DIB data structure – an important component of the Windows GDI API. The in-memory DIB data structure is almost the same as the BMP file format, but it does not contain the 14-byte bitmap file header and begins with the DIB header. For DIBs loaded in memory, the color table can also consist of 16-bit entries that constitute indexes to the currently realized palette (an additional level of indirection), instead of explicit RGB color definitions. In all cases, the pixel array must begin at a memory address that is a multiple of 4 bytes. In non-packed DIBs loaded in memory, the optional color profile data should be located immediately after the color table and before the gap1 and pixel array
<!-- sanity: floating diagram 1 must not overrun the next section -->
Bitmap file header
This block of bytes is at the start of the file and is used to identify the file. A typical application reads this block first to ensure that the file is actually a BMP file and that it is not damaged. The first 2 bytes of the BMP file format are the character "B" then the character "M" in ASCII encoding. All of the integer values are stored in little-endian format (i.e. least-significant byte first).
{| class="wikitable"
|-
! Offset (bytes)
! Size (bytes)
! Description
|-
| 0
| 2
| The header field used to identify the BMP and DIB file is <code>0x42 0x4D</code> in hexadecimal, same as <code>BM</code> in ASCII. The following entries are possible:
;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
|-
| 2
| 4
| The size of the BMP file in bytes
|-
| 6
| 2
| Reserved; actual value depends on the application that creates the image, if created manually can be 0
|-
| 8
| 2
| Reserved; actual value depends on the application that creates the image, if created manually can be 0
|-
| 10
| 4
| The offset, i.e. starting address, of the byte where the bitmap image data (pixel array) can be found.
|}
DIB header (bitmap information header)
This block of bytes tells the application detailed information about the image, which will be used to display the image on the screen. The block also matches the header used internally by Windows and OS/2 and has several different variants. All of them contain a dword (32-bit) field, specifying their size, so that an application can easily determine which header is used in the image. The reason that there are different headers is that Microsoft extended the DIB format several times. The new extended headers can be used with some GDI functions instead of the older ones, providing more functionality. Since the GDI supports a function for loading bitmap files, typical Windows applications use that functionality. One consequence of this is that for such applications, the BMP formats that they support match the formats supported by the Windows version being run. See the table below for more information.
{| class="wikitable"
|+ Windows and OS/2 bitmap headers
|-
! Size (bytes)
! Header name
! OS support
! Features
! Written by
|-
| align="right"| 12
| <br />
| Windows 2.0 or later<br />OS/2 1.x
of the BMP Suite.
|
|
|-
| align="right"| 40
|
| Windows NT, 3.1x or later
| Adds alpha channel bit mask.
| Microsoft
|-
| align="right"| 108
|
| Windows NT 4.0, 95 or later
| Adds color space type and gamma correction
|
|-
| align="right"| 124
|
| Windows NT 5.0, 98 or later
| Adds ICC color profiles
| GIMP
|}
{| class="wikitable"
! Offset (bytes)
! Size (bytes)
! OS/2 1.x
|-
| 14
| 4
| The size of this header (12 bytes)
|-
| 18
| 2
| The bitmap width in pixels (unsigned 16-bit)
|-
| 20
| 2
| The bitmap height in pixels (unsigned 16-bit)
|-
| 22
| 2
| The number of color planes, must be 1
|-
| 24
| 2
| The number of bits per pixel
|+ align="bottom" style="caption-side: bottom" |
|}
The Windows 2.x BITMAPCOREHEADER differs from the OS/2 1.x BITMAPCOREHEADER (shown in the table above) in the one detail that the image width and height fields are signed integers, not unsigned.
Versions after only add fields to the end of the header of the previous version.
For example: adds fields to , and adds fields to .
An integrated alpha channel has been introduced with the undocumented and with the documented (since Windows 95) and is used within Windows XP logon and theme system as well as Microsoft Office (since v2000); it is supported by some image editing software, such as Adobe Photoshop since version 7 and Adobe Flash since version MX 2004 (then known as Macromedia Flash). It is also supported by GIMP, Google Chrome, Microsoft PowerPoint and Microsoft Word.
For compatibility reasons, most applications use the older DIB headers for saving files. With OS/2 no longer supported after Windows 2000, for now the common Windows format is the header. See next table for its description. All values are stored as unsigned integers, unless explicitly noted.
{| class="wikitable"
! Offset (bytes)
! Size (bytes)
! Windows
|-
| 5
|
|
| <abbr title="Windows NT 4.0 & 95 or later">+</abbr>: PNG image for printing option in the biCompression member.</small>
The number of entries in the palette is either 2<sup>n</sup> (where n is the number of bits per pixel) or a smaller number specified in the header (in the OS/2 header format, only the full-size palette is supported). in and for 1bpp, 4bpp and 8bpp indexed color images, which indicates that the color table entries can also specify an alpha component using the [[RGBAX|8.8.8.[0-8].[0-8]]] format via the RGBQUAD.rgbReserved member. However, some versions of Microsoft's documentation disallow this feature by stating that the RGBQUAD.rgbReserved member "must be zero".
As mentioned above, the color table is normally not used when the pixels are in the 16-bit per pixel (16bpp) format (and higher); there are normally no color table entries in those bitmap image files. However, the Microsoft documentation (on the MSDN web site as of Nov. 16, 2010) specifies that for 16bpp (and higher), the color table can be present to store a list of colors intended for optimization on devices with limited color display capability, while it also specifies, that in such cases, no indexed palette entries are present in this Color Table. This may seem like a contradiction if no distinction is made between the mandatory palette entries and the optional color list.
Pixel storage
The bits representing the bitmap pixels are packed in rows (also known as strides or scan lines). The size of each row is rounded up to a multiple of 4 bytes (a 32-bit DWORD) by padding.
For images with height above 1, multiple padded rows are stored consecutively, forming a Pixel Array.
The total number of bytes necessary to store one row of pixels can be calculated as:
<math display="block">\text{RowSize} = \left\lceil\frac { \text{BitsPerPixel} \cdot \text{ImageWidth{32}\right\rceil \cdot 4 = \left\lfloor\frac { \text{BitsPerPixel} \cdot \text{ImageWidth}+31}{32}\right\rfloor \cdot 4,</math>
The total number of bytes necessary to store an array of pixels in an <var>n</var> bits per pixel (bpp) image, with 2<sup><var>n</var></sup> colors, can be calculated by accounting for the effect of rounding up the size of each row to a multiple of 4 bytes, as follows:
<math display="block">\text{PixelArraySize} = \text{RowSize} \cdot |\text{ImageHeight}|</math>
Pixel array (bitmap data)
The pixel array is a block of 32-bit DWORDs, that describes the image pixel by pixel. Usually pixels are stored "bottom-up", starting in the lower left corner, going from left to right, and then row by row from the bottom to the top of the image. GDI+ also permits 64 bits per pixel.
Padding bytes (not necessarily 0) must be appended to the end of the rows in order to bring up the length of the rows to a multiple of four bytes. When the pixel array is loaded into memory, each row must begin at a memory address that is a multiple of 4. This address/offset restriction is mandatory only for Pixel Arrays loaded in memory. For file storage purposes, only the size of each row must be a multiple of 4 bytes while the file offset can be arbitrary.). Each pixel value is a 2-bit index into a table of up to 4 colors.
- The 4-bit per pixel (4bpp) format supports 16 distinct colors and stores 2 pixels per 1 byte, the left-most pixel being in the more significant nibble.|448px|center
RGB video subtypes
The BITFIELD mechanism described above allows for the definition of tens of thousands of different pixel formats, however only several of them are used in practice,
!R.G.B.A.X
!RGB subtype
!R.G.B.A.X
!ARGB subtype
|-
| 8.8.8.0.8
| RGB32
| 8.8.8.8.0
| ARGB32
|-
|
|
| 10.10.10.2.0
| A2R10G10B10
|-
| 8.8.8.0.0
| RGB24
| 10.10.10.2.0
| A2B10G10R10
|-
| 5.6.5.0.0
| RGB565
| 4.4.4.4.0
| ARGB4444
|-
| 5.5.5.0.1
| RGB555
| 5.5.5.1.0
| ARGB1555
|}
{| class="wikitable" style="float:right"
|+ Bit fields for ten RGB bits
thumb|upright=0.6|[[#Example 1|Example 1 of a 2×2 pixel bitmap, with 24 bits/pixel encoding]]
Example 1
Following is an example of a 2×2 pixel, 24-bit bitmap (Windows DIB header ) with pixel format RGB24.
{| class="wikitable"
! Offset
(hex)
! Size
(bytes)
! Hex value
! Value
! Description
|-
| colspan="5" style="text-align: center;" | BMP Header
|-
| align="center" |00
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|42 4D
| style="padding: 0px 10px"|"BM"
| style="padding: 0px 10px"|ID field (<code>42 4D</code>)
|-
| align="center" |02
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|46 00 00 00
| style="padding: 0px 10px"|70 bytes (54+16)
| style="padding: 0px 10px"|Size of the BMP file (54 bytes header + 16 bytes data)
|-
| align="center" |06
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00
| style="padding: 0px 10px"|Unused
| style="padding: 0px 10px"|Application specific
|-
| align="center" |08
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00
| style="padding: 0px 10px"|Unused
| style="padding: 0px 10px"|Application specific
|-
| align="center" |0A
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|36 00 00 00
| style="padding: 0px 10px"|54 bytes (14+40)
| style="padding: 0px 10px"|Offset where the pixel array (bitmap data) can be found
|-
| colspan="5" style="text-align: center;" | DIB Header
|-
| align="center" |0E
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|28 00 00 00
| style="padding: 0px 10px"|40 bytes
| style="padding: 0px 10px"|Number of bytes in the DIB header (from this point)
|-
| align="center" |12
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|02 00 00 00
| style="padding: 0px 10px"|2 pixels (left to right order)
| style="padding: 0px 10px"|Width of the bitmap in pixels
|-
| align="center" |16
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|02 00 00 00
| style="padding: 0px 10px"|2 pixels (bottom to top order)
| style="padding: 0px 10px"|Height of the bitmap in pixels. Positive for bottom to top pixel order.
|-
| align="center" |1A
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|01 00
| style="padding: 0px 10px"|1 plane
| style="padding: 0px 10px"|Number of color planes being used
|-
| align="center" |1C
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|18 00
| style="padding: 0px 10px"|24 bits
| style="padding: 0px 10px"|Number of bits per pixel
|-
| align="center" |1E
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 00 00
| style="padding: 0px 10px"|0
| style="padding: 0px 10px"|BI_RGB, no pixel array compression used
|-
| align="center" |22
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|10 00 00 00
| style="padding: 0px 10px"|16 bytes
| style="padding: 0px 10px"|Size of the raw bitmap data (including padding)
|-
| align="center" |26
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|13 0B 00 00
| style="padding: 0px 10px"|2835 pixels/metre horizontal
| style="padding: 0px 10px" rowspan="2"|Print resolution of the image,<br />72 DPI × 39.3701 inches per metre yields 2834.6472
|-
| align="center" |2A
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|13 0B 00 00
| style="padding: 0px 10px"|2835 pixels/metre vertical
|-
| align="center" |2E
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 00 00
| style="padding: 0px 10px"|0 colors
| style="padding: 0px 10px"|Number of colors in the palette
|-
| align="center" |32
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 00 00
| style="padding: 0px 10px"|0 important colors
| style="padding: 0px 10px"|0 means all colors are important
|-
| colspan="5" align="center"|Start of pixel array (bitmap data)
|-
| align="center" |36
| align="center" |3
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 FF
| style="padding: 0px 10px"|0 0 255
| style="padding: 0px 10px"|Red, Pixel (x=0, y=1)
|-
| align="center" |39
| align="center" |3
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|FF FF FF
| style="padding: 0px 10px"|255 255 255
| style="padding: 0px 10px"|White, Pixel (x=1, y=1)
|-
| align="center" |3C
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00
| style="padding: 0px 10px"|0 0
| style="padding: 0px 10px"|Padding for 4 byte alignment (could be a value other than zero)
|-
| align="center" |3E
| align="center" |3
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|FF 00 00
| style="padding: 0px 10px"|255 0 0
| style="padding: 0px 10px"|Blue, Pixel (x=0, y=0)
|-
| align="center" |41
| align="center" |3
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 FF 00
| style="padding: 0px 10px"|0 255 0
| style="padding: 0px 10px"|Green, Pixel (x=1, y=0)
|-
| align="center" |44
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00
| style="padding: 0px 10px"|0 0
| style="padding: 0px 10px"|Padding for 4 byte alignment (could be a value other than zero)
|}
<imagemap>
File:Bmp_format2.svg|frame|right|Example 2 of a 4×2 pixel bitmap, with 32 bits/pixel encoding
rect 50 50 100 100 0,0: blue 0000FF FF
rect 100 50 150 100 0,1: green 00FF00 FF
rect 150 50 200 100 0,2: red FF00000 FF
rect 200 50 250 100 0,3: white FFFFFF FF
rect 50 100 100 150 1,0: blue 0000FF 7F, half transparent
rect 100 100 150 150 1,1: green 00FF00 7F, half transparent
rect 150 100 200 150 1,2: red FF0000 7F, half transparent
rect 200 100 250 150 1,3: white FFFFFF 7F, half transparent
default Netpbm#Transparency
desc top-left
</imagemap>
Example 2
Following is an example of a 4×2 pixel, 32-bit bitmap with opacity values in the alpha channel (Windows DIB Header ) with pixel format ARGB32.
{| class="wikitable"
! Offset
(hex)
! Size
(bytes)
! Hex value
! Value
! Description
|-
| colspan="5" style="text-align: center;" | BMP Header
|-
| align="center" |00
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|42 4D
| style="padding: 0px 10px"|"BM"
| style="padding: 0px 10px"|ID field (42h, 4Dh)
|-
| align="center" |02
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|9A 00 00 00
| style="padding: 0px 10px"|154 bytes (122+32)
| style="padding: 0px 10px"|Size of the BMP file
|-
| align="center" |06
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00
| style="padding: 0px 10px"|Unused
| style="padding: 0px 10px"|Application specific
|-
| align="center" |08
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00
| style="padding: 0px 10px"|Unused
| style="padding: 0px 10px"|Application specific
|-
| align="center" |0A
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|7A 00 00 00
| style="padding: 0px 10px"|122 bytes (14+108)
| style="padding: 0px 10px"|Offset where the pixel array (bitmap data) can be found
|-
| colspan="5" style="text-align: center;" | DIB Header
|-
| align="center" |0E
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|6C 00 00 00
| style="padding: 0px 10px"|108 bytes
| style="padding: 0px 10px"|Number of bytes in the DIB header (from this point)
|-
| align="center" |12
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|04 00 00 00
| style="padding: 0px 10px"|4 pixels (left to right order)
| style="padding: 0px 10px"|Width of the bitmap in pixels
|-
| align="center" |16
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|02 00 00 00
| style="padding: 0px 10px"|2 pixels (bottom to top order)
| style="padding: 0px 10px"|Height of the bitmap in pixels
|-
| align="center" |1A
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|01 00
| style="padding: 0px 10px"|1 plane
| style="padding: 0px 10px"|Number of color planes being used
|-
| align="center" |1C
| align="center" |2
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|20 00
| style="padding: 0px 10px"|32 bits
| style="padding: 0px 10px"|Number of bits per pixel
|-
| align="center" |1E
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|03 00 00 00
| style="padding: 0px 10px"|3
| style="padding: 0px 10px"|BI_BITFIELDS, no pixel array compression used
|-
| align="center" |22
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|20 00 00 00
| style="padding: 0px 10px"|32 bytes
| style="padding: 0px 10px"|Size of the raw bitmap data (including padding)
|-
| align="center" |26
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|13 0B 00 00
| style="padding: 0px 10px"|2835 pixels/metre horizontal
| style="padding: 0px 10px" rowspan="2"|Print resolution of the image,<br /> 72 DPI × 39.3701 inches per metre yields 2834.6472
|-
| align="center" |2A
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|13 0B 00 00
| style="padding: 0px 10px"|2835 pixels/metre vertical
|-
| align="center" |2E
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 00 00
| style="padding: 0px 10px"|0 colors
| style="padding: 0px 10px"|Number of colors in the palette
|-
| align="center" |32
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 00 00
| style="padding: 0px 10px"|0 important colors
| style="padding: 0px 10px"|0 means all colors are important
|-
| align="center" |36
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 FF 00
| style="padding: 0px 10px"|00FF0000 in big-endian
| style="padding: 0px 10px"|Red channel bit mask (valid because BI_BITFIELDS is specified)
|-
| align="center" |3A
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 FF 00 00
| style="padding: 0px 10px"|0000FF00 in big-endian
| style="padding: 0px 10px"|Green channel bit mask (valid because BI_BITFIELDS is specified)
|-
| align="center" |3E
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|FF 00 00 00
| style="padding: 0px 10px"|000000FF in big-endian
| style="padding: 0px 10px"|Blue channel bit mask (valid because BI_BITFIELDS is specified)
|-
| align="center" |42
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 00 FF
| style="padding: 0px 10px"|FF000000 in big-endian
| style="padding: 0px 10px"|Alpha channel bit mask
|-
| align="center" |46
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|20 6E 69 57
| style="padding: 0px 10px"|little-endian "<code>Win </code>"
| style="padding: 0px 10px"|LCS_WINDOWS_COLOR_SPACE
|-
| align="center" |4A
| align="center" |36
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00...00
| style="padding: 0px 10px"|CIEXYZTRIPLE Color Space endpoints
| style="padding: 0px 10px"|Unused for LCS "<code>Win </code>" or "<code>sRGB</code>"
|-
| align="center" |6E
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 00 00
| style="padding: 0px 10px"|0 Red Gamma
| style="padding: 0px 10px"|Unused for LCS "<code>Win </code>" or "<code>sRGB</code>"
|-
| align="center" |72
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 00 00
| style="padding: 0px 10px"|0 Green Gamma
| style="padding: 0px 10px"|Unused for LCS "<code>Win </code>" or "<code>sRGB</code>"
|-
| align="center" |76
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 00 00
| style="padding: 0px 10px"|0 Blue Gamma
| style="padding: 0px 10px"|Unused for LCS "<code>Win </code>" or "<code>sRGB</code>"
|-
| colspan="5" align="center"|Start of the Pixel Array (the bitmap Data)
|-
| align="center" |7A
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|FF 00 00 7F
| style="padding: 0px 10px"|255 0 0 127
| style="padding: 0px 10px"|Blue (Alpha: 127), Pixel (x=0, y=1)
|-
| align="center" |7E
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 FF 00 7F
| style="padding: 0px 10px"|0 255 0 127
| style="padding: 0px 10px"|Green (Alpha: 127), Pixel (x=1, y=1)
|-
| align="center" |82
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 FF 7F
| style="padding: 0px 10px"|0 0 255 127
| style="padding: 0px 10px"|Red (Alpha: 127), Pixel (x=2, y=1)
|-
| align="center" |86
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|FF FF FF 7F
| style="padding: 0px 10px"|255 255 255 127
| style="padding: 0px 10px"|White (Alpha: 127), Pixel (x=3, y=1)
|-
| align="center" |8A
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|FF 00 00 FF
| style="padding: 0px 10px"|255 0 0 255
| style="padding: 0px 10px"|Blue (Alpha: 255), Pixel (x=0, y=0)
|-
| align="center" |8E
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 FF 00 FF
| style="padding: 0px 10px"|0 255 0 255
| style="padding: 0px 10px"|Green (Alpha: 255), Pixel (x=1, y=0)
|-
| align="center" |92
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|00 00 FF FF
| style="padding: 0px 10px"|0 0 255 255
| style="padding: 0px 10px"|Red (Alpha: 255), Pixel (x=2, y=0)
|-
| align="center" |96
| align="center" |4
| style="padding: 0px 20px; white-space: nowrap; font-family:monospace;"|FF FF FF FF
| style="padding: 0px 10px"|255 255 255 255
| style="padding: 0px 10px"|White (Alpha: 255), Pixel (x=3, y=0)
|}
Note that the bitmap data starts with the lower left hand corner of the image.
Usage of BMP format
The simplicity of the BMP file format, and its widespread familiarity in Windows and elsewhere, as well as the fact that this format is relatively well documented and has an open format, makes BMP a very common format that image processing programs from many operating systems can read and write. ICO and CUR files contain bitmaps starting with a BITMAPINFOHEADER.
Many older graphical user interfaces used bitmaps in their built-in graphics subsystems; for example, the Microsoft Windows and OS/2 platforms' GDI subsystem, where the specific format used is the Windows and OS/2 bitmap file format, usually named with the file extension of <code>.BMP</code>.
While most BMP files have a relatively large file size due to lack of any compression (or generally low-ratio run-length encoding on palletized images), many BMP files can be considerably compressed with lossless data compression algorithms such as ZIP because they contain redundant data. Some formats, such as RAR, even include routines specifically targeted at efficient compression of such data.
Related formats
The X Window System uses a similar XBM format for black-and-white images, and XPM (pixelmap) for color images. There are also a variety of "raw" formats, which save raw data with no other information. The Portable Pixmap (PPM) and Truevision TGA formats also exist, but are less often used – or only for special purposes; for example, TGA can contain transparency information.
References
External links
- Bitmap File Structure, at digicamsoft.com
- An introduction to DIBs (Device Independent Bitmaps), at herdsoft.com
<!-- * BMP test images, at wvnet.edu -->
- A simple bitmap loader C++ class, at kalytta.com (A2R10G10B10 not supported)
- The BMP File Format, Part 1 By David Charlap at Dr. Dobb's journal of software tools (drdobbs.com), March 1995
