javascript 模糊 HTML5 画布
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14751032/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Blur HTML5 Canvas
提问by starbeamrainbowlabs
How can I blur the contents of an HTML5 canvas?
如何模糊 HTML5 画布的内容?
I know that I can use CSS, but I need to blur the contents of the canvas so that I can manipulate it later.
我知道我可以使用 CSS,但我需要模糊画布的内容,以便我以后可以对其进行操作。
采纳答案by Philipp
There is no native function to do that. But you can implement your own image filter operations by using context.getImageData
to get an array of raw RGBA values of the canvas data, do your filter operation on that data, and then write it back with context.putImageData
.
没有本机功能可以做到这一点。但是您可以通过使用context.getImageData
获取画布数据的原始 RGBA 值数组来实现自己的图像过滤操作,对该数据执行过滤操作,然后使用context.putImageData
.