SVG filter taints canvas

时间:2018-07-30 21:23:04

标签: javascript html5 svg canvas

I've been trying to fight HTML5 Canvas anti-aliasing by filtering the canvas with this svg filter (from a stackoverflow-post):

<svg width="0" height="0" style="position:absolute;z-index:-1;" >
  <defs>
     <filter id="remove-alpha" x="0" y="0" width="100%" height="100%" >
         <feComponentTransfer>
             <feFuncA type="discrete" tableValues="0 1"></feFuncA>
         </feComponentTransfer>
     </filter>
  </defs>
</svg>

and then applying the filter to the canvas with

ctx.filter ='url(#remove-alpha)';

Everything works great, until I want to read from the canvas with getImageData()。我已经了解到,画布是通过使用SVG获得tainted的。我想知道是否有适合我的解决方法,因此我仍然可以使用“ alpha过滤器”而不弄脏画布。

0 个答案:

没有答案