BMP file format

Template: Infobox file format / Maintenance / default missing template: Infobox file format / Maintenance / missing site

42 4D hex BM

Windows Bitmap ( " BMP" ) or device-independent bitmap (DIB ) is a two-dimensional raster graphics format that was developed for the operating systems Microsoft Windows and OS / 2 3.0, and introduced with Microsoft Windows, which was released in 1990. The file extension is. Bmp, rare. Dib.

Features

BMPs are available in three different versions. Most BMP files are in version 3; There are no previous versions. The later versions 4 and 5 are extremely rare.

Windows bitmaps ( version 3 ) allow color depths of 1, 4, 8, 16, 24 or 32 bpp ( bpp = bits per pixel, bits per pixel ), where at 16 and 32 do not bpp all bits must be utilized. Alpha channels, color correction and metadata are not supported. Windows bitmaps with RLE compression ( run length encoding) stored either uncompressed or lossless. This is a rather weak process, so that BMP files are considerably larger than other formats, such as PNG, and are hardly used for the Internet. For the BMP format is relatively simple. BMPs are widely used especially in the Windows environment; popular graphics software supports the format easily ( with the exception of the more exotic color depths 16 and 32 bpp ).

The image size is limited to 32767 × 32767 pixels.

File format (version 3)

BMP files consist of three parts: the header, the block of information and the image data ( see diagram right).

The following WORD denotes a 16 -bit unsigned integer, DWORD A 32 -bit unsigned integer and a LONG coded in two's complement 32- bit integer. BMP uses the little-endian convention.

Header

Information block

Bitmap Properties

The block of information begins with the structure that contains the bitmap properties:

  • If the value is positive, the bitmap is a so-called "bottom -up" bitmap ( the image data begins with the lowest and ending with the top screen line). This is the most common variant.
  • If the value is negative, the bitmap is a "top -down" bitmap ( the image data begins with the top and end with the bottom image line ).
  • 0 ( BI_RGB ): image data is uncompressed.
  • 1 ( BI_RLE8 ): Image data is run-length encoding for 8 bpp. Only allowed if biBitCount = 8 and biHeight positive.
  • 2 ( BI_RLE4 ): Image data is run-length encoding for 4 bpp. Only allowed if biBitCount = 4 and biHeight positive.
  • 3 ( BI_BITFIELDS ): image data is uncompressed and user- defined codes (using color masks ). Only allowed if biBitCount = 16 or 32; disuse.
  • If biCompression = BI_RGB: either 0 or the size of the image data in bytes.
  • Otherwise: size of the image data in bytes.
  • If biBitCount = 1: 0
  • If biBitCount = 4 or 8: the number of entries in the color table; 0 is the maximum number (2, 16, or 256).
  • Otherwise: The number of entries in the color table (0 = no color table). Although it is not necessary in this case, but a recommended color for the color quantization table can be specified.
  • If biBitCount = 1, 4 or 8: The number of all the colors used in the image; 0 means all colors in the color table.
  • Otherwise: If a color table is present and these all colors used in the image contains: their number.
  • Otherwise: 0

Color masks

If biCompression = BI_BITFIELDS, then follow three DWORD containing the bit masks for the red, green, and blue values ​​. Set bits mean that that bit is used for each color channel in the data of a pixel. The following conditions must be met:

  • Set bits must directly follow one after the other;
  • Bpp 16 for the set bits must be in the lower two bytes;
  • The bit masks for each color channel can not overlap each other.

Color Chart

  • If biClrUsed = 0: If biBitCount = 1, 4 or 8: Below is a color chart with 2biBitCount entries.
  • Otherwise: It follows no color table.

Each color entry is 4 bytes in size and contains one byte for blue, green and red component, as well as a set to 0 bytes ( in this order).

Image data

The image data starting at offset bfOffBits. The size of the image data is biWidth × × biHeight biBitCount / 8 when biCompression = BI_RGB, otherwise biSizeImage.

The image data is stored line by line. If biHeight is positive, the image data begins with the last and ending with the first image line, otherwise it is vice versa. The length of each line is a multiple of 4 bytes, if necessary, it is filled with null bytes.

The other format of the image data depends on the value of the field biCompression:

  • BI_BITFIELDS
  • BI_RGB
  • BI_RLE8 and BI_RLE4

Pros and Cons

Benefits of bitmaps include:

  • The simple creation of already existing in the computer's pixel data.
  • The efficient and simple access to the image data due to their grid-like arrangement.
  • A change of color information by changing a possibly existing range is possible without changing the image data itself.
  • The simple output to raster-based output devices such as monitors or printers.

A disadvantage is the large file size compared to compressed formats.

Versions 4 and 5

Microsoft has 98 newer versions 4 and 5 of the BMP format introduced with Windows 95 and Windows that allow alpha channels, and color correction, and can be used as a container format for PNG and JFIF files. However, these new formats are only very rarely found as standalone files and little support of applications; they find rather than internal format into Windows programs use.

Pictures of BMP file format

18037
de