getImageData in Animate CC
Hi all,
I'm trying to use getImageData to detect the alpha value of pixels but I couldn't do it correctly, wondering if anyone knows how to do that?
Here's the code I wrote, can't get any image data. ![]()
var ctx = canvas.getContext('2d');
var bmp1 = new createjs.Bitmap('http://lorempixel.com/400/200/sports/Dummy-Text/')
bmp1.image.onload = function()
{
stage.addChild(bmp1);
//ctx.drawImage(bmp1, 0, 0, 400, 200); //this line cause error
var imageData = ctx.getImageData(0, 0, 400, 200);
console.log(imageData.data[3]);
}
Thanks in advance,
Chih Wei
