我有这样的画布
<canvas id="canvas" width="600px" height="300px"></canvas>
现在我正在尝试在大约 260px 宽度和高度的画布内显示图像。但它在画布中全屏显示图像。我做错了什么?
img.onload = function(){
var im = this;
var imgWidth = im.width;
var imgHeight = im.height;
var imgScaledWidth = 0;
var imgScaledHeight = 0;
imgScaledHeight = self.conHeight - 40;
imgScaledWidth = imgScaledHeight * (imgWidth/imgHeight);
self.context.drawImage(this, 0,0,imgScaledWidth,imgScaledHeight);
}
它的显示是这样的