方式一:
#define RGB565_MASK_RED 0xF800
#define RGB565_MASK_GREEN 0x07E0
#define RGB565_MASK_BLUE 0x001F
unsigned short *pRGB16 = (unsigned short *)lParam;
for(int i=0; i<176*144; i++)
{
unsigned short RGB16 = *pRGB16;
g_rgbbuf[i*3+2] = (RGB16&RGB565_MASK_RED) >> 11;
g_rgbbuf[i*3+1] = (RGB16&RGB565_MASK_GREEN) >> 5;
g_rgbbuf[i*3+0] = (RGB16&RGB565_MASK_BLUE);
g_rgbbuf[i*3+2] <<= 3;
g_rgbbuf[i*3+1] <<= 2;
g_rgbbuf[i*3+0] <<= 3;
pRGB16++;
}
方式二:
rgb5652rgb888(unsigned char *image,unsigned char *image888)
{
unsigned char R,G,B;
B=(*image) & 0x1F;//000BBBBB
G=( *(image+1) << 3 ) & 0x38 + ( *image >> 5 ) & 0x07 ;//得到00GGGGGG00
R=( *(image+1) >> 3 ) & 0x1F; //得到000RRRRR
*(image888+0)=B * 255 / 63; // 把5bits映射到8bits去,自己可以优化一下算法,下同
*(image888+1)=G * 255 / 127;
*(image888+2)=R * 255 / 63;
}
转载自:
阅读(4489) | 评论(0) | 转发(0) |