|
|
发表于 2006-12-12 18:13:00
|
显示全部楼层
Re:请问各位大虾,怎么样把一个24位色的图片用程序转换为1
引用《Windows游戏编程大师技巧》
1.创建一个m*n个字(WORD)大小的缓冲,每个字是16位
2.把24位图象装载到你的BITMAP_FILE结构中,而后读取缓冲,用下面粗糙的色彩换算算法把24位色彩转换成16位;
//each pixel in BITMAP_FILE.buffer() is encoded as 3-bytes
//in BGR order,or BLUE,GREEN,RED
//assuming index is pointing to the next pixel...
UCHAR blue=(bitmap.buffer[index*3+0])>>3,
green=(bitmap.buffer[index*3+1])>>2,
red=(bitmap.buffer[index*3+2])>>3;
//build up 16 bit color word
USHORT color=_RGB16BIT565(red,green,blue); |
|