Bitmap format Analysis

Source: Internet
Author: User

Let's take a look at the bitmap file (*. BMP) format. The bitmap file is divided into the following 3 parts:
Block name Corresponds to the Windows fabric Body Definition Size (Byte)
File Information Header Bitmapfileheader 14
Bitmap Information Header Bitmapinfoheader 40
RGB Color Array byte* Determined by the image's long and wide dimensions
1.file Information header Bitmapfileheader The structure is defined as follows:typedef struct TAGBITMAPFILEHEADER {/* BMFH * /UINT Bftype;
DWORD bfsize;
UINT bfReserved1;
UINT BfReserved2;
DWORD bfoffbits;} Bitmapfileheader;among them:
bftype < Span style= "font-size:medium;" > Description of the file type, which must be 0x4d42, which is the character ' BM '.
bfsize
bfreserved1 reserved, must be set to 0
bfreserved2 < Span style= "font-size:medium;" > reserved, must be set to 0
bfoffbits
2. Bitmap Information Header Bitmapinfoheader The structure is defined as follows:typedef struct TAGBITMAPINFOHEADER {/* BMIH * /DWORD bisize;
LONG biwidth;
LONG biheight;
WORD biplanes;
WORD biBitCount;
DWORD bicompression;
DWORD biSizeImage;
LONG Bixpelspermeter;
LONG Biypelspermeter;
DWORD biclrused;
DWORD biclrimportant;} bitmapinfoheader;among them:
Bisize Describes the number of words required for the bitmapinfoheader structure.
Biwidth Indicates the width of the image, in pixels.
Biheight Indicates the height of the image, in pixels. Note: This value, in addition to describing the height of the image, has another use to indicate whether the image is a backward bitmap or a forward bitmap. If the value is a positive number, the image is inverted, and if the value is a negative number, the image is positive. Most BMP files are inverted bitmaps, that is, when the height value is a positive number.
biplanes Describes the number of bits for the target device, and its value will always be set to 1.
biBitCount Indicates the number of bits/pixels, with values of 1, 4, 8, 16, 24, or 32. However, since most of the images we use are 24-bit and 32-bit, we discuss these two types of images.
Bicompression Describe the type of image data compression, and we only discuss types that are not compressed:Bi_rgb.
biSizeImage Indicates the size of the image, in bytes. When in bi_rgb format, it can be set to 0.
Bixpelspermeter Describes the horizontal resolution, expressed in pixels / meters.
Biypelspermeter Describes the vertical resolution, expressed in pixels / meters.
biClrUsed Describes the number of color indexes in the color table that the bitmap is actually using (set to 0 , which means that all palette items are used).
Biclrimportant Indicates that the number of color indexes that have a significant effect on the image display, if 0, is important.
3. RGB Color Arrayabout RGB tri-color space I think everyone is very familiar with, here I want to say is under Windows ,RGB color array storage format actually BGR. In other words , the RGB bit image format for the four bits is:
Blue B value Green G value Red R value
for the three-bit RGB bit image, the format of the voxel data is:
Blue B value Green G value Red R value Transparent channel A value
The transparent channel is also called the Alpha channel, which is a transparent property of the pixel, with a value between 0(fully transparent) and 255(opaque). For The image of the position, the entire image is opaque because there is no Alpha channel. Line Alignmentbecause Windows has a minimum of 4 bytes in a row scan, whenpicture width × number of bytes per pixel! = integer multiples of 4 fill in the missing bytes at the back of each line with a 0 padding (generally not justified if the image width is a power of 2 ). Note:The first line of the RGB data for a BMP file represents the last line of data in the LCD

Bitmap format Analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.