canvas 生成图片 模糊
发布于 5 年前 作者 weihao 9566 次浏览 来自 问答

根据手机屏幕宽度设定canvas的宽度

根据9:16的比例设置高度

绘画出图像

保存图片

尺寸(不知道这么设置对不对)

    destWidth等于canvas宽度

    destHeight等于canvas高度

    width等于canvas宽度

    height等于canvas高度

保存后的图片非常模糊,由于上面绘制小程序码   根本就扫不出来

    不知道如何设置不模糊

    

4 回复

请问这个问题解决了么?我使用canvas绘制出来的 海报 ,海报上的文字绘制出来有锯齿。

是不是用canvas宽度*设备像素比

wx.canvasToTempFilePath({

     width:that.data.canvasWidth,

     height: that.data.canvasHeight,

     destWidth: that.data.canvasWidth*that.data.pixelRatio,

     destHeight: that.data.canvasHeight * that.data.pixelRatio,

    …

实测模糊

应该是受手机的 dpr 的影响,如手机 dpr 是 2 的话,canvas 的宽度应该是手机屏幕宽度的两倍才不会模糊

回到顶部