alphaRGB 转 RGB、16位
struct xColor
{
BYTE b, g, r, a;
};
struct RGBColor
{
BYTE b, g, r;
};
//void operator <<(RGBColor& rgb, xColor& color)
//{
// rgb.r = color.a * 1.0 / 0xFF * color.r;
// rgb.g = color.a * 1.0 / 0xFF * color.g;
// rgb.b = color.a * 1.0 / 0xFF * color.b;
//}
void operator <<(RGBColor& rgb, xColor& color)
{
rgb.r = 0xFF;
rgb.g = 0x0;
rgb.b = 0x0;
}
void alphaRGB2RGB(unsigned char* src, unsigned char* dest, int sizePixel)
{
assert(src != NULL && dest != NULL);
xColor* pColor = (xColor*)src;
RGBColor* pRGBColor = (RGBColor*)dest;
while (--sizePixel >= 0)
{
*pRGBColor << *pColor;
//printf("pColor r[%d] g[%d] b[%d] a[%d]\n", pColor->r, pColor->g, pColor->b, pColor->a);
//printf("prgbColor r[%d] g[%d] b[%d]\n", pRGBColor->r, pRGBColor->g, pRGBColor->b);
++pRGBColor;
++pColor;
}
}
unsigned short
RGB888toRGB565(xColor& color)
{
unsigned short B = ( (color.a / 0xFF * color.b) >> 3) & 0x001F;
unsigned short G = (( (color.a / 0xFF * color.g) >> 2) << 5) & 0x07E0;
unsigned short R = (( (color.a / 0xFF * color.r) >> 3) << 11) & 0xF800;
return (unsigned short) (R | G | B);
}
void alphaRGB2RGB565(unsigned char* src, unsigned char* dest, int xWidth, int yHeight, int nLineWidthByte)
{
assert(src != NULL && dest != NULL);
printf("xWidth[%d] xHeight[%d] nLineWidthByte[%d]", xWidth, yHeight, nLineWidthByte);
xColor* pColor = (xColor*)src;
BYTE* pDstLineByte = (BYTE*)dest;
for(int y =0; y < yHeight; ++y)
{
unsigned short* pDstPixel = (unsigned short*)pDstLineByte;
for(int x = 0; x < xWidth; ++x)
{
*pDstPixel = RGB888toRGB565(*pColor);
++pDstPixel;
++pColor;
}
pDstLineByte += nLineWidthByte;
}
}
unsigned short
RGB888toRGB565(unsigned char red, unsigned char green, unsigned char blue)
{
unsigned short B = (blue >> 3) & 0x001F;
unsigned short G = ((green >> 2) << 5) & 0x07E0;
unsigned short R = ((red >> 3) << 11) & 0xF800;
return (unsigned short) (R | G | B);
}
alphaRGB 转 RGB、16位的更多相关文章
- 如何将24位RGB颜色转换16位RGB颜色
有许多朋友第一次使用16位彩色显示屏会遇到如何将24位RGB颜色转换为对应的16位RGB颜色的问题, 通过查阅相关资料,就写一下其中的转换原理吧,希望对大家会有所帮助. 我们知道24位RGB是分别由8 ...
- bmp文件格式中rgb555与rgb888之间的转换,24位与16位位图的转换
今日,有同事问我.rgb555模式下的位图文件的格式问题,于是花了一下午的时间通过推測与測试,分析出了例如以下bmp文件在rgb555模式下的文件存储规律: 1:bmp文件的文件信息头中的biBitC ...
- 颜色模式中8位,16位,24位,32位色彩是什么意思?会有什么区别?计算机颜色格式( 8位 16位 24位 32位色)<转>
颜色模式中8位,16位,24位,32位色彩是什么意思?会有什么区别简单地说这里说的位数和windows系统显示器设置中的颜色位数是一样的.表示的是能够显示出来的颜色的多少. 8位的意思是说,能够显示出 ...
- AM335X用RGB888连接LCD如何以16位色彩模式显示图片
在AM335x中,在连接显示屏的时候,存在一个问题.这个在am335x Sillicon Errata已经提到过 在RGB888模式中 而对于RGB565模式的硬件连接 不难看出,这个RGB是反的 ...
- 使用 GCC 和 GNU Binutils 编写能在 x86 实模式运行的 16 位代码
不可否认,这次的标题有点长.之所以把标题写得这么详细,主要是为了搜索引擎能够准确地把确实需要了解 GCC 生成 16 位实模式代码方法的朋友带到我的博客.先说一下背景,编写能在 x86 实模式下运行的 ...
- C# GUID转换成16位字符串或19位数字并确保唯一
/// <summary> /// 根据GUID获取16位的唯一字符串 /// </summary> /// <param name=\"guid\" ...
- 16位汇编 多文件 intel汇编 编译器masm5.0 调用子程序库即静态库的自定义函数 WINDOWS
;以下是16位汇编 创建静态库,并调用静态库中的函数 ;多文件汇编格式 ;编译方法(此处用的是masm 5.0,如果是其他的编译器,有可能不能编译) ;第一种,编译方法 ;1.masm main.as ...
- [ZigBee] 5、ZigBee基础实验——图文与代码详解定时器1(16位定时器)(长文)
1.定时器1概述 定时器1 是一个支持典型的定时/计数功能的独立16 位定时器,支持输入捕获,输出比较和PWM等功能.定时器有五个独立的捕获/比较通道.每个通道定时器要使用一个I/O 引脚.定时器用于 ...
- zzy:java采用的是16位的Unicode字符集作为编码方式------理解
java语言使用16位的Unicode字符集作为编码方式,是疯狂Java中的原话. 1,编码方式只是针对字符类型的(不包括字符串类,数值类型int等,这些只是在解释[执行]的时候放到Jvm的不同内存块 ...
- [Effective JavaScript 笔记] 第7条:视字符串为16位的代码单元序列
Unicode编码,基础:它为世界上所有的文字系统的每个字符单位分配一个唯一的整数,该整数介于0~1114111之间,在Unicode术语中称为代码点(code point). 和其它字符编码几乎没有 ...
随机推荐
- Java温故系列之web项目复习
如果从外面导入项目 操作方法为: File->Import -->General-->Existing Project into Workspace 搭建sqlserver数据库连接 ...
- Type.GetType(string)为空
Type type = Type.GetType(scheduleJob.JobType); 时type为空, 导致执行下一步时 MethodInfo method = type.GetMethod( ...
- linux查看父子进程
python多进程代码 http://blog.csdn.net/yfkiss/article/details/6729364 Linux下多线程查看工具(pstree.ps.pstack) tes ...
- hibernate 左链接查询
select pro from Provide as pro left join pro.labels as la left join pro.city as c where 1=1
- thinkPHP-空操作
空操作 当访问的方法不存在时,可以定义一个empty方法来避免空操作 function _empty() { echo "网页不存在,请检查地址信息"; } 这样当访问不存在的方法 ...
- 通过innobackupex实现对MySQL的增量备份与还原
备份 增量备份是基于完整备份的,所以我们需要先做一次完整备份: innobackupex --password=test /backup/ 备注:test是我的MySQL服务的root用户的密码,/b ...
- centos6升级python2.7
#下载python #wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 #安装支持https yum install opens ...
- (转)javascript异步编程的四种方法
本文转自:http://www.ruanyifeng.com/blog/2012/12/asynchronous%EF%BC%BFjavascript.html 作者:阮一峰 本文仅仅作为个人mark ...
- 【初学者教程】在电脑上安装Python,写第一个程序
欢迎来到Python的世界 1.存在Python 2和Python 3两个版本,我该用哪个?如果书是关于2的,下载2:如果书是关于3的,就下载3.建议用Python 3,不过用2也是可以的. 2.下载 ...
- centos7安装mariadb10遇到的问题解决
4. 安装中的错误 4.1 /bin/ld: cannot find -lz /bin/ld: cannot find -lzcollect2: error: ld returned 1 exit s ...