BMP format Structure detailed

Source: Internet
Author: User

Some time ago for a period of time image acquisition, BMP format and JPG pictures and further in-depth research, this blog will first introduce the structure of BMP format files, browsing a lot of information online, found that there are a lot of Daniel in this study quite deep ... Here's what they have to learn from ...

First, the contents of the entire BMP file can be divided into 3 to 4 pieces. There are 3 to 4 blocks instead of fixed values because there may be a palette or some masks for BMP. Discuss this in detail.

The first block is the BMP file header used to describe the situation of the entire BMP file. The structure is as follows:

Typedefstruct tagbitmapfileheader   

{

WORD bftype;

DWORD bfsize;

WORD bfReserved1;

WORD BfReserved2;

DWORD bfoffbits;   

} Bitmapfileheader, *pbitmapfileheader;

This information is quite useful if you want to parse the BMP file directly. The first bftype is used to represent the file type, and if it is a BMP file, then the value of this position must be "BM" or 0x4d42. The second bfsize represents the number of bytes in the entire file. The third fourth is reserved, currently meaningless, the last is very important, said, bitmap data information from the file header offset, in bytes.

First, the contents of the entire BMP file can be divided into 3 to 4 pieces. There are 3 to 4 blocks instead of fixed values because there may be a palette or some masks for BMP. Discuss this in detail.

The first block is the BMP file header used to describe the situation of the entire BMP file. The structure is as follows:

Typedefstruct tagbitmapfileheader   
       
{     
       
WORD bftype;     
       
DWORD bfsize;     
       
WORD bfReserved1;     
       
WORD BfReserved2;     
       
DWORD bfoffbits;   
       
} Bitmapfileheader, *pbitmapfileheader;

This information is quite useful if you want to parse the BMP file directly. The first bftype is used to represent the file type, and if it is a BMP file, then the value of this position must be "BM" or 0x4d42. The second bfsize represents the number of bytes in the entire file. The third fourth is reserved, currently meaningless, the last is very important, said, bitmap data information from the file header offset, in bytes.

Reference from:http://blog.csdn.net/jurrah/article/details/4163333

There is also a Daniel's blog that is also very exciting http://www.cnblogs.com/beer/archive/2010/11/21/1883054.html

Http://www.blogjava.net/georgehill/articles/6549.html

This article is from the "Late Evening" blog, please be sure to keep this source http://yiluohuanghun.blog.51cto.com/3407300/864001

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.