|
|
BMP (Windows Bitmap) Image Format
Format name: Microsoft Windows Bitmap
File extension: .bmp, .dib, .rle, .rl8, .vga
BMP (an abbreviation derived from
"BitMaP") is a native bitmap format in Windows because it most closely
corresponds to the internal format used by Windows for storing its bitmap
arrays. BMP files most often have the .bmp extension, though sometimes the .rle
extension is used. The .rle extension usually indicates that the bitmap
information was compressed using one of the two RLE (run-length encoding)
methods available for BMP files. In a BMP
file, information about each pixel's color is encoded in 1, 4, 8, 16, or 24 bits
(bits per pixel). The number of bits per pixel, also called “color depth,”
determines the maximum number of colors in a picture. A color depth of 1 bit per
pixel means that only 2 colors can be used in the picture. A color depth of 24
bits per pixel limits the maximum number of colors by approx. 16.7 million.
Take a look at the picture, which shows the
structure of a typical BMP format file that contains a 256-color (8 bits
per pixel) image. The file consists of four basic sections: a bitmap file
header, a bitmap information header, a color table (palette), and pixel array
data. The bitmap file header contains information about the file, including the
starting address of the pixel array data. The bitmap information header contains
information about the image stored in the file, such as image height and width
(in pixels). The color table stores RGB (red, green, and blue) values used for
creating specific colors. If a graphics card doesn't support more than 256
colors, the software that reads and displays BMP files can programmatically set
such RGB values in the card's palette for precise color rendering.
The format of bitmap array data in a BMP file
depends on the number of bits used for encoding data on each pixel's color. If
the number of colors in an image is limited by 256, each pixel in the bitmap
array is described by one byte (8 bits). Such a pixel description doesn't
represent any RGB value but indicates the entry point in the BMP file's color
table. For example, if the first RGB value in the color table is R/G/B=255/0/0,
then pixel 0 in the bitmap array will represent the pure red color. Pixel values
are stored from left to right, usually starting from the bottom row of the
image. In a 256-color BMP file, the first byte of the bitmap array is an index
for the color of the leftmost pixel in the bottom row; the second byte, for the
color of the next pixel; and so on. If the number of bytes in each row is odd,
then an additional byte is added for each row to align the bitmap array data by
16-bit boundaries. Not all BMP files have
a structure like that shown in the picture. For example, BMP files with a color
depth of 16 or 24 bits per pixel do not use color tables because pixel values in
their bitmap arrays directly represent RGB values. Internal formats of file
sections may differ too. For instance, bitmap array data in some 16- or
256-color BMP files may be compressed using the RLE algorithm, with replaces
each sequence of repeated pixels by the number of pixels and their color value.
Windows also supports BMP files inherited from OS/2, which use formats of the
bitmap information header and palette different from those in Windows. |
|
|