canvas.toDataURLWithMultiplier is not a function(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().
这篇关于canvas.toDataURLWithMultiplier 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:canvas.toDataURLWithMultiplier 不是函数


基础教程推荐
- Bootstrap 模态出现在背景下 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01