[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 ...
随机推荐
- 763 Hex Conversion
原题网址:http://www.lintcode.com/zh-cn/problem/hex-conversion/ Given a decimal number n and an integer k ...
- x-杂项-maven-repository-lombok:lombok
ylbtech-杂项-maven-repository-lombok:lombok Project Lombok是一个java库,可以自动插入编辑器并构建工具,为您的java增添色彩.永远不要再写另一 ...
- K最近邻(KNN,k-Nearest Neighbor)准确理解
K最近邻(KNN,k-Nearest Neighbor)准确理解 用了之后,发现我用的都是1NN,所以查阅了一下相关文献,才对KNN理解正确了,真是丢人了. 下图中,绿色圆要被决定赋予哪个类,是红色三 ...
- HDU-1501-Zipper-字符串的dfs
Given three strings, you are to determine whether the third string can be formed by combining the ch ...
- 1.1python基础_基础
1_编码 默认情况下,Python 3 源码文件以 UTF-8 编码,所有字符串都是 unicode 字符串. 当然你也可以为源码文件指定不同的编码: # -*- coding: UTF-8 -*- ...
- POJ 3304 /// 判断线段与直线是否相交
题目大意: 询问给定n条线段 是否存在一条直线使得所有线段在直线上的投影存在公共点 这个问题可以转化为 是否存在一条直线与所有的线段同时相交 而枚举直线的问题 因为若存在符合要求的直线 那么必存在穿过 ...
- 面试系列14 redis的过期策略都有哪些
(1)设置过期时间 我们set key的时候,都可以给一个expire time,就是过期时间,指定这个key比如说只能存活1个小时?10分钟?这个很有用,我们自己可以指定缓存到期就失效. 如果假设你 ...
- 筛法求欧拉函数(poj2478
求1-n的欧拉函数的值 #include <iostream> #include <cstdio> #include <queue> #include <al ...
- 「BZOJ2388」旅行规划
传送门 分块+凸包 求出前缀和数组s 对于l~r加上k,相当于s[l]~s[r]加上一个首项为k,公差为k的等差数列.r~n加上k*(r-l+1). 分块之后对每一块维护两个标记,一个记录它加的等差数 ...
- 如何在window和mac下查找数据库
1. mac 下终端使用步骤 cd /Applications/xampp/bin ./mysql -u root 2. window CMD命令中执行步骤 D: cd D:/xampp/mysql ...