$.fn.imageCanvas = function() {
if (!document.getElementById('bgCanvas')){
$('body').append($('<canvas>',{id:'bgCanvas', width:'500px', height: '500px'}))
var canvas = document.getElementById('bgCanvas');
var ctx = canvas.getContext('2d');
}
var img = new Image();
img.onload = function() {
ctx.drawImage(img,0,0,438,300);
console.log(this.width);
console.log(this.height);
}
img.src= 'http://www.html5canvastutorials.com/demos/assets/darth-vader.jpg';
}
在 ctx.drawImage 我写了 x,y,width,height。但是画布拉伸了这个图像。如何使用原始宽度/高度进行图像处理