内部结构
BMP文件的数据按照从文件头开始的先后顺序分为四个部分:分别是
- 位图文件头
- 位图信息头
- 调色板(24bt位图是没有的)
- 位图数据(RGB)
// 定义BMP文件头部结构
typedef struct {
unsigned short bfType;
unsigned int bfSize;
unsigned short bfReserved1;
unsigned short bfReserved2;
unsigned int bfOffBits;
} BITMAPFILEHEADER;
// 定义BMP信息头部结构
typedef struct {
unsigned int biSize;
int biWidth;
int biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
unsigned int biCompression;
unsigned int biSizeImage;
int biXPelsPerMeter;
int biYPelsPerMeter;
unsigned int biClrUsed;
unsigned int biClrImportant;
} BITMAPINFOHEADER;