bitmap convert to RGB565 display
来源:互联网 发布:画册制作软件 编辑:程序博客网 时间:2024/05/22 15:46
bitmap图片是一个RGB888,每个像素由3个字节组成,R->8bit,G->8bit,B->8bit;
RGB565 的每个pixels是由2字节组成,R->5bit,G->6bit,B->5bit。
转换的思路是取出原图的点,对没个采样进行运算。
- #define RGB565_MASK_RED 0xF800
- #define RGB565_MASK_GREEN 0x07E0
- #define RGB565_MASK_BLUE 0x001F
- void rgb565_2_rgb24(BYTE *rgb24, WORD rgb565)
- {
- //extract RGB
- rgb24[2] = (rgb565 & RGB565_MASK_RED) >> 11;
- rgb24[1] = (rgb565 & RGB565_MASK_GREEN) >> 5;
- rgb24[0] = (rgb565 & RGB565_MASK_BLUE);
- //amplify the image
- rgb24[2] <<= 3;
- rgb24[1] <<= 2;
- rgb24[0] <<= 3;
- }
- USHORT rgb_24_2_565(int r, int g, int b)
- {
- return (USHORT)(((unsigned(r) << 8) & 0xF800) |
- ((unsigned(g) << 3) & 0x7E0) |
- ((unsigned(b) >> 3)));
- }
- USHORT rgb_24_2_555(int r, int g, int b)
- {
- return (USHORT)(((unsigned(r) << 7) & 0x7C00) |
- ((unsigned(g) << 2) & 0x3E0) |
- ((unsigned(b) >> 3)));
- }
- COLORREF rgb_555_2_24(int rgb555)
- {
- unsigned r = ((rgb555 >> 7) & 0xF8);
- unsigned g = ((rgb555 >> 2) & 0xF8);
- unsigned b = ((rgb555 << 3) & 0xF8);
- return RGB(r,g,b);
- }
- void rgb_555_2_bgr24(BYTE* p, int rgb555)
- {
- p[0] = ((rgb555 << 3) & 0xF8);
- p[1] = ((rgb555 >> 2) & 0xF8);
- p[2] = ((rgb555 >> 7) & 0xF8);
- }
view plaincopy to clipboardprint?
http://blog.csdn.net/nitghost/archive/2009/02/23/3925678.aspx
- bitmap convert to RGB565 display
- bitmap convert to RGB565 display
- YUV422 to RGB565 Convert
- Android Bitmap convert to ByteArray
- 【bug】plug in convert icon to bitmap
- convert between RGB565 and RGB888
- Android: how to convert whole ImageView to Bitmap?
- How to convert a Drawable to a Bitmap?
- RGB565 to RGB24
- RGB565 to RGB24
- YUV422 to RGB565
- RGB565 to gray
- convert View to Bitmap将View保存为图片
- 一个RGB565转Bitmap的程序
- RGB565 to RGB24, RGB555 & RGB24
- RGB565 to RGB24, RGB555 & RGB24
- RGB565 to RGB24, RGB555 & RGB2
- ffmpeg 命令 rgb565 to YUV420p
- dwr异步改为同步
- In_interrupt( ) 和In_irq( )
- 电脑定时自动开机无需人手动开机
- 第一个go语言的网络程序
- 在 Linux 上构建一个 RADIUS 服务器
- bitmap convert to RGB565 display
- 在雪豹10.6.2(Mac OS X)上安装Oracle10g
- magento开发 -- 深入理解Magento第二章
- Qt4写的压包工具.(开源OpenSource)
- c#启动Sql Server服务
- 3.7.3 最简单的关联
- 敏捷开发中编写高质量Java代码
- 如何从表空间中删除数据文件
- 帮QQ朋友改的一段C++程序2