Fabricjs HTML5 Canvas:为什么图像大小调整得这么差?

Fabricjs HTML5 Canvas: Why are images so poorly resized?(Fabricjs HTML5 Canvas:为什么图像大小调整得这么差?)
本文介绍了Fabricjs HTML5 Canvas:为什么图像大小调整得这么差?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将 775 x 775 的图像添加到 fabricjs 画布并将其调整到大约 90 x 90 时,图像的质量会大大降低.

When I add a 775 x 775 image to a fabricjs canvas and resize it down to around 90 x 90, the image greatly loses its quality.

但是,如果我将相同的图像添加为 <img/> 并将其缩小,它会保留其质量.

But if I add that same image as an <img/> and scale it down, it retains its quality.

为什么画布图像变得如此低质量?如何使画布图像像 <img/> 一样保持其原始质量?

Why does the canvas image become so low quality? How can I make the canvas image retain it's original quality like the <img/> does?

推荐答案

应该可以去评论一下,可惜我是新手,不能加评论.但是,对我来说,这看起来像是抗锯齿问题.画布只是一堆像素 - 是否进行抗锯齿取决于您.然而,浏览器会对图片缩放进行一些抗锯齿(请参阅此处缩放图像时禁用抗锯齿).

It should probably go for a comment, but unfortunately I am new here and I can't add comments. However, to me it looks like antialiasing issue. Canvas is just bunch of pixels - it's up to you whether you do some antialiasing or not. Browsers however do some antialiasing on picture scaling (see here Disable antialising when scaling images).

此问题可能与以下问题重复:

This question might be a duplicate of:

Html5 canvas drawImage:如何应用抗锯齿

HTML5 画布和抗锯齿

希望对你有帮助.

这篇关于Fabricjs HTML5 Canvas:为什么图像大小调整得这么差?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

how to remove this error quot;Response must contain an array at quot; . quot;.quot; while making dropdown(如何删除此错误quot;响应必须在quot;处包含数组。创建下拉菜单时(Q;))
Why is it necessary to use `document.createElementNS` when adding `svg` tags to an HTML document via JS?(为什么在通过JS为一个HTML文档添加`svg`标签时,需要使用`Document.createElementNS`?)
wkhtmltopdf print-media-type uses @media print ONLY and ignores the rest(Wkhtmltopdf print-media-type仅使用@media print,而忽略其余内容)
price depend on selection of radio input(价格取决于无线电输入的选择)
calculate price depend on selection without button(根据没有按钮的选择计算价格)
What should I consider before minifying HTML?(在缩小HTML之前,我应该考虑什么?)