--use common method to display BMP bitmap, the memory is big, slow, in the shape shrinks, the distortion is serious, in the low color bit number of devices display high color digit figure graphics when the distortion is big. This article uses the video function to display BMP bitmap, can eliminate the above shortcoming.
----One, BMP file structure
----1. BMP File Composition
----BMP file consists of file header, bitmap information header, color information and graphic data.
----2. BMP file Header
----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;
----3. Bitmap Information Header----
BMP bitmap Information Header data is used to describe the size of bitmaps and other information.
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;
----4. Color table
The----color table describes the colors in a bitmap, it has several table entries, and each table item is a RGBQUAD type structure that defines a color. The RGBQUAD structure is defined as follows:
typedef struct tagRGBQUAD {
BYTErgbBlue;// 蓝色的亮度(值范围为0-255)
BYTErgbGreen; // 绿色的亮度(值范围为0-255)
BYTErgbRed; // 红色的亮度(值范围为0-255)
BYTErgbReserved;// 保留,必须为0
} RGBQUAD;
The number of Rgbquad structure data in the color table is bibitcount to determine:
When bibitcount=1,4,8, there are 2,16,256 table items respectively;
When bibitcount=24, there are no color table entries.
The bitmap information header and color table Form the bitmap information, and the BITMAPINFO structure is defined as follows:
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader; // 位图信息头
RGBQUAD bmiColors[1]; // 颜色表
} BITMAPINFO;