RGB565、RGB555、RGB888图像DIB显示

RGB565:

BITMAPINFOHEADER bmpHeader;
ZeroMemory(&bmpHeader, sizeof BITMAPINFOHEADER);
bmpHeader.biSize = sizeof BITMAPINFOHEADER;
bmpHeader.biWidth =width;
bmpHeader.biHeight = abs(height);
bmpHeader.biPlanes = 1;
bmpHeader.biBitCount = 16;
bmpHeader.biCompression = BI_BITFIELDS;//RGB555是BI_RGB;
bmpHeader.biSizeImage = 2*(bmpHeader.biWidth+3)/4*4*abs(bmpHeader.biHeight);
HBITMAP hBmp = CreateDIBSection(hDC, (BITMAPINFO*) &bmpHeader, DIB_RGB_COLORS, ppBits, NULL, 0);

 

RGB555、RGB888:
bmpHeader.biSize = sizeof BITMAPINFOHEADER;
bmpHeader.biWidth =width;
bmpHeader.biHeight = abs(height);
bmpHeader.biPlanes = 1;
bmpHeader.biBitCount = 24;
bmpHeader.biCompression = BI_RGB;//RGB555是BI_RGB;


注:0xF800,0x07E0,0x001F是RGB565的bit mask
    0xFF0000,0xFF00,0xFF是RGB888的bit mask
RGB565--->RGB888
Color为SHORT
Red=(unsigned char)((Color&0xF800)>>8);
Green=(unsigned char)((Color&0x07E0)>>3);
Blue=(unsigned char)((Color&0x1F)<<3);

RGB888--->RGB565
COLOR为INT
Red=(unsigned char)((Color&0xFF0000)>>19);
Green=(unsigned char)((Color&0xFF00)>>10);
Blue=(unsigned char)((Color&0xFF)>>3);


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/langonghan/archive/2009/03/26/4026729.aspx

你可能感兴趣的:(null,BI,colors)