canvas.toDataURLWithMultiplier 不是函数
我正在尝试导出 4 倍于画布大小的图像.
I am trying to export an image 4x the size of the canvas one.
与
var dataURL = canvas.toDataURL();
我将图像设置为画布的大小
I get the image set to the size of the canvas
但是当我尝试时
var dataURL = canvas.toDataURLWithMultiplier(4);
我收到错误canvas.toDataURLWithMultiplier 不是函数"
I get the error "canvas.toDataURLWithMultiplier is not a function"
下面是我的函数.
$('.preview').on('click touchstart', function() {
// save canvas image as data url (png format by default)
canvas.isGrabMode = false;
canvas.setZoom(1.0);
canvas.viewportTransform = [1, 0, 0, 1, 0, 0];
// var dataURL = canvas.toDataURL();
var dataURL = canvas.toDataURLWithMultiplier(4);
// so it can be saved as an image
document.getElementById('previewImg').src = dataURL;
canvas.renderAll();
});
推荐答案
var dataURL = canvas.toDataURL({
format: 'png',
multiplier: 4
});
在 toDataURL()multiplier 属性>.
Use multiplier
property in toDataURL().
相关文章