您的位置:首页 > 其它

RGB565,RGB888

2014-03-19 08:23 447 查看
// 颜色的转换

/* create 24 bit 8/8/8 format pixel (0x00RRGGBB) from RGB triplet*/

#define RGB2PIXEL888(r,g,b) \

(((r) << 16) | ((g) << 8) | (b))

/* create 16 bit 5/6/5 format pixel from RGB triplet */

#define RGB2PIXEL565(r,g,b) \

((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))

/* create 24 bit 8/8/8 format pixel from RGB colorval (0x00RRGGBB)*/

#define COLOR2PIXEL888(c) \

((((c) & 0xff) << 16) | ((c) & 0xff00) | (((c) & 0xff0000) >> 16))

/* create 16 bit 5/6/5 format pixel from RGB colorval (0x00RRGGBB)*/

#define COLOR2PIXEL565(c) \

((((c) & 0xf8) << 8) | (((c) & 0xfc00) >> 5) | (((c) & 0xf80000) >> 19))

/* return 8/8/8 bit r, g, or b, component of 24 bit pixel */

#define PIXEL888RED(pixel) (Uint8)(((pixel) >> 16) & 0xff)

#define PIXEL888GREEN(pixel) (Uint8)(((pixel) >> 8) & 0xff)

#define PIXEL888BLUE(pixel) (Uint8)((pixel) & 0xff)

/* return 5/6/5 bit r, g or b component of 16 bit pixel*/

#define PIXEL565RED(pixel) (Uint8)(((pixel) >> 11) & 0x1f)

#define PIXEL565GREEN(pixel) (Uint8)(((pixel) >> 5) & 0x3f)

#define PIXEL565BLUE(pixel) (Uint8)((pixel) & 0x1f)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: