我使用以下代码在画布上绘制图像
context.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
此代码工作正常,但当我使用大尺寸图像(大约1300 X 700)时,画布完全空白。
作为参考,我也提供了我用来获取图像的代码
var image = new Image();
image.setAttribute('crossOrigin', 'anonymous');
var img = "http://www.bigrhinos.com/ceabackend/index.php/drawingcontroller/getimage?level=1";
image.src = img;
答案 0 :(得分:0)
加载图像后绘制。
var image = new Image();
image.setAttribute('crossOrigin', 'anonymous');
image.src='http://www.bigrhinos.com/ceabackend/index.php/drawingcontroller/getimage?level=1';
image.addEventListener('load', function() {
context.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
});