BMP | Version compareBack to page history |
Become a member ofCnbeta encyclopediaCommunity. Join this Wiki Already a member? Sign in |
Version |
User |
Scope of changes |
Jun 28, 1:01 pm edt (current) |
Anonymous |
2 words added, 13 words deleted, 3 images added, 3 images deleted |
Jul 2, 9: 18 am EDT |
Vulcano |
251 words added, 3 images added |
Changeskey: additions deletionsbmp abbreviated from bitmap, also known as DiB (Abbreviated from Bitmap with BMP, also known as DiB (device-independent Bitmap) is irrelevant Bitmap) it is a bitmap format used internally by the Microsoft Windows Graphics subsystem (GDI). It is a simple graphical file format on the Microsoft Windows platform. The color depth of an image is usually 2 (1 bit), 16 (4 bits), 256 (8 bits), 65536 (16 bits), and 16.7 million (24 bits) color (bit indicates the data bit used by each vertex ). An 8-bit image can be an indexed color image or a grayscale image. A transparent alpha channel can also be stored in an independent file similar to a grayscale image. The 32-bit version with integrated alpha channel has already appeared with Windows XP, which is used in Windows logon and theme systems, but not many image editing software support.
//
[Edit]
Storage Algorithm
BMP files are usually not compressed, so they are generally much larger than the compressed image file format of the same image. For example, a 24-digit 800x600 occupies almost MB space. Therefore, they are generally not suitable for transmission over the Internet or other low-speed or capacity-limited media. Depending on the color depth, a pixel on an image can be expressed in one or more bytes.N/8Determined (n is the bit depth, and 1 byte contains 8 data bits ). The image browser calculates the color of the pixel Based on the byte ASCII value, and then reads the corresponding value from the color palette. For more information, see the following section on Bitmap files. The following formula can be used to calculate the approximate number of bytes of N-bit 2n bitmap:BMP file sizeThe height and width are the number of bins. Note that54It is the file header of the bitmap file and the size of the color palette. In addition, it should be noted that this is an approximate value. For N-bit bitmap images, although there may be a maximum of 2NA specific image may not use any of these colors. Since the color palette only defines the color used by the image, the actual color palette is smaller. If you want to know how these values are obtained, refer to the file format section below. Due to factors determined by the storage algorithm itself, the size calculated based on different image parameters may be slightly different from the actual file size.
[Edit]
Typical File Format
A typical bitmap file format usually contains the following data blocks:
- Bitmap header:Saves the overall information of a bitmap file.
- Bitmap information:Saves the detailed information of the bitmap image.
- Color Palette:Save the definition of the color used.
- Bitmap data:Saves the actual image of one pixel after another.
The following sections describe the data stored in the bitmap file in detail. Note that this is a standard bitmap file format. Other bitmap images may be slightly different based on the format used by the generated file application.
[Edit]
Bitmap header
This part is recognition information. A typical application will first read this part of data to ensure that it is indeed a bitmap file and is not damaged.
- Byte #1-2 stores the identifier of the bitmap file. The typical data of these two bytes isBM.
- Byte #3-6 use a DWORD to save the size of the bitmap file.
- Byte #7-10 is the reserved step. The actual values vary according to the application that generates them.
- Byte #11-14 stores the address offset of the bitmap data location, that is, the starting address.
[Edit]
Bitmap Information
This part tells the application the detailed information of the image, which will be used when the image is displayed on the screen, starting from the 15th bytes of the file.
- Bytes #15-18 define the size of the header. The value is 40-Windows V3, 12-OS/2 V1, 64-OS/2 v2, 108-Windows V4, and 124-Windows V5.
- Bytes #19-22 Save the bitmap width (expressed in pixels ).
- Bytes #23-26 Save the bitmap height (expressed in pixels ).
- Bytes #27-28 Save the number of colored planes used. Not frequently used.
- Byte #29-30 stores the digits of each pixel, which is the color depth of the image. Common values include 1, 4, 8, and 24.
- Bytes #31-34 define the compression algorithm used. The allowed values are 0, 1, 2, 3, 4, and 5.
0-no compression (also expressed in bi_rgb)
1-8 bits/pixel (also represented by bi_rle8)
2-The Travel length is encoded in 4 bits/pixel format (also expressed by bi_rle4)
3-bit field (also expressed in bi_bitfields)
4-JPEG image (also in bi_jpeg format)
5-PNG Image (also in bi_png format)
However, since most bitmap files are not compressed, the most common value is 0.
- Bytes #35-38 Save the image size. This is the size of the original (: EN: Raw) bitmap data. Do not confuse it with the file size.
- Bytes #39-42 Save the horizontal resolution of the image.
- Bytes #43-46 Save the portrait resolution of the image.
- Bytes #47-50 Save the number of colors used.
- Byte #51-54 the number of important colors used for saving. This value is equal to the number of colors when each color is important.
[Edit]
Color palette
This part defines the color used in the image. As mentioned above, bitmap images are stored one pixel after another, and each pixel is represented by one or more values. Therefore, the purpose of the palette is to tell the application the actual color of these values. A typical bitmap file uses an RGB color model. In this model, each color is composed of red (R), Green (G), and blue (B) of different intensity (from 0 to the maximum intensity), that is, each color can be defined by Red, green, and Blue values. In the implementation of Bitmap files, the color palette can contain many entries. The number of entries is the number of colors used in the image. Each entry contains four bytes: three of them indicate Red, green, and blue, and the fourth byte is not used (most applications set it to 0 ). For each byte, the value 0 indicates that the corresponding color is not used in the current image file, and the value 255 indicates that the color uses the maximum intensity.
[Edit]
Bitmap data
This part is represented in pixels one by one. Pixels are saved from bottom to top and left to right. Each pixel is represented by one or more bytes. If the number of bytes in the horizontal line of an image is not a multiple of 4, this line uses NULL bytes, usually ASCII code 0.
[Edit]
Others
Despite the large file size, bitmap files are simple, widely used in Microsoft Windows and other places, as well as excellent documentation standards in this format and without patent restrictions, this makes it the most common format for image processing programs in other operating systems to read and write. X Window System uses similar. XbmThe format represents a black-and-white image and. XPM(Pixelmap) Indicates the color image. There is also. RawFormat. It has no information except the original data. Other features include portable pixmap file format (. Ppm) And truevision TGA (. TGA), But they are rarely used or only for special purposes. Although other formats are saved as bitmaps (different from Vector images), they use data compression or color indexes, so they are not strictly bitmaps. Due to redundant information, many BMP files use lossless data compression algorithms similar to zip to achieve good compression performance.