收藏
回答

华为META9机器canvas.drawImage后canvasToTemp图片大小不对?

机型:HUAWEI META9

机型:HUAWEI META9 MHA-AL00

微信版本号:7.0.7

系统版本号:8.0.0

能复现问题的代码片段:

wx.getImageInfo({
        src: imagePath,
        success: function (res) {
 
          // 生成指定宽度的图片
          that.setData({
            canvasWidth: canvasWidth,
            canvasHeight: canvasHeight 
          })
          var ctx = wx.createCanvasContext('tmpImage');
          ctx.drawImage(imagePath, 0, 0, canvasWidth, canvasHeight );
          ctx.draw(false, function() {
            //保存临时文件
            wx.canvasToTempFilePath({
              canvasId: 'tmpImage',
              fileType: 'jpg',
              success: function (res) {
                console.log(res.tempFilePath)
              },
              fail: function (error) {
                console.log(error)
                reject(error)
              }
            })
          })
        }
      }) 
    })


最后一次编辑于  11-28
回答关注问题邀请回答
收藏

2 个回答

问题标签