html - How do I retrieve raw bitmap data from html5 canvas using JavaScript? - Stack Overflow

I would like to know how to extract the raw data from a html5 canvas as raw bitmap pixel data and store

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
Add a ment  | 

1 Answer 1

Reset to default 2

you 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745453765a4628390.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信