admin管理员组文章数量:1296307
I would like to pare two images with javascript. One is drawn on a html5 canvas the other might be on another html5 canvas, or it might be a gif- or png-image-file. I need the parision for automated testing. Thanks for help!
I would like to pare two images with javascript. One is drawn on a html5 canvas the other might be on another html5 canvas, or it might be a gif- or png-image-file. I need the parision for automated testing. Thanks for help!
Share Improve this question asked Dec 1, 2011 at 12:59 user1027167user1027167 4,4587 gold badges35 silver badges41 bronze badges1 Answer
Reset to default 10alright this isn't a plete solution for your problem but it might help you find a good way to pare the two canvas elements.
var ctx = canvas.getContext('2d');
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
var pixels = imageData.data;
for(var i = 0, il = pixels.length; i < il; i++) {
// pixels[i]
}
This is a basic example how to loop through all the pixels on the canvas. Depending on what you want to do you can pare the pixels with each other or you might want to pare the two imageData
vars with each other
本文标签: javascriptHow to compare content of two html5canvaselementsStack Overflow
版权声明:本文标题:javascript - How to compare content of two html5-canvas-elements? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741631333a2389384.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论