失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > html5 更新图片颜色示例代码技巧

html5 更新图片颜色示例代码技巧

时间:2019-04-29 14:31:07

相关推荐

html5 更新图片颜色示例代码技巧

web前端|H5教程

html5,图片颜色

web前端-H5教程

dvd成源码怎么安装教程,vscode简化特效,ubuntu 科研,tomcat环境变了,sqlite 读取速度,网站 租用服务器,WordPress 插件调试,前端框架小汇总,python爬虫与反爬虫开发,php球料,网站SEO优化费用,帐号分享网站源码,易语言网页采集视频教程,全屏幕网站模板,整个页面居中代码,金库管理系统,VIP 访客程序lzw

复制代码代码如下:

c udp 广播 点对点源码,vscode c 连接,ubuntu命名,cmd tomcat版本,sqlite跨库导入数据,3.3.5全套插件,后端开发需要掌握的前端框架,爬虫如何解决高并发,php url路径,版纳seo培训招生,网站的代码下载,产品 网页 模板,微信页面模板 源码lzw

var cID = “c1”;

var image = new Image();

image.src = “Eye/item_eye_1.jpg”;

image.onload = function () {

recolorImage(cID,image, 0, 0, 0, 255, 0, 0);

}

function recolorImage(c,img, oldRed, oldGreen, oldBlue, newRed, newGreen, newBlue) {

var c = document.getElementById(c);

var ctx = c.getContext(“2d”);

var w = img.width;

var h = img.height;

c.width = w;

c.height = h;

// draw the image on the temporary canvas

ctx.drawImage(img, 0, 0, w, h);

// pull the entire image into an array of pixel data

var imageData = ctx.getImageData(0, 0, w, h);

// examine every pixel,

// change any old rgb to the new-rgb

for (var i = 0; i < imageData.data.length; i += 4) {

// is this pixel the old rgb?

if (imageData.data[i] == oldRed && imageData.data[i + 1] == oldGreen && imageData.data[i + 2] == oldBlue) {

// change to your new rgb

imageData.data[i] = newRed;

imageData.data[i + 1] = newGreen;

imageData.data[i + 2] = newBlue;

}

}

// put the altered data back on the canvas

ctx.putImageData(imageData, 0, 0);

}

h5地区源码,ubuntu使用KVM教程,脊针爬虫攻击,php button,seo神器applzw

如果觉得《html5 更新图片颜色示例代码技巧》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。