【问题标题】:How to increase the size of the downloaded image from canvas with fabricjs?如何使用fabricjs增加从画布下载的图像的大小?
【发布时间】:2017-11-14 00:23:39
【问题描述】:

我正在使用以下内容下载我的 fabricjs 画布,效果很好,但我想知道如何才能使下载的图像更大,以便在打印时更清晰?感谢您提前提供任何帮助。

// Download as png
function download(url, name) {
  // make the link. set the href and download. emulate dom click
  $('<a>').attr({
    href: url,
    download: name
  })[0].click();
}

function downloadFabric(canvas, name) {
  //  convert the canvas to a data url and download it.
  download(canvas.toDataURL(), name + '.png');
}

<button onclick="downloadFabric(canvas,'save');">Save</button>

【问题讨论】:

标签: javascript canvas fabricjs


【解决方案1】:

这最终类似于this post。从那里我能够工作,将{multiplier: 4} 添加到canvas.toDataURL(); 工作出色。

【讨论】:

    【解决方案2】:

    您可以将画布的宽度和高度设置为大于显示尺寸。

    <canvas width="2400" height="2400" style="width:600px;height:600px;"></canvas>
    

    因为渲染png 指的是画布widthheight

    FIDDLE(你可以从fiddle得到2400x2400的图片)

    【讨论】:

      猜你喜欢
      • 2018-08-02
      • 2016-08-25
      • 2017-07-05
      • 1970-01-01
      • 2016-05-30
      • 1970-01-01
      • 1970-01-01
      • 2017-05-09
      • 1970-01-01
      相关资源
      最近更新 更多