BITMAP IMAGE
(Redirected from Windows bitmap)
In computing, the bitmap image format is an image file format used for representing raster graphics on various operating systems. The Microsoft Windows and OS/2 platforms use bitmaps in their underlying graphics subsystem (GDI), with the file extension .BMP (or .DIB for ''device-independent bitmap'').
Images are generally stored with a color depth of 2 (1-bit), 16 (4-bit), 256 (8-bit), 65,536 (16-bit), or 16.7 million (24-bit) colors (the bits represent the bits per pixel). 8-bit images can also be greyscale instead of indexed color. An alpha channel (for transparency) may be stored in a separate file, where it is similar to a greyscale image. A 32-bit version with integrated alpha channel has been introduced with Windows XP and is used within its logon and theme system; it has yet to gain wide support in image editing software but has been supported in Adobe Photoshop since version 7 and Adobe Flash since version MX 2004 (then known as Macromedia Flash).
BMP files are usually not compressed, so they are typically much larger than compressed image file formats for the same image. For example, an 800×600 24-bit image will occupy almost 1.4 megabytes. For a more concrete example, the 1058×1058 , which occupies about 287.65 KB in the PNG format, takes about 3281.5 KB as a 24-bit BMP file.
As such, BMPs are generally unsuitable for transferring images on the Internet or other slow or capacity-limited media.
Depending on the color depth, a pixel in the picture will be stored using one or more bytes, which is determined by 'n/8' (n is the bit depth, since 1 byte equals 8 bits). The color of the pixel will be calculated (by the picture viewer, for example) based on the value of the bytes and the corresponding values read from the color palette. For more detailed information, see the section of bitmap file format below.
The approximate size for a n-bit (2n colors) bitmap in bytes can be calculated as:
'size of BMP file' , where height and width are given in pixels.
In the formula above, '54' is the size of the header of the bitmap file. And is the size of the color palette. Notice that this is an approximation, as for an n-bit bitmap image, although there can be maximum colors, a specific image may not use all of these colors. Since the color palette only defines the colors that are used by the image, the actual size of the color palette will be smaller than . Also, only 8-bit (or less) bitmaps use a palette. For 16-bit (or higher) bitmaps, omit the palette part from the size calculation:
'size of BMP file'
Due to effects of ''dword padding'' (if the number of bytes matching a horizontal line in the image does not form multiple dwords, i.e. divisible by 4, null bytes are added), the term describing the raw image size is approximated and the calculated size will be slightly different from the actual file size. For detailed information, see the sections on file format below.
A typical bitmap file usually contains the following blocks of data:
The following sections discuss the data stored in the bitmap file in details. Notice that this is the standard bitmap file format. Some bitmap images may be stored using a slightly different format, depending on the application that creates it. Also, not all fields are used; a value of 0 will be found in these unused fields.
This block of bytes is added before the bitmap format used internally by GDI and serves for identification. A typical application will read this block first to ensure that the file is actually a bitmap file and that it is not damaged.
This block of bytes tells the application detailed information about the image, which will be used to display the image on the screen. It also matches the header used internally by Windows and OS/2 and thus has several different variants. All of them start with a dword field, specifying their size in bytes, so that an application can easily determine the exact format used. The new header variants were introduced with new versions of Windows and OS/2, adding more functionality to the GDI. But since these extended headers are used only with few GDI functions, for compatibility with older programs most applications use the older headers when saving files. With OS/2 being obsolete, for now the only common format is the Windows 3.0 V3 header. See the table below for more information about the variants.
The V3 header:
The compression method field (bytes #30-33) can have the following values:[1]
The OS/2 V1 header is also popular:[2]
This block of bytes define the colors being used inside an indexed-color image. As stated above, the bitmap picture will be stored pixel by pixel. Each pixel is described by a value which will be stored using one or more bytes. Therefore, the purpose of the color palette in indexed-color bitmaps is to tell the application the actual color that each of these values corresponds to.
A typical bitmap file uses the RGB color model. In this model, a color is created by mixing different intensities (which can vary from 0 to 255) of red (R), green (G) and blue (B). A color is thus defined using the 3 values for R, G and B.
In the bitmap file implementation, the color palette contains many entries; the number of entries is the number of colors used in the picture. Each entry contains 4 bytes for a Windows bitmap and 3 bytes for an OS/2 bitmap. The first (and only for OS/2) 3 bytes store the values for blue, green and red respectively while the last one is unused and is filled with 0 by most applications. For each byte, a value of 0 indicates that the corresponding color (either red, green, or blue) is not used to create the current image color. On the other hand, a value of 255 indicates that maximum intensity is used.
As mentioned above, the color palette is not used when the bitmap is 16-bit or higher.
This block of bytes describes the image, pixel by pixel. Pixels are stored starting in the bottom left corner going from left to right and then row by row from the bottom to the top. Each pixel is described using one or more bytes. If the number of bytes matching a horizontal line in the image is not divisible by 4, the line is padded with null-bytes.
The simplicity of BMP and its widespread familiarity in MS Windows and elsewhere, as well as the fact that this format is well-documented and free of patents, makes it a very common format that image processing programs from many operating systems can read and write.
While bitmap images have a relatively large file size, most bitmap files compress very well with lossless data compression algorithms such as ZIP because they contain redundant 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 saves raw data with no other information. The Portable Pixmap file format (.PPM) and Truevision TGA (.TGA) formats also exist, but are less often used - or only for special purposes. for example, tga can contain transparency information.
Yet other formats store as "bitmaps" (as opposed to vector graphics), but use compression or color indices, and thus are not strictly considered true bitmaps.
★ Comparison of graphics file formats
★ Windows Picture and Fax Viewer
★ Microsoft Paint
1. The image size field can be 0 for BI_RGB bitmaps.
2. The OS/2 V1 bitmaps cannot be compressed and cannot be 16 or 32 bits/pixel.
★ Microsoft's MSDN page on Bitmaps
★ Bitmap Storage Explanation
★ Bitmap File Structure
★ Wotsit.org's entry on the BMP format
★ An introduction to DIBs (Device Independent Bitmaps)
★ Example BMP images with various internal formats
★ Turbo C++ 3.0 Code to open 16-color bitmaps in DOS
★ List of bitmap image file types
★ Bitmap entries at File-extensons.org
In computing, the bitmap image format is an image file format used for representing raster graphics on various operating systems. The Microsoft Windows and OS/2 platforms use bitmaps in their underlying graphics subsystem (GDI), with the file extension .BMP (or .DIB for ''device-independent bitmap'').
Images are generally stored with a color depth of 2 (1-bit), 16 (4-bit), 256 (8-bit), 65,536 (16-bit), or 16.7 million (24-bit) colors (the bits represent the bits per pixel). 8-bit images can also be greyscale instead of indexed color. An alpha channel (for transparency) may be stored in a separate file, where it is similar to a greyscale image. A 32-bit version with integrated alpha channel has been introduced with Windows XP and is used within its logon and theme system; it has yet to gain wide support in image editing software but has been supported in Adobe Photoshop since version 7 and Adobe Flash since version MX 2004 (then known as Macromedia Flash).
| Contents |
| Storage algorithm |
| Typical file format |
| Bitmap header |
| Bitmap information |
| Color palette |
| Bitmap data |
| Miscellaneous |
| Related formats |
| See also |
| Notes |
| External links |
Storage algorithm
BMP files are usually not compressed, so they are typically much larger than compressed image file formats for the same image. For example, an 800×600 24-bit image will occupy almost 1.4 megabytes. For a more concrete example, the 1058×1058 , which occupies about 287.65 KB in the PNG format, takes about 3281.5 KB as a 24-bit BMP file.
As such, BMPs are generally unsuitable for transferring images on the Internet or other slow or capacity-limited media.
Depending on the color depth, a pixel in the picture will be stored using one or more bytes, which is determined by 'n/8' (n is the bit depth, since 1 byte equals 8 bits). The color of the pixel will be calculated (by the picture viewer, for example) based on the value of the bytes and the corresponding values read from the color palette. For more detailed information, see the section of bitmap file format below.
The approximate size for a n-bit (2n colors) bitmap in bytes can be calculated as:
'size of BMP file' , where height and width are given in pixels.
In the formula above, '54' is the size of the header of the bitmap file. And is the size of the color palette. Notice that this is an approximation, as for an n-bit bitmap image, although there can be maximum colors, a specific image may not use all of these colors. Since the color palette only defines the colors that are used by the image, the actual size of the color palette will be smaller than . Also, only 8-bit (or less) bitmaps use a palette. For 16-bit (or higher) bitmaps, omit the palette part from the size calculation:
'size of BMP file'
Due to effects of ''dword padding'' (if the number of bytes matching a horizontal line in the image does not form multiple dwords, i.e. divisible by 4, null bytes are added), the term describing the raw image size is approximated and the calculated size will be slightly different from the actual file size. For detailed information, see the sections on file format below.
Typical file format
A typical bitmap file usually contains the following blocks of data:
| 'Bitmap Header' | Stores general information about the bitmap file. |
| 'Bitmap Information' | Stores detailed information about the bitmap image. |
| 'Color Palette' | Stores the definition of the colors being used for indexed color bitmaps. |
| 'Bitmap Data' | Stores the actual image, pixel by pixel. |
The following sections discuss the data stored in the bitmap file in details. Notice that this is the standard bitmap file format. Some bitmap images may be stored using a slightly different format, depending on the application that creates it. Also, not all fields are used; a value of 0 will be found in these unused fields.
Bitmap header
This block of bytes is added before the bitmap format used internally by GDI and serves for identification. A typical application will read this block first to ensure that the file is actually a bitmap file and that it is not damaged.
| Offset# | Size | Purpose |
|---|---|---|
| 0 | 2 | Store the magic number used to identify the bitmap file. Typical values for these 2 bytes are 0x42 0x4D (ASCII code points for 'B' and 'M'). |
| 2 | 4 | Store the size of the bitmap file using a dword. |
| 6 | 2 | Reserved. Actual value depends on the application that creates the image. |
| 8 | 2 | Reserved. Actual value depends on the application that creates the image. |
| 10 | 4 | Store the offset, i.e. starting address, of the byte where the bitmap data can be found. |
Bitmap information
This block of bytes tells the application detailed information about the image, which will be used to display the image on the screen. It also matches the header used internally by Windows and OS/2 and thus has several different variants. All of them start with a dword field, specifying their size in bytes, so that an application can easily determine the exact format used. The new header variants were introduced with new versions of Windows and OS/2, adding more functionality to the GDI. But since these extended headers are used only with few GDI functions, for compatibility with older programs most applications use the older headers when saving files. With OS/2 being obsolete, for now the only common format is the Windows 3.0 V3 header. See the table below for more information about the variants.
| Size | Header | Identified by | Supported by |
|---|---|---|---|
| 40 | Windows V3 | BITMAPINFOHEADER | All Windows OSes since Windows 3.0 |
| 12 | OS/2 V1 | BITMAPCOREHEADER | OS/2 and also all Windows OSes since Windows 3.0 |
| 64 | OS/2 V2 | ||
| 108 | Windows V4 | BITMAPV4HEADER | All Windows OSes since Windows 95/NT4 |
| 124 | Windows V5 | BITMAPV5HEADER | Windows 98/2000 and newer |
The V3 header:
| Offset # | Size | Purpose |
|---|---|---|
| 14 | 4 | Size of this header (40 bytes) |
| 18 | 4 | Store the bitmap width in pixels. |
| 22 | 4 | Store the bitmap height in pixels. |
| 26 | 2 | Store the number of color planes being used. Not often used. |
| 28 | 2 | Store the number of bits per pixel, which is the color depth of the image. Typical values are 1, 4, 8, 16, 24 and 32. |
| 30 | 4 | Define the compression method being used. See the next table for a list of possible values. |
| 34 | 4 | Store the image size. This is the size of the raw bitmap data (see below), and should not be confused with the file size. |
| 38 | 4 | Store the horizontal resolution of the image. (pixel per meter) |
| 42 | 4 | Store the vertical resolution of the image. (pixel per meter) |
| 46 | 4 | Store the number of colors used. |
| 50 | 4 | Store the number of important colors used. This field can be 0 when every color is important. |
The compression method field (bytes #30-33) can have the following values:[1]
| Value | Identified by | Compression method | Comments |
|---|---|---|---|
| 0 | BI_RGB | none | Most common |
| 1 | BI_RLE8 | RLE 8-bit/pixel | Can be used only with 8-bit/pixel bitmaps |
| 2 | BI_RLE4 | RLE 4-bit/pixel | Can be used only with 4-bit/pixel bitmaps |
| 3 | BI_BITFIELDS | Bit field | Can be used only with 16 and 32-bit/pixel bitmaps. |
| 4 | BI_JPEG | JPEG | The bitmap contains a JPEG image |
| 5 | BI_PNG | PNG | The bitmap contains a PNG image |
The OS/2 V1 header is also popular:[2]
| Offset | Size | Purpose |
|---|---|---|
| 14 | 4 | Size of this header (12 bytes) |
| 18 | 2 | Store the bitmap width in pixels. |
| 20 | 2 | Store the bitmap height in pixels. |
| 22 | 2 | Store the number of color planes being used. |
| 24 | 2 | Store the number of bits per pixel. Typical values are 1, 4, 8 and 24. |
Color palette
This block of bytes define the colors being used inside an indexed-color image. As stated above, the bitmap picture will be stored pixel by pixel. Each pixel is described by a value which will be stored using one or more bytes. Therefore, the purpose of the color palette in indexed-color bitmaps is to tell the application the actual color that each of these values corresponds to.
A typical bitmap file uses the RGB color model. In this model, a color is created by mixing different intensities (which can vary from 0 to 255) of red (R), green (G) and blue (B). A color is thus defined using the 3 values for R, G and B.
In the bitmap file implementation, the color palette contains many entries; the number of entries is the number of colors used in the picture. Each entry contains 4 bytes for a Windows bitmap and 3 bytes for an OS/2 bitmap. The first (and only for OS/2) 3 bytes store the values for blue, green and red respectively while the last one is unused and is filled with 0 by most applications. For each byte, a value of 0 indicates that the corresponding color (either red, green, or blue) is not used to create the current image color. On the other hand, a value of 255 indicates that maximum intensity is used.
As mentioned above, the color palette is not used when the bitmap is 16-bit or higher.
Bitmap data
This block of bytes describes the image, pixel by pixel. Pixels are stored starting in the bottom left corner going from left to right and then row by row from the bottom to the top. Each pixel is described using one or more bytes. If the number of bytes matching a horizontal line in the image is not divisible by 4, the line is padded with null-bytes.
Miscellaneous
The simplicity of BMP and its widespread familiarity in MS Windows and elsewhere, as well as the fact that this format is well-documented and free of patents, makes it a very common format that image processing programs from many operating systems can read and write.
While bitmap images have a relatively large file size, most bitmap files compress very well with lossless data compression algorithms such as ZIP because they contain redundant data.
Related formats
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 saves raw data with no other information. The Portable Pixmap file format (.PPM) and Truevision TGA (.TGA) formats also exist, but are less often used - or only for special purposes. for example, tga can contain transparency information.
Yet other formats store as "bitmaps" (as opposed to vector graphics), but use compression or color indices, and thus are not strictly considered true bitmaps.
See also
★ Comparison of graphics file formats
★ Windows Picture and Fax Viewer
★ Microsoft Paint
Notes
1. The image size field can be 0 for BI_RGB bitmaps.
2. The OS/2 V1 bitmaps cannot be compressed and cannot be 16 or 32 bits/pixel.
External links
★ Microsoft's MSDN page on Bitmaps
★ Bitmap Storage Explanation
★ Bitmap File Structure
★ Wotsit.org's entry on the BMP format
★ An introduction to DIBs (Device Independent Bitmaps)
★ Example BMP images with various internal formats
★ Turbo C++ 3.0 Code to open 16-color bitmaps in DOS
★ List of bitmap image file types
★ Bitmap entries at File-extensons.org
This article provided by Wikipedia. To edit the contents of this article, click here for original source.
psst.. try this: add to faves

العربية
中国
Français
Deutsch
Ελληνική
हिन्दी
Italiano
日本語
Português
Русский
Español