Reputation: 44609
I have a weird bug on the lastest chrome (v27 on Windows 7) using Canvas and drawImage. The bug only occur on Chrome, everything works as expected on Firefox and IE.
I created a failing reduce test case here: http://jsfiddle.net/qU3s5/
HTML
<canvas id="canvas"></canvas>
JavaScript
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var img = new Image();
img.onload = function() {
ctx.drawImage(this, 0, 0);
}
img.src = "http://octodex.github.com/images/foundingfather_v2.png";
This give me Uncaught TypeError: Type error
on the line where drawImage
is called.
Upvotes: 3
Views: 4891
Reputation: 44609
Apparently Chrome throw an error when using new Image()
. You have to use this instead:
var img = document.createElement('img');
Updated fiddle: http://jsfiddle.net/aM8aA/
Here's the related Chromium project bug report: https://code.google.com/p/chromium/issues/detail?id=238071
Upvotes: 12