canvas将文字图片绘制至画布再导出为什么都是都是模糊的?
发布于 4 年前 作者 yong62 3320 次浏览 来自 问答

canvas将文字图像(drawImage)绘制到画布上,再把当前画布图像内容导出生成图片draw(false, () => {wx.canvasToTempFilePath(Object object, Object this)}),合成后的图片都是模糊的,无论在开发者工具或是真机调试都是模糊的。请问canvas处理图像(如,resize或其他合成操作),再导出图像都是模糊失真的吗?

   // 将图像绘制到画布,width&height为图像等比例缩放后的宽高,originWidth&originHeight为图像原图宽高
   this.ctx.drawImage(path, x, y, width, height) 
   // 将在绘图上下文中的描述(路径、样式)画到 canvas 中,并把当前画布指定区域的内容导出生成指定大小的图片
    this.ctx.draw(false, () => {
      Taro.canvasToTempFilePath({
        canvasId: this.ctx.canvasId,
        x,
        y,
        width: originWidth,
        height: originHeight,
        destWidth: originWidth,
        destHeight: originHeight,
        // width: this.canvasWidth,
        // height: this.canvasHeight,
        // destWidth: this.canvasWidth,
        // destHeight: this.canvasHeight,
        // quality: 1,
        success: (res) => {
          console.log('导出新图:', res.tempFilePath)
          Taro.saveImageToPhotosAlbum({
            filePath: res.tempFilePath
          })
        }
      }, this)
    })
1 回复

canvas设置成两倍大试试?

回到顶部