BMP file format

Last updated
Windows Bitmap
Filename extension
.bmp, .dib
Internet media type image/bmp [1]
image/x-bmp
Type code 'BMP '
'BMPf'
'BMPp'
Uniform Type Identifier (UTI) com.microsoft.bmp
Developed by Microsoft Corporation
Type of format Raster graphics
Open format? OSP for WMF

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 [2] and OS/2 [3] operating systems.

Contents

The BMP file format is capable of storing two-dimensional digital images in various color depths, and optionally with data compression, alpha channels, and color profiles. The Windows Metafile (WMF) specification covers the BMP file format. [4]

Device-independent bitmaps and the BMP file format

BMPfileFormat.svg
Diagram 1 – The structure of the bitmap image file

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: [5]

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 (CF_DIB data format).

The following sections discuss the data stored in the BMP file or DIB in detail. This is the standard BMP file format. [5] Some applications create bitmap image files which are not compliant with the Microsoft documentation. Also, not all fields are used; a value of 0 will be found in these unused fields.

File structure

The bitmap image file consists of fixed-size structures (headers) as well as variable-sized structures appearing in a predetermined sequence. Many different versions of some of these structures can appear in the file, due to the long evolution of this file format.

Referring to the diagram 1, the bitmap file is composed of structures in the following order:

Structure nameOptionalSizePurposeComments
Bitmap file headerNo14 bytesTo store general information about the bitmap image fileNot needed after the file is loaded in memory
DIB headerNoFixed-size
(7 different versions exist)
To store detailed information about the bitmap image and define the pixel formatImmediately follows the Bitmap file header
Extra bit masksYes3 or 4 DWORDs [6]
(12 or 16 bytes)
To define the pixel formatPresent only in case the DIB header is the BITMAPINFOHEADER and the Compression Method member is set to either BI_BITFIELDS or BI_ALPHABITFIELDS
Color tableSemi-optionalVariable sizeTo define colors used by the bitmap image data (Pixel array)Mandatory for color depths ≤ 8 bits
Gap1YesVariable sizeStructure alignmentAn artifact of the File offset to Pixel array in the Bitmap file header
Pixel arrayNoVariable sizeTo define the actual values of the pixelsThe 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
Gap2YesVariable sizeStructure alignmentAn artifact of the ICC profile data offset field in the DIB header
ICC color profileYesVariable sizeTo define the color profile for color managementCan also contain a path to an external file containing the color profile. When loaded in memory as "non-packed DIB", it is located between the color table and Gap1. [7]

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 [8] (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 [7] (unlike in diag. 1).

When the size of gap1 and gap2 is zero, the in-memory DIB data structure is customarily referred to as "packed DIB" and can be referred to by a single pointer pointing to the beginning of the DIB header. In all cases, the pixel array must begin at a memory address that is a multiple of 4 bytes. In some cases it may be necessary to adjust the number of entries in the color table in order to force the memory address of the pixel array to a multiple of 4 bytes. [8] For "packed DIBs" loaded in memory, the optional color profile data should immediately follow the pixel array, as depicted in diag. 1 (with gap1=0 and gap2=0). [7]
"Packed DIBs" are required by Windows clipboard API functions as well as by some Windows patterned brush and resource functions. [9]

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).

Offset hexOffset decSizePurpose
0002 bytesThe header field used to identify the BMP and DIB file is 0x42 0x4D in hexadecimal, same as BM 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
0224 bytesThe size of the BMP file in bytes
0662 bytesReserved; actual value depends on the application that creates the image, if created manually can be 0
0882 bytesReserved; actual value depends on the application that creates the image, if created manually can be 0
0A104 bytesThe 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.

Windows and OS/2 bitmap headers
SizeHeader nameOS supportFeaturesWritten by
12BITMAPCOREHEADER
OS21XBITMAPHEADER
Windows 2.0 or later
OS/2 1.x [3]
64OS22XBITMAPHEADER OS/2 BITMAPCOREHEADER2Adds halftoning. Adds RLE and Huffman 1D compression.
16OS22XBITMAPHEADERThis variant of the previous header contains only the first 16 bytes and the remaining bytes are assumed to be zero values. [3]

An example of such a case is the graphic pal8os2v2-16.bmp [10] of the BMP Suite. [11]

40BITMAPINFOHEADER Windows NT, 3.1x or later [2] Extends bitmap width and height to 4 bytes. Adds 16 bpp and 32 bpp formats. Adds RLE compression.
52BITMAPV2INFOHEADERUndocumentedAdds RGB bit masks.Adobe Photoshop
56BITMAPV3INFOHEADERNot officially documented, but this documentation was posted on Adobe's forums, by an employee of Adobe with a statement that the standard was at one point in the past included in official MS documentation [12] Adds alpha channel bit mask.Adobe Photoshop
108BITMAPV4HEADER Windows NT 4.0, 95 or laterAdds color space type and gamma correction
124BITMAPV5HEADER Windows NT 5.0, 98 or laterAdds ICC color profiles The GIMP
Offset (hex)Offset (dec)Size (bytes)OS/2 1.x BITMAPCOREHEADER [3]
0E144The size of this header (12 bytes)
12182The bitmap width in pixels (unsigned 16-bit)
14202The bitmap height in pixels (unsigned 16-bit)
16222The number of color planes, must be 1
18242The number of bits per pixel
OS/2 1.x bitmaps are uncompressed and cannot be 16 or 32 bpp.

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. [13]

Versions after BITMAPINFOHEADER only add fields to the end of the header of the previous version. For example: BITMAPV2INFOHEADER adds fields to BITMAPINFOHEADER, and BITMAPV3INFOHEADER adds fields to BITMAPV2INFOHEADER.

An integrated alpha channel has been introduced with the undocumented BITMAPV3INFOHEADER and with the documented BITMAPV4HEADER (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 BITMAPINFOHEADER header. See next table for its description. All values are stored as unsigned integers, unless explicitly noted.

Offset (hex)Offset (dec)Size (bytes)Windows BITMAPINFOHEADER [2]
0E144the size of this header, in bytes (40)
12184the bitmap width in pixels (signed integer)
16224the bitmap height in pixels (signed integer)
1A262the number of color planes (must be 1)
1C282the number of bits per pixel, which is the color depth of the image. Typical values are 1, 4, 8, 16, 24 and 32.
1E304the compression method being used. See the next table for a list of possible values
22344the image size. This is the size of the raw bitmap data; a dummy 0 can be given for BI_RGB bitmaps.
26384the horizontal resolution of the image. (pixel per metre, signed integer)
2A424the vertical resolution of the image. (pixel per metre, signed integer)
2E464the number of colors in the color palette, or 0 to default to 2n
32504the number of important colors used, or 0 when every color is important; generally ignored

The compression method (offset 30) can be:

ValueIdentified byCompression methodComments
0BI_RGBnoneMost common
1BI_RLE8 RLE 8-bit/pixelCan be used only with 8-bit/pixel bitmaps
2BI_RLE4RLE 4-bit/pixelCan be used only with 4-bit/pixel bitmaps
3BI_BITFIELDSOS22XBITMAPHEADER: Huffman 1DBITMAPV2INFOHEADER: RGB bit field masks,
BITMAPV3INFOHEADER+: RGBA
4BI_JPEGOS22XBITMAPHEADER: RLE-24BITMAPV4INFOHEADER+: JPEG image for printing [14]
5BI_PNGBITMAPV4INFOHEADER+: PNG image for printing [14]
6BI_ALPHABITFIELDSRGBA bit field masksonly Windows CE 5.0 with .NET 4.0 or later
11BI_CMYKnoneonly Windows Metafile CMYK [4]
12BI_CMYKRLE8RLE-8only Windows Metafile CMYK
13BI_CMYKRLE4RLE-4only Windows Metafile CMYK

An OS/2 2.x OS22XBITMAPHEADER (BITMAPINFOHEADER2 in IBM's documentation) contains 24 additional bytes: [3]

Offset (hex)Offset (dec)Size (bytes)OS/2 OS22XBITMAPHEADER (BITMAPINFOHEADER2) [3]
36542An enumerated value specifying the units for the horizontal and vertical resolutions (offsets 38 and 42). The only defined value is 0, meaning pixels per metre
38562Padding. Ignored and should be zero
3A582An enumerated value indicating the direction in which the bits fill the bitmap. The only defined value is 0, meaning the origin is the lower-left corner. Bits fill from left-to-right, then bottom-to-top.

Note that Windows bitmaps (which don't include this field) can also specify an upper-left origin (bits fill from left-to-right, then top-to-bottom) by using a negative value for the image height

3C602An enumerated value indicating a halftoning algorithm that should be used when rendering the image.
40644Halftoning parameter 1 (see below)
44684Halftoning parameter 2 (see below)
48724An enumerated value indicating the color encoding for each entry in the color table. The only defined value is 0, indicating RGB.
4C764An application-defined identifier. Not used for image rendering

The halftoning algorithm (offset 60) can be:

ValueHalftoning algorithmComments
0noneMost common
1 Error diffusion Halftoning parameter 1 (offset 64) is the percentage of error damping. 100 indicates no damping. 0 indicates that errors are not diffused
2PANDA: Processing Algorithm for Noncoded Document AcquisitionHalftoning parameters 1 and 2 (offsets 64 and 68, respectively) represent the X and Y dimensions, in pixels, respectively, of the halftoning pattern used
3Super-circleHalftoning parameters 1 and 2 (offsets 64 and 68, respectively) represent the X and Y dimensions, in pixels, respectively, of the halftoning pattern used

Color table

The color table (palette) occurs in the BMP image file directly after the BMP file header, the DIB header, and after the optional three or four bitmasks if the BITMAPINFOHEADER header with BI_BITFIELDS (12 bytes) or BI_ALPHABITFIELDS (16 bytes) option is used. Therefore, its offset is the size of the BITMAPFILEHEADER plus the size of the DIB header (plus optional 12-16 bytes for the three or four bit masks).
Note: On Windows CE the BITMAPINFOHEADER header can be used with the BI_ALPHABITFIELDS [6] option in the biCompression member.

The number of entries in the palette is either 2n (where n is the number of bits per pixel) or a smaller number specified in the header (in the OS/2 BITMAPCOREHEADER header format, only the full-size palette is supported). [3] [5] In most cases, each entry in the color table occupies 4 bytes, in the order blue, green, red, 0x00 (see below for exceptions). This is indexed in the BITMAPINFOHEADER in the structure member biBitCount.

The color table is a block of bytes (a table) listing the colors used by the image. Each pixel in an indexed color image is described by a number of bits (1, 4, or 8) which is an index of a single color described by this table. The purpose of the color palette in indexed color bitmaps is to inform the application about the actual color that each of these index values corresponds to. The purpose of the color table in non-indexed (non-palettized) bitmaps is to list the colors used by the bitmap for the purposes of optimization on devices with limited color display capability and to facilitate future conversion to different pixel formats and palettization.

The colors in the color table are usually specified in the 4-byte per entry RGBA32 format. The color table used with the OS/2 BITMAPCOREHEADER uses the 3-byte per entry RGB24 format. [3] [5] For DIBs loaded in memory, the color table can optionally consist of 2-byte entries – these entries constitute indexes to the currently realized palette [8] instead of explicit RGB color definitions.

Microsoft does not disallow the presence of a valid alpha channel bit mask [15] in BITMAPV4HEADER and BITMAPV5HEADER for 1bpp, 4bpp and 8bpp indexed color images, which indicates that the color table entries can also specify an alpha component using the 8.8.8.[0-8].[0-8] format via the RGBQUAD.rgbReserved [16] 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 [17] ) 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. [18]

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:

ImageWidth is expressed in pixels. The equation above uses the floor and ceiling functions.

The total number of bytes necessary to store an array of pixels in an n bits per pixel (bpp) image, with 2n 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:

ImageHeight is expressed in pixels. The absolute value is necessary because ImageHeight is expressed as a negative number for top-down images.

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. [5] Unless BITMAPCOREHEADER is used, uncompressed Windows bitmaps also can be stored from the top to bottom, when the Image Height value is negative.

In the original OS/2 DIB, the only four legal values of color depth were 1, 4, 8, and 24 bits per pixel (bpp). [5] Contemporary DIB Headers allow pixel formats with 1, 2, 4, 8, 16, 24 and 32 bits per pixel (bpp). [19] GDI+ also permits 64 bits per pixel. [20]

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. [5] A 24-bit bitmap with Width=1, would have 3 bytes of data per row (blue, green, red) and 1 byte of padding, while Width=2 would have 6 bytes of data and 2 bytes of padding, Width=3 would have 9 bytes of data and 3 bytes of padding, and Width=4 would have 12 bytes of data and no padding.

Compression

  • Indexed color images may be compressed with 4-bit or 8-bit RLE or Huffman 1D algorithm.
  • OS/2 BITMAPCOREHEADER2 24bpp images may be compressed with the 24-bit RLE algorithm.
  • The 16bpp and 32bpp images are always stored uncompressed.
  • Note that images in all color depths can be stored without compression if so desired.

Pixel format

  • The 1-bit per pixel (1bpp) format supports 2 distinct colors, (for example: black and white). The pixel values are stored in each bit, with the first (left-most) pixel in the most-significant bit of the first byte. [5] Each bit is an index into a table of 2 colors. An unset bit will refer to the first color table entry, and a set bit will refer to the last (second) color table entry.
  • The 2-bit per pixel (2bpp) format supports 4 distinct colors and stores 4 pixels per 1 byte, the left-most pixel being in the two most significant bits (Windows CE only: [21] ). 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. [5] Each pixel value is a 4-bit index into a table of up to 16 colors.
  • The 8-bit per pixel (8bpp) format supports 256 distinct colors and stores 1 pixel per 1 byte. Each byte is an index into a table of up to 256 colors.
  • The 16-bit per pixel (16bpp) format supports 65536 distinct colors and stores 1 pixel per 2-byte WORD. Each WORD can define the alpha, red, green and blue samples of the pixel.
  • The 24-bit per pixel (24bpp) format supports 16,777,216 distinct colors and stores 1 pixel value per 3 bytes. Each pixel value defines the red, green and blue samples of the pixel (8.8.8.0.0 in RGBAX notation). Specifically, in the order: blue, green and red (8 bits per each sample). [5]
  • The 32-bit per pixel (32bpp) format supports 4,294,967,296 distinct colors and stores 1 pixel per 4-byte DWORD. Each DWORD can define the alpha, red, green and blue samples of the pixel.

In order to resolve the ambiguity of which bits define which samples, the DIB headers provide certain defaults as well as specific BITFIELDS, which are bit masks that define the membership of particular group of bits in a pixel to a particular channel. The following diagram defines this mechanism:

BitfieldsSLN.svg
Diag. 2 – The BITFIELDS mechanism for a 32-bit pixel depicted in RGBAX sample length notation

The sample fields defined by the BITFIELDS bit masks have to be contiguous and non-overlapping, but the order of the sample fields is arbitrary. The most ubiquitous field order is: Alpha, Blue, Green, Red (MSB to LSB). The red, green and blue bit masks are valid only when the Compression member of the DIB header is set to BI_BITFIELDS. The alpha bit mask is valid whenever it is present in the DIB header or when the Compression member of the DIB header is set to BI_ALPHABITFIELDS [6] (Windows CE only).

SLNotation44440.svg
Diag. 3 – The pixel format with an alpha channel for a 16-bit pixel (in RGBAX sample Length notation) actually generated by Adobe Photoshop [22]
AllBMPformats.png
All of the possible pixel formats in a DIB

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, [22] all palettized formats RGB8, RGB4, and RGB1 (marked in yellow in the table above, defined in dshow.h.MEDIASUBTYPE names):

Uncompressed RGB Video Subtypes [23]
R.G.B.A.XRGB subtypeR.G.B.A.XARGB subtype
8.8.8.0.8RGB328.8.8.8.0ARGB32
10.10.10.2.0A2R10G10B10
8.8.8.0.0RGB2410.10.10.2.0A2B10G10R10
5.6.5.0.0RGB5654.4.4.4.0ARGB4444
5.5.5.0.1RGB5555.5.5.1.0ARGB1555
Bit fields for ten RGB bits [23]
Bit fieldOffsetBits A2R10G10B10Bits A2B10G10R10
Red36h00 00 F0 3FLE:3FF0000020...29FF 03 00 00LE:000003FF 0... 9
Green3Ah00 FC 0F 00LE:000FFC0010...1900 FC 0F 00LE:000FFC0010...19
Blue3EhFF 03 00 00LE:000003FF 0... 900 00 F0 3FLE:3FF0000020...29
Alpha42h00 00 00 C0LE:C000000030...3100 00 00 C0LE:C000000030...31

In version 2.1.4 FFmpeg supported (in its own terminology) the BMP pixel formats bgra, bgr24, rgb565le, rgb555le, rgb444le, rgb8, bgr8, rgb4_byte, bgr4_byte, gray, pal8, and monob; i.e., bgra was the only supported pixel format with transparency. [24]

Example 1 of a 2x2 pixel bitmap, with 24 bits/pixel encoding Bmp format.svg
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 BITMAPINFOHEADER) with pixel format RGB24.

OffsetSizeHex valueValueDescription
BMP Header
0h242 4D"BM"ID field (42h, 4Dh)
2h446 00 00 0070 bytes (54+16)Size of the BMP file (54 bytes header + 16 bytes data)
6h200 00UnusedApplication specific
8h200 00UnusedApplication specific
Ah436 00 00 0054 bytes (14+40)Offset where the pixel array (bitmap data) can be found
DIB Header
Eh428 00 00 0040 bytesNumber of bytes in the DIB header (from this point)
12h402 00 00 002 pixels (left to right order)Width of the bitmap in pixels
16h402 00 00 002 pixels (bottom to top order)Height of the bitmap in pixels. Positive for bottom to top pixel order.
1Ah201 001 planeNumber of color planes being used
1Ch218 0024 bitsNumber of bits per pixel
1Eh400 00 00 000BI_RGB, no pixel array compression used
22h410 00 00 0016 bytesSize of the raw bitmap data (including padding)
26h413 0B 00 002835 pixels/metre horizontalPrint resolution of the image,
72 DPI × 39.3701 inches per metre yields 2834.6472
2Ah413 0B 00 002835 pixels/metre vertical
2Eh400 00 00 000 colorsNumber of colors in the palette
32h400 00 00 000 important colors0 means all colors are important
Start of pixel array (bitmap data)
36h300 00 FF0 0 255Red, Pixel (x=0, y=1)
39h3FF FF FF255 255 255White, Pixel (x=1, y=1)
3Ch200 000 0Padding for 4 byte alignment (could be a value other than zero)
3Eh3FF 00 00255 0 0Blue, Pixel (x=0, y=0)
41h300 FF 000 255 0Green, Pixel (x=1, y=0)
44h200 000 0Padding for 4 byte alignment (could be a value other than zero)
Example 2 of a 4x2 pixel bitmap, with 32 bits/pixel encoding Bmp format2.svg 0,0: blue 0000FF FF0,1: green 00FF00 FF0,2: red FF00000 FF0,3: white FFFFFF FF1,0: blue 0000FF 7F, half transparent1,1: green 00FF00 7F, half transparent1,2: red FF0000 7F, half transparent1,3: white FFFFFF 7F, half transparent
Example 2 of a 4×2 pixel bitmap, with 32 bits/pixel encoding

Example 2

Following is an example of a 4×2 pixel, 32-bit bitmap with opacity values in the alpha channel (Windows DIB Header BITMAPV4HEADER) with pixel format ARGB32.

OffsetSizeHex valueValueDescription
BMP Header
0h242 4D"BM"ID field (42h, 4Dh)
2h49A 00 00 00154 bytes (122+32)Size of the BMP file
6h200 00UnusedApplication specific
8h200 00UnusedApplication specific
Ah47A 00 00 00122 bytes (14+108)Offset where the pixel array (bitmap data) can be found
DIB Header
Eh46C 00 00 00108 bytesNumber of bytes in the DIB header (from this point)
12h404 00 00 004 pixels (left to right order)Width of the bitmap in pixels
16h402 00 00 002 pixels (bottom to top order)Height of the bitmap in pixels
1Ah201 001 planeNumber of color planes being used
1Ch220 0032 bitsNumber of bits per pixel
1Eh403 00 00 003BI_BITFIELDS, no pixel array compression used
22h420 00 00 0032 bytesSize of the raw bitmap data (including padding)
26h413 0B 00 002835 pixels/metre horizontalPrint resolution of the image,
72 DPI × 39.3701 inches per metre yields 2834.6472
2Ah413 0B 00 002835 pixels/metre vertical
2Eh400 00 00 000 colorsNumber of colors in the palette
32h400 00 00 000 important colors0 means all colors are important
36h400 00 FF 0000FF0000 in big-endianRed channel bit mask (valid because BI_BITFIELDS is specified)
3Ah400 FF 00 000000FF00 in big-endianGreen channel bit mask (valid because BI_BITFIELDS is specified)
3Eh4FF 00 00 00000000FF in big-endianBlue channel bit mask (valid because BI_BITFIELDS is specified)
42h400 00 00 FFFF000000 in big-endianAlpha channel bit mask
46h420 6E 69 57little-endian "Win "LCS_WINDOWS_COLOR_SPACE
4Ah24h24h* 00...00CIEXYZTRIPLE Color Space endpointsUnused for LCS "Win " or "sRGB"
6Eh400 00 00 000 Red GammaUnused for LCS "Win " or "sRGB"
72h400 00 00 000 Green GammaUnused for LCS "Win " or "sRGB"
76h400 00 00 000 Blue GammaUnused for LCS "Win " or "sRGB"
Start of the Pixel Array (the bitmap Data)
7Ah4FF 00 00 7F255 0 0 127Blue (Alpha: 127), Pixel (x=0, y=1)
7Eh400 FF 00 7F0 255 0 127Green (Alpha: 127), Pixel (x=1, y=1)
82h400 00 FF 7F0 0 255 127Red (Alpha: 127), Pixel (x=2, y=1)
86h4FF FF FF 7F255 255 255 127White (Alpha: 127), Pixel (x=3, y=1)
8Ah4FF 00 00 FF255 0 0 255Blue (Alpha: 255), Pixel (x=0, y=0)
8Eh400 FF 00 FF0 255 0 255Green (Alpha: 255), Pixel (x=1, y=0)
92h400 00 FF FF0 0 255 255Red (Alpha: 255), Pixel (x=2, y=0)
96h4FF FF FF FF255 255 255 255White (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; [25] 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 .BMP. [26]

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.

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.

Related Research Articles

<span class="mw-page-title-main">GIF</span> Bitmap image file format family

The Graphics Interchange Format is a bitmap image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released on June 15, 1987.

<span class="mw-page-title-main">PNG</span> Family of lossless compression file formats for image files

Portable Network Graphics is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange Format (GIF)—unofficially, the initials PNG stood for the recursive acronym "PNG's not GIF".

PCX, standing for PiCture eXchange, is an image file format developed by the now-defunct ZSoft Corporation of Marietta, Georgia, United States. It was the native file format for PC Paintbrush and became one of the first widely accepted DOS imaging standards, although it has since been succeeded by more sophisticated image formats, such as BMP, JPEG, and PNG. PCX files commonly store palette-indexed images ranging from 2 or 4 colors to 16 and 256 colors, although the format has been extended to record true-color (24-bit) images as well.

<span class="mw-page-title-main">Raster graphics</span> Matrix-based data structure

In computer graphics and digital photography, a raster graphic represents a two-dimensional picture as a rectangular matrix or grid of pixels, viewable via a computer display, paper, or other display medium. A raster is technically characterized by the width and height of the image in pixels and by the number of bits per pixel. Raster images are stored in image files with varying dissemination, production, generation, and acquisition formats.

Tag Image File Format or Tagged Image File Format, commonly known by the abbreviations TIFF or TIF, is an image file format for storing raster graphics images, popular among graphic artists, the publishing industry, and photographers. TIFF is widely supported by scanning, faxing, word processing, optical character recognition, image manipulation, desktop publishing, and page-layout applications. The format was created by the Aldus Corporation for use in desktop publishing. It published the latest version 6.0 in 1992, subsequently updated with an Adobe Systems copyright after the latter acquired Aldus in 1994. Several Aldus or Adobe technical notes have been published with minor extensions to the format, and several specifications have been based on TIFF 6.0, including TIFF/EP, TIFF/IT, TIFF-F and TIFF-FX.

<span class="mw-page-title-main">ILBM</span> File format

Interleaved Bitmap (ILBM) is an image file format conforming to the Interchange File Format (IFF) standard. The format originated on the Amiga platform, and on IBM-compatible systems, files in this format or the related PBM format are typically encountered in games from late 1980s and early 1990s that were either Amiga ports or had their graphical assets designed on Amiga machines.

Truevision TGA, often referred to as TARGA, is a raster graphics file format created by Truevision Inc.. It was the native format of TARGA and VISTA boards, which were the first graphic cards for IBM-compatible PCs to support Highcolor/truecolor display. This family of graphic cards was intended for professional computer image synthesis and video editing with PCs; for this reason, usual resolutions of TGA image files match those of the NTSC and PAL video formats.

<span class="mw-page-title-main">Microsoft Paint</span> Raster graphics editor

Paint is a simple raster graphics editor that has been included with all versions of Microsoft Windows. The program opens, modifies and saves image files in Windows bitmap (BMP), JPEG, GIF, PNG, and single-page TIFF formats. The program can be in color mode or two-color black-and-white, but there is no grayscale mode. For its simplicity and wide availability, it rapidly became one of the most used Windows applications, introducing many to painting on a computer for the first time.

Color depth or colour depth, also known as bit depth, is either the number of bits used to indicate the color of a single pixel, or the number of bits used for each color component of a single pixel. When referring to a pixel, the concept can be defined as bits per pixel (bpp). When referring to a color component, the concept can be defined as bits per component, bits per channel, bits per color, and also bits per pixel component, bits per color channel or bits per sample (bps). Modern standards tend to use bits per component, but historical lower-depth systems used bits per pixel more often.

Text mode is a computer display mode in which content is internally represented on a computer screen in terms of characters rather than individual pixels. Typically, the screen consists of a uniform rectangular grid of character cells, each of which contains one of the characters of a character set; at the same time, contrasted to graphics mode or other kinds of computer graphics modes.

<span class="mw-page-title-main">Smacker video</span> Digital video file format

Smacker video is a video file format developed by Epic Games Tools, and primarily used for full-motion video in video games. Smacker uses an adaptive 8-bit RGB palette. RAD's format for video at higher color depths is Bink Video. The Smacker format specifies a container format, a video compression format, and an audio compression format. Since its release in 1994, Smacker has been used in over 2300 games. Blizzard used this format for the cinematic videos seen in its games Warcraft II, StarCraft and Diablo I.

<span class="mw-page-title-main">X BitMap</span> File format

In computer graphics, the X Window System used X BitMap (XBM), a plain text binary image format, for storing cursor and icon bitmaps used in the X GUI. The XBM format is superseded by XPM, which first appeared for X11 in 1989.

Netpbm is an open-source package of graphics programs and a programming library. It is used mainly in the Unix world, where one can find it included in all major open-source operating system distributions, but also works on Microsoft Windows, macOS, and other operating systems.

The ICO file format is an image file format for computer icons in Microsoft Windows. ICO files contain one or more small images at multiple sizes and color depths, such that they may be scaled appropriately. In Windows, all executables that display an icon to the user, on the desktop, in the Start Menu, or in file Explorer, must carry the icon in ICO format.

An image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be compressed or uncompressed. If the data is compressed, it may be done so using lossy compression or lossless compression. For graphic design applications, vector formats are often used. Some image file formats support transparency.

<span class="mw-page-title-main">Palette (computing)</span> In computer graphics, a finite set of available colors

In computer graphics, a palette is the set of available colors from which an image can be made. In some systems, the palette is fixed by the hardware design, and in others it is dynamic, typically implemented via a color lookup table (CLUT), a correspondence table in which selected colors from a certain color space's color reproduction range are assigned an index, by which they can be referenced. By referencing the colors via an index, which takes less information than needed to describe the actual colors in the color space, this technique aims to reduce data usage, including processing, transfer bandwidth, RAM usage, and storage. Images in which colors are indicated by references to a CLUT are called indexed color images.

In computing, indexed color is a technique to manage digital images' colors in a limited fashion, in order to save computer memory and file storage, while speeding up display refresh and file transfers. It is a form of vector quantization compression.

The Apple Icon Image format (.icns) is an icon format used in Apple Inc.'s macOS. It supports icons of 16 × 16, 32 × 32, 48 × 48, 128 × 128, 256 × 256, 512 × 512 points at 1x and 2x scale, with both 1- and 8-bit alpha channels and multiple image states. The fixed-size icons can be scaled by the operating system and displayed at any intermediate size.

In computing, a bitmap is a mapping from some domain to bits. It is also called a bit array or bitmap index.

The Quite OK Image Format (QOI) is a specification for lossless image compression of 24-bit or 32-bit color raster (bitmapped) images, invented by Dominic Szablewski and first announced on 24 November 2021.

References

  1. "IANA Considerations". Windows Image Media Types. sec. 5. doi: 10.17487/RFC7903 . RFC 7903.
  2. 1 2 3 James D. Murray; William vanRyper (April 1996). Encyclopedia of Graphics File Formats (Second ed.). O'Reilly. bmp. ISBN   1-56592-161-5 . Retrieved 2014-03-07.
  3. 1 2 3 4 5 6 7 8 James D. Murray; William vanRyper (April 1996). Encyclopedia of Graphics File Formats (Second ed.). O'Reilly. os2bmp. ISBN   1-56592-161-5 . Retrieved 2014-03-07.
  4. 1 2 "[MS-WMF]: Windows Metafile Format". MSDN. 2014-02-13. Retrieved 2014-03-12.
  5. 1 2 3 4 5 6 7 8 9 10 "DIBs and Their Uses". Microsoft Help and Support. Retrieved 2015-05-14.
  6. 1 2 3 MSDN - BITMAPINFOHEADER (Windows CE 5.0): BI_ALPHABITFIELDS in biCompression member
  7. 1 2 3 MSDN Bitmap Header Types
  8. 1 2 3 MSDN BITMAPINFO Structure
  9. Feng Yuan - Windows graphics programming: Win32 GDI and DirectDraw: Packed Device-Independent Bitmap (CreateDIBPatternBrush, CreateDIBPatternBrushPt, FindResource, LoadResource, LockResource)
  10. Summers, Jason (2015-10-30). "pal8os2v2-16.bmp" . Retrieved 2016-07-06.
  11. Summers, Jason (2015-10-30). "BMP Suite" . Retrieved 2016-07-06.
  12. Cox, Chris (2010-11-15). "Invalid BMP Format with Alpha channel". Photoshop Windows forum. Adobe. Archived from the original on 2015-01-27. Retrieved 2016-05-22.
  13. "Microsoft Windows Bitmap: Summary from the Encyclopedia of Graphics File Formats".
  14. 1 2 "JPEG and PNG Extensions for Specific Bitmap Functions and Structures".
  15. MSDN – BITMAPV4HEADER: The member bV4AlphaMask
  16. MSDN – RGBQUAD: rgbReserved member
  17. see note under biClrUsed MSDN BITMAPINFOHEADER
  18. "Image Stride - Win32 apps". learn.microsoft.com.
  19. MSDN - BITMAPINFOHEADER: The member biBitCount
  20. "Types of Bitmaps". MSDN. 2012-06-03. Retrieved 2014-03-16.
  21. MSDN: Windows CE - BITMAPINFOHEADER Structure
  22. 1 2 Adobe Photoshop: BMP Format Archived 2011-09-22 at the Wayback Machine
  23. 1 2 "Uncompressed RGB Video Subtypes". dshow.h. MSDN . Retrieved 2014-03-11.
  24. "Image Formats". FFmpeg General Documentation. 2014. Retrieved 2014-02-23.
  25. Julian Smart; Stefan Csomor & Kevin Hock (2006). Cross-Platform GUI Programming with Wxwidgets. Prentice Hall. ISBN   0-13-147381-6.
  26. "Bitmap Image File (BMP), Version 5". Digital Preservation. Library of Congress. 2014-01-08. Retrieved 2014-03-11.