BMP image Analysis

Source: Internet
Author: User
Tags bmp image file size

BMP file consists of file header, bitmap information header, color information and graphic data four parts.

One, BMP file head

BMP file header Data structure contains the type of BMP file, file size and bitmap starting position information. Its structure is defined as follows:

typedef struct tagBITMAPFILEHEADER
{
  WORDbfType;  // 位图文件的类型,必须为BM
  DWORD  bfSize;  // 位图文件的大小,以字节为单位
  WORDbfReserved1; // 位图文件保留字,必须为0
  WORDbfReserved2; // 位图文件保留字,必须为0
  DWORD  bfOffBits; // 位图数据的起始位置,以相对于位图文件头的偏移量表示,以字节为单位
} BITMAPFILEHEADER;

Second, bitmap information header

BMP bitmap Information Header data is used to describe the size of bitmaps and other information. Its structure is defined as follows:

typedef struct tagBITMAPINFOHEADER
{
 DWORD biSize;  // 本结构所占用字节数
 LONGbiWidth; // 位图的宽度,以像素为单位
 LONGbiHeight; // 位图的高度,以像素为单位
 WORD  biPlanes; // 目标设备的级别,必须为1
 WORD  biBitCount// 每个像素所需的位数,必须是1(双色),4(16色),8(256色)或24(真彩色)之一
 DWORD biCompression;  // 位图压缩类型,必须是 0(不压缩),1(BI_RLE8压缩类型)或2(BI_RLE4压缩类型)之一
 DWORD biSizeImage; // 位图的大小,以字节为单位
 LONGbiXPelsPerMeter; // 位图水平分辨率,每米像素数
 LONGbiYPelsPerMeter; // 位图垂直分辨率,每米像素数
 DWORD biClrUsed;// 位图实际使用的颜色表中的颜色数
 DWORD biClrImportant;// 位图显示过程中重要的颜色数
} BITMAPINFOHEADER;

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.