I can't seem to figure out how to draw an image on canvas. Drawing a
rectangle works.
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
ctx.fillStyle = "rgba(0,0,255,255)";
ctx.fillRect(0,0,16,16);
return ctx.getImageData(0,0,16,16);
}
But this doesn't.
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
var img = new Image();
img.src = "data:image/png;base64,...";
ctx.drawImage(img,0,0);
return ctx.getImageData(0,0,16,16);
}
And replacing img.src with either of these doesn't work either.
img.src = '1.png';
img.src = chrome.extension.getURL('1.png');
--
You received this message because you are subscribed to the Google Groups
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/chromium-extensions?hl=.