本文介绍了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
});
在。
Use multiplier
property in toDataURL().
这篇关于canvas.toDataURLWithMultiplier不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!