[code] if (x<0)x=0;else if (x>255)x=255;
//颜色范围0-255;
// 1.原始:
if (tem_b<)tem_b=;else if (tem_b>)tem_b=;
if (tem_g<)tem_g=;else if (tem_g>)tem_g=;
if (tem_r<)tem_r=;else if (tem_r>)tem_r=;
//2.使用条件状态值生成掩码来移除条件分支
tem_b &=-(tem_b>=);//求负是为了生成掩码,也可以减1来生成掩码 <0
tem_b = (tem_b | -(tem_b>) ) & 0xFF;//>255
tem_g &=-(tem_g>=);
tem_g = (tem_g | -(tem_g>) ) & 0xFF;
tem_r &=-(tem_r>=);
tem_r = (tem_r | -(tem_r>) ) & 0xFF;
//3.使用带符号的移位生成掩码来移除条件分支 (建议使用该方案替代上面的条件状态值方案)
tem_b &=~(tem_b>>);
tem_b = (tem_b | ((-tem_b)>>) ) & 0xFF;
tem_g &=~(tem_g>>);
tem_g = (tem_g | ((-tem_g)>>) ) & 0xFF;
tem_r &=~(tem_r>>);
tem_r = (tem_r | ((-tem_r)>>) ) & 0xFF; //4.查表移除分支;
unsigned char_color_table[++];//假设color属于[-256..512]
unsigned char*color_table=&_color_table[];//先偏移256
//初始化 color_table;
for ( int i = -;i< ; i++)
{
if (i<) color_table[i]=;
else if (i>) color_table[i]=;
else color_table[i]=i;
}
...
resultRow[*x]=color_table[tem_b];
resultRow[*x+]=color_table[tem_g];
resultRow[*x+]=color_table[tem_r];
[code] if (x<0)x=0;else if (x>255)x=255;的更多相关文章
- 微软Visual Studio Code 0.8.0发布,新增多种主题
月30日,Build 开发者大会上,正式宣布了 Visual Studio Code 项目;并将其定义为:一个运行于 Mac OS X.Windows和 Linux 之上的,针对于编写现代 Web 和 ...
- VS Code + NWJS(Node-Webkit)0.14.7 + SQLite3 + Angular6 构建跨平台桌面应用
一.项目需求 最近公司有终端桌面系统需求,需要支持本地离线运行(本地数据为主,云端数据同步),同时支持Window XP,最好跨平台.要求安装配置简单(一次性打包安装),安装包要小,安装时间短,可离线 ...
- ORA-00600: internal error code, arguments: [2662], [0], [1106971], [0], [1107731], [12583040]
今天是2014-06-06,在进行数据库恢复的时候出现了一个久违的ora-600 [2662]错误.特整理例如以下: 问题描写叙述: system及数据文件误删,採用恢复数据文件的方式将数据库恢复到開 ...
- 07 oracle 归档模式 inactive/current redo log损坏修复--以及错误ORA-00600: internal error code, arguments: [2663], [0], [9710724], [0], [9711142], [], [], [], [], [], [], []
07 oracle 归档模式 inactive/current redo log损坏修复--以及错误ORA-00600: internal error code, arguments: [2663], ...
- QR code & auto login & OAuth 2.0
QR code & auto login & OAuth 2.0 扫码自动登录原理解析 https://www.ximalaya.com/shangye/14685881/958686 ...
- Error Code: 1366. Incorrect DECIMAL value: '0' for column '' at row -1 0.266 sec;
Reference: https://stackoverflow.com/questions/35037288/incorrect-decimal-integer-value-mysql Er ...
- caffe: test code 执行出问题: Check failed: FLAGS_weights.size() > 0 (0 vs. 0) Need model weights to score.
Check failed: FLAGS_weights.size() > 0 (0 vs. 0) Need model weights to score. 出现这个错误,但是我记得昨天还好好的, ...
- Oracle Database 11g Release 2(11.2.0.3.0) RAC On Redhat Linux 5.8 Using Vmware Workstation 9.0
一,简介 二,配置虚拟机 1,创建虚拟机 (1)添加三块儿网卡: 主节点 二节点 eth0: 公网 192.168.1.20/24 NAT eth0: 公网 192.168.1 ...
- ps6 安装失败-FATAL: Payload '{3F023875-4A52-4605-9DB6-A88D4A813E8D} Camera Profiles Installer 6.0.98.0' information not found in Media_db.
点击 '错误摘要' Exit Code: 34 -------------------------------------- Summary ----------------------------- ...
- [转]Could not load file or assembly 'System.Core, Version=2.0.5.0 和autofac冲突的问题
Could not load file or assembly 'System.Core, Version=2.0.5.0 和autofac冲突的问题 来源:http://www.cnblogs.co ...
随机推荐
- mysqldump使用记录
#导出单个数据库:结构 无数据 [root@localhost ~]#mysqldump -h127.0.0.1 -uroot -p --opt --no-data db_name >~/db_ ...
- python库参考学习网址
https://github.com/china-testing/python-api-tesing 这里有很多python库参考
- JAVA数据结构之数组
接下来的几篇博文会在最近仔细研读数据结构与算法的书籍后会摘录一些要点和总结一些自己的心得体会,帮助大家更深入地理解java中的数据结构和一些基本的算法,同时巩固自己数据结构和算法这些最基础的计算机知识 ...
- js怎样把URL链接的参数截取出来
有时候,A页面参数需要传递到B页面,则把参数拼接到跳转B页面的url上,这时怎样在另一个页面截取A页面传递的参数呢,主要代码如下 /** * 获取指定的URL参数值 URL:http://www.qu ...
- 期望——邮票收集问题lightoj1342
邮票手机问题: 有n种类型的邮票,问将所有的类型的邮票全部收集起来所要的收集次数期望是多少. 设dp[i]为已经收集了i种类型的票,还要收集n-i种的次数的期望. dp[n]=0; 递推式: dp[i ...
- 记录一次dubbo不能正常抛出特定异常
BUG场景 今天同事的代码中出现一个问题,让我帮忙排查一下.原代码大致如下 dubbo服务消费者: @Resource private IPayWayService payWayService; @R ...
- NFS+mou
前言 有两台电脑,Linux操作系统,服务器和客户端,IP不同,但是可以相互访问. 客户端想访问服务器的文件系统 准备工作 假设 服务器的ip为 192.168.0.100,要分享为公共文件夹的目录为 ...
- Zuul的容错与回退与Zuul的高可用
容错与回退 复制zuul项目,修改ArtifactId 如zuul-falllback 写Zuul的回退类 @Component public class ZuulFallBackProvider ...
- js获取base64格式图片预览上传并用php保存到本地服务器指定文件夹
html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- React报错:Laravel React-Router browserHistory 刷新子页面报错404
举例:myblog.com/ 刷新没问题 myblog.com/add 刷新404 browserHistory报404,hashHistory却正常 原因是少路由.web.php添加路由 Route ...