我正在尝试导出 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().
这篇关于canvas.toDataURLWithMultiplier 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!