[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 ...
随机推荐
- day 65 Django基础十一之认证系统
Django基础十一之认证系统 本节目录 一 auth模块 二 User对象 三 扩展默认的auth_user表 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 auth模块 我们 ...
- pip install mysql-python报错1. Unable to find vcvarsall.bat 2 fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory 3.error: command 'mt.exe' failed with exit statu
最近在安装mysql -python 时报错折腾了半天,通过以下方法解决: 1. pip install mysql-python报错 Unable to find vcvarsall.bat (参考 ...
- 初识OpenCV-Python - 003:Mouse as a paint-brush
此次学习了如何在OpenCV中使用鼠标事件.主要使用cv2.setMouseCallback()函数来调用鼠标事件. 首先,鼠标有如下事件: >>> import cv2>&g ...
- Nand Flash 控制器中的硬件 ECC 介绍
ECC 产生方法 ECC 是用于对存储器之间传送数据正确进行校验的一种算法,分硬件 ECC 和软件 ECC 算法两种,在 S3C2410 的 Nand Flash 控制器中实现了由硬件电路(ECC 生 ...
- 在js中使用Razor
@foreach (var tem in Model) { <text> time.push("@tem.CreateTime.ToString("G")&q ...
- (一)phonegap自学---不会java也会写原生app
移动设备如日中天的今天 微软的表现让我们这些.net程序员无不心寒!!幸好每次乱世出英豪,古有java能夸平台,.net跨语言,今有phonegap跨设备 phonegap是什么 狂点这 http:/ ...
- 使用Cookie实现显示用户上次访问时间
一. 常用Cookie API介绍 1. 获取cookie request.getCookies(); // 返回Cookie[] 2. 创建cookie Cookie(String key, St ...
- poj 2774 字符串哈希求最长公共子串
Long Long Message #include <iostream> #include <algorithm> #include <cstdio> #incl ...
- momentjs 使用总结
一.安装 cnpm install moment 二.引入 var moment = require('moment') 三.使用 let today = moment().format('YYYY- ...
- PAT甲级——A1003Emergency
As an emergency rescue team leader of a city, you are given a special map of your country. The map s ...