JavaScript过滤器图像颜色 [英] JavaScript filter image color

查看:182
本文介绍了JavaScript过滤器图像颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我正在寻找一个方法来采取一个黑白的 img 元素,并使用JavaScript,指定一个RGB值,使图像变成这种颜色。任何想法(除了图书馆)?



我也试图这样做与IE只。

解决方案

在Internet Explorer中,我在IE中执行此操作的原因是因为我在制作一个小的侧边栏小工具。您可以使用可视化过滤器。 / p>

编辑:您要使用光过滤器,这里是一个例子

  .aFilter {
filter:light();
}
< / STYLE>
< SCRIPT>
window.onload = fnInit;
function fnInit(){
oDiv.filters [0] .addAmbient(50,20,180,100);
}
< / SCRIPT>
with filter:< img CLASS =aFilterID =oDivsrc =http://cache2.artprintimages.com/p/LRG/8/853/2USY000Z/black-and-white-cats .jpg>

without:< img src =http://cache2.artprintimages.com/p/LRG/8/853/2USY000Z/black-and-white-cats.jpg>


Hey, I'm looking for a way to take a black and white img element, and using JavaScript, specify an RGB value so that the image becomes that color. Any ideas (aside from libraries)?

Also I'm trying to do this with IE only. The reason I'm doing it in IE only is because I'm making a small sidebar gadget.

解决方案

In Internet Explorer, you could use Visual Filters.

Edit: you want to use the Light filter, here is an exemple

<STYLE>
   .aFilter {
            filter:light();
        }
</STYLE>
<SCRIPT>
window.onload=fnInit;
function fnInit(){
   oDiv.filters[0].addAmbient(50,20,180,100);
}
</SCRIPT>
with filter: <img CLASS="aFilter" ID="oDiv" src="http://cache2.artprintimages.com/p/LRG/8/853/2USY000Z/black-and-white-cats.jpg">

without: <img src="http://cache2.artprintimages.com/p/LRG/8/853/2USY000Z/black-and-white-cats.jpg">

这篇关于JavaScript过滤器图像颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆