Firefox throwing a exception with HTML Canvas putImageData

前端 未结 7 936
Happy的楠姐
Happy的楠姐 2021-01-04 09:12

So I was working on this little javascript experiment and I needed a widget to track the FPS of it. I ported a widget I\'ve been using with Actionscript 3 to Javascript and

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 10:06

    I was having similar problem with drawImage(), when attempted to draw a tile on a canvas of the same size in this manner:

    var image = new Image();
         image.onload = function() {
             context.drawImage(image, 0, 0, this.tileSize, this.tileSize);
           }
         image.src = this.baseURL + tileId;
    

    The problem disappeared, when I removed height and width parameters from the call and used this:

    context.drawImage(image, 0, 0);
    

提交回复
热议问题