Il formato BMP O formato BMP BMP-Format Le format BMP El formato BMP

The BMP format

The BMP is one of the simplest formats. It was jointly developed by Microsoft and IBM, which explains why it is particularly widespread on Windows and OS/2 platforms. A BMP file is a bitmap file, i.e. a graphic image file, with pixels stored in the form of point table and managing the colours either as true colours or using an indexed palette. The BMP format has been studied in such a way as to obtain a bitmap that is independent of the peripheral display device (DIB, Device independent bitmap).

The structure of a bitmap file is the following:

File header

The file header provides information on the type of file (Bitmap) and its size as well as indicating where information concerning the image actually starts.

The header comprises four fields:

  • The signature (on 2 bytes), indicating that it is a BMP file, using two characters
    • BM, 424D in hexadecimal, indicates that it is a Windows Bitmap.
    • BA indicates that it is an OS/2 Bitmap.
    • CI indicates that it is an OS/2 colour icon.
    • CP indicates that it is an OS/2 colour pointer.
    • IC indicates that it an OS/2 icon.
    • PT indicates that it is an OS/2 pointer.
  • The total size of the file in bytes (coded on 4 bytes)
  • A reserved field (on 4 bytes)
  • The offset of the image (on 4 bytes), that is, it is the location of the start of the image information relative to the start of the file

Bitmap information header

The bitmap information header provides information on the image, particularly its dimensions and its colours.

The bitmap information header comprises four fields:

  • The size of the bitmap information header in bytes (coded on 4 bytes). The following hexadecimal values are possible according to the type of BMP format:
    • 28 for Windows 3.1x, 95, NT…
    • 0C for OS/2 1.x
    • F0 for OS/2 2.x
  • The width of the image (on 4 bytes), i.e. the number of pixels counted horizontally
  • The height of the image (on 4 bytes), i.e. the number of pixels counted vertically
  • The number of planes (on 2 bytes). This value is always 1
  • The colour model depth of (on 2 bytes), i.e. the number of bits used to code the colour. This value may be equal to 1, 4, 8,16, 24 or 32
  • The compression method (on 4 bytes). This value is 0 when the image is not compressed, or either 1, 2 or 3 depending on the type of compression used:
    • 1 for RLE coding of 8 bits per pixel
    • 2 for RLE coding of 4 bits per pixel
    • 3 for bitfield coding, meaning that the colour is coded by a triple mask represented by the palette
  • The total size of the image in bytes (on 4 bytes).
  • The horizontal resolution (on 4 bytes), i.e. the number of pixels per metre counted horizontally
  • The vertical resolution (on 4 bytes), i.e. the number of pixels per metre counted vertically
  • The number of palette colours (on 4 bytes)
  • The number of important palette colours (on 4 bytes). This field may be equal to 0 when all colours are important.

Image palette

The palette is optional. When a palette is defined, it contains 4 bytes successively for each of its entries, representing:

  • The blue component (on one byte)
  • The green component (on one byte)
  • The red component (on one byte)
  • A reserved field (on one byte)

Image coding

The coding of the image is done by successively writing the bits corresponding to each pixel, line by line, starting with the pixel in the bottom left-hand corner.

  • 2-Colour images use 1 bit per pixel, which means that one byte allows 8 pixels to be coded
  • 16-Colour images use 4 bits per pixel, which means that one byte allows 2 pixels to be coded
  • 256-Colour images use 8 bits per pixel, which means that one byte is needed to code each pixel
  • Real colour images use 24 bits per pixel, which means that 3 bytes are needed to code each pixel, taking care to respect the alternating colour order for blue, green and red.
Each image line must comprise a total number of bytes that is a multiple of 4; if this is not the case, the line must be completed with as many 0 as necessary in order to respect this criterion.

Last update on Thursday October 16, 2008 02:43:16 PM.This document entitled « The BMP format » from Kioskea (en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the licence, as this note appears clearly.
Best answers for « The BMP format » in :
PROBLEM 'Save Image As' Show PROBLEM "Save Image As" Solution It may happen that when you right click on an image "Save image as" the internet explorer allow you to save images in BMP format and no other possible format! Solution The solution is to...
Download Icon eXplorer and eXtractor Show Icon eXplorer and Extractor is a tool for exploring and extracting icons associated with files or file content. The extracted icons can be saved as files in ICO or BMP format. Advantage The program supports files: EXE, DLL, OCX, SCR, ICL, ICO,...
How to convert a video clip in .flv format and vice versa ShowIntroduction Here's a tip for you to simply convert a video clip of (almost) any format to .flv format. This trick will be useful for dealing with the video post or publish your video on the web. How to convert to and from the .flv...
Formatting Your Hard Drive ShowFormatting Your Hard Drive Formatting and installing your Hard drive using the installation CD ] A hard disk drive is a non-volatile device mainly for data storage. Usually faster than any other storage device, this essential...
Basic Excel Formulas ShowBasic Excel Formulas Below are some basic formulas for Microsoft excel: Basic formula : ADDITION cell A1 to A10 = sum (A1: A10) AVERAGE cell A1 to A10 = average (A1: A10) MAXIMUM cell A1 to A10 = max (A1: A10) MINIMUM...
Download Moo0 ImageTypeConverter ShowSome web applications or interfaces only support specific formats of images, wheareas you must convert your images into a particular format. For example, some blogs only supports JPG format but your image is GIG or BMP format. Moo0 ImageTypeConverter...
HTML forms ShowForms Interactive forms let web page authors give their pages interactive elements, such as for receiving messages from their readers, much like the reply cards found in some magazines. The reader enters information by filling in fields or clicking...
Spreadsheet - Formulas ShowIntroduction to Formulas The main use of a spreadsheet is to automate calculations, which means using cells to perform operations based on values in other cells. The spreadsheet recalculates all the values each time a change is made to the value of...
MKV format (Matroska Video) ShowMKV format The MKV format (Matroska Video) is an entirely free video format. More precisely, it is a container (hence the name Matroska, in reference to the Russian dolls contained within another) making it possible to contain video (DivX, Xvid,...