admin管理员组文章数量:1425819
I would like to know how to extract the raw data from a html5 canvas as raw bitmap pixel data and store it in a variable.
So far I have setup my html5 canvas with an image in it: /
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("myimg");
ctx.drawImage(img,0,0);
var bitmapData;
//retrieve image data as raw bitmap
I would like to know how to extract the raw data from a html5 canvas as raw bitmap pixel data and store it in a variable.
So far I have setup my html5 canvas with an image in it: https://jsfiddle/t21mjh5L/1/
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("myimg");
ctx.drawImage(img,0,0);
var bitmapData;
//retrieve image data as raw bitmap
Share
Improve this question
asked Jan 6, 2016 at 18:53
user1869257user1869257
5054 gold badges7 silver badges18 bronze badges
1
- Have you seen this older question? – Pointy Commented Jan 6, 2016 at 18:54
1 Answer
Reset to default 2you can try to get bitmap data like this :
var myImageData = ctx.getImageData(left, top, width, height).data;
More information about getting image data can be found here
本文标签: htmlHow do I retrieve raw bitmap data from html5 canvas using JavaScriptStack Overflow
版权声明:本文标题:html - How do I retrieve raw bitmap data from html5 canvas using JavaScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745453765a2659006.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论