//颜色范围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;的更多相关文章

  1. 微软Visual Studio Code 0.8.0发布,新增多种主题

    月30日,Build 开发者大会上,正式宣布了 Visual Studio Code 项目;并将其定义为:一个运行于 Mac OS X.Windows和 Linux 之上的,针对于编写现代 Web 和 ...

  2. VS Code + NWJS(Node-Webkit)0.14.7 + SQLite3 + Angular6 构建跨平台桌面应用

    一.项目需求 最近公司有终端桌面系统需求,需要支持本地离线运行(本地数据为主,云端数据同步),同时支持Window XP,最好跨平台.要求安装配置简单(一次性打包安装),安装包要小,安装时间短,可离线 ...

  3. ORA-00600: internal error code, arguments: [2662], [0], [1106971], [0], [1107731], [12583040]

    今天是2014-06-06,在进行数据库恢复的时候出现了一个久违的ora-600 [2662]错误.特整理例如以下: 问题描写叙述: system及数据文件误删,採用恢复数据文件的方式将数据库恢复到開 ...

  4. 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], ...

  5. QR code & auto login & OAuth 2.0

    QR code & auto login & OAuth 2.0 扫码自动登录原理解析 https://www.ximalaya.com/shangye/14685881/958686 ...

  6. 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 ...

  7. 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. 出现这个错误,但是我记得昨天还好好的, ...

  8. 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 ...

  9. 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 ----------------------------- ...

  10. [转]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 ...

随机推荐

  1. Java笔记 – JDBC编程

    JDBC通过分层技术实现了跨数据库编程.为不同的数据库开发了统一的编程接口,为不同的数据库提供了不同的JAR类库. 一.JDBC基础 1.开发环境 (1)下载对应的Jar包 Oracle的本地Jar包 ...

  2. redis服务后台运行

    文章目录 进入redis的安装目录 查看目录结构 进入src目录,普通启动效果 编辑redis服务目录下的redis.conf 进入src目录,执行后台运行的命令 检查服务是否开启 进入redis的安 ...

  3. JS typeof() parseInt() parseFloat()

    判断变量的数据类型:typeof() 使用一元运算符typeof(),可以测试一个变量的类型. typeof()测试的结果是一个类型字符串. typeof()的结果字符串有几种情况: “string” ...

  4. niginx相关命令及代理配置

    安装 in mac https://www.cnblogs.com/meng1314-shuai/p/8335140.html Nginx相关命令 mac下启动: 通过brew 安装install 后 ...

  5. 20.multi_case04

    import aiohttp import asyncio import ssl async def fetch(session, url): async with session.get(url,s ...

  6. 16.ajax_case09

    import requests import json import re from selenium import webdriver from selenium.webdriver.common. ...

  7. <每日一题>题目5:生成器表达式面试题

    题目: def demo(): for i in range(4): yield i g = demo() g1 = (i for i in g ) g2 = (i for i in g1) prin ...

  8. Python版本OpenCV安装配置及简单实例

    # 2018-06-03 # 1. Python下载:https://www.python.org/downloads/ 选择对应平台对应版本的的Python进行安装. 2. Python版OpenC ...

  9. linux流量监控iftop命令安装详解

    iftop跟nload差不多,也是捕获网卡流量的命令,nload的安装见之前发布的教程:http://www.cnblogs.com/catlee/p/5703541.html 开始安装.本文以cen ...

  10. css3 html5 手机设备 列表的弹回和加速移动

    <style type="text/css"> * { margin: 0; padding: 0; } .min { width: 350px; height: 40 ...