Digital VideoLight and colorVideo and digital imagingImageData compressionImage processingVideoVideo imagingVideo formatsSee also :
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.