如何使用Javascript将彩色图像转换为黑色/白色? [英] How do you convert a color image to black/white using Javascript?
问题描述
如何使用Javascript将彩色图片转换为黑白图片?
还可以使它在大多数浏览器因为我听说Internet Explorer有一个过滤器机制,但没有其他浏览器支持它。
AND, also make it cross compatible in most browsers because I hear Internet Explorer has a "filter" mechanism but no other browsers support it.
推荐答案
尽管我最初的怀疑,这样的魔法确实是可能的,在一些浏览器中使用新的Canvas功能。
Despite my initial scepticism it appears that such magic is indeed possible, using the new Canvas functionality in some browsers.
此页面显示如何使用支持Canvas的浏览器:
This page shows how to do it using browsers that support Canvas:
http://www.permadi.com/tutorial/jsCanvasGrayscale/index.html
对于IE,您需要使用过滤器,这里有一个做灰度的示例:
For IE you need to use filters, there is an example of doing greyscale here:
http://www.javascriptkit.com/filters/basicimage.shtml
这篇关于如何使用Javascript将彩色图像转换为黑色/白色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!