统一三倍canvas画图,然后正常导出
canvas.width = canvasWidth*3;
canvas.height = canvasHeight*3;
ctx.drawImage(image, 0, 0, canvasWidth*3, canvasHeight*3);
wx.canvasToTempFilePath({
width: canvasWidth*3,
height: canvasHeight*3,
destWidth: canvasWidth,
destHeight: canvasHeight,
canvas: canvas,
success(res) {
resolve(res.tempFilePath);
},
fail(error) {
reject(error)
}
})
这样导出的图片就会清晰很多了
通过将canvas的宽度和高度设置为原始尺寸的三倍,然后使用ctx.drawImage绘制图像,并在导出时保持原始宽高比,可以显著提高导出图片的清晰度。wx.canvasToTempFilePath方法用于实现这个过程。
3867

被折叠的 条评论
为什么被折叠?



