当压缩格式为 BI_BITFIELDS 时,在位图信息(即BITMAPINFOHEADER)后面接着三个DWORD型数据,就是掩码数据,
一般为:0xF800(兰色掩码),0x07E0(绿色掩码),0x001F(红色掩码),这是565的格式
如果为:0x7C00, 0x03E0, 0x001F, 则是555的格式(这也是bitcount=16,而压缩标志为BI_DIB时的默认格式)
BITMAPINFO *bitmapInfo = (BITMAPINFO*)malloc( sizeof(BITMAPINFO)+sizeof(RGBQUAD)*(255) );
memset( bitmapInfo, 0, sizeof(BITMAPINFO)+sizeof(RGBQUAD)*(255) );
bitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitmapInfo->bmiHeader.biWidth = m_uWidth;
bitmapInfo->bmiHeader.biHeight = uLineCount*uLineHeight + m_uLineSpace*(uLineCount-1);
bitmapInfo->bmiHeader.biPlanes = 1;
bitmapInfo->bmiHeader.biBitCount = 16;
bitmapInfo->bmiHeader.biCompression = BI_BITFIELDS;
bitmapInfo->bmiHeader.biSizeImage = 0;
bitmapInfo->bmiColors[0].rgbBlue = 0;
bitmapInfo->bmiColors[0].rgbGreen = 0xF8;
bitmapInfo->bmiColors[0].rgbRed = 0;
bitmapInfo->bmiColors[0].rgbReserved = 0;
bitmapInfo->bmiColors[1].rgbBlue = 0xE0;
bitmapInfo->bmiColors[1].rgbGreen = 0x07;
bitmapInfo->bmiColors[1].rgbRed = 0;
bitmapInfo->bmiColors[1].rgbReserved = 0;
bitmapInfo->bmiColors[2].rgbBlue = 0x1F;
bitmapInfo->bmiColors[2].rgbGreen = 0;
bitmapInfo->bmiColors[2].rgbRed = 0;
bitmapInfo->bmiColors[2].rgbReserved = 0;
m_hBitmap = CreateDIBSection( m_hCompatibleDc, bitmapInfo, DIB_RGB_COLORS, &pBitmapBuffer, NULL, NULL );
GetObject( m_hBitmap, sizeof(DIBSECTION), &dibSection );