html5 canvas toDataURL在移动设备上的图像质量很差

html5 canvas toDataURL poor image quality on mobile

本文关键字:图像质量 canvas toDataURL 移动 html5      更新时间:2023-09-26

我使用toDataURL("image/png")函数。我的画布有几条线,彩色的形状和文字。生成的png在桌面Chrome上看起来不错。然而,在移动Chrome上,图像质量非常低,像素化。

有没有办法提高移动设备的图像质量?

你可以设置画布的CSS大小小于画布元素的大小。

这会导致浏览器在画布上画得更"密集"。

HTML:

<canvas id="canvas" width=600 height=300></canvas>
CSS:

#canvas {
    width:300px;
    height:150px;
}        

示例:http://jsfiddle.net/m1erickson/N8JL6/