收藏
回答

canvasToTempFilePath 导出图片尺寸实际效果有误

wx.canvasToTempFilePath({

      canvasId: "myCanvas",

      x: 0,

      y: 0,

      width: parseInt(imgInfo.width ),

      height: parseInt(imgInfo.height),

      destWidth: parseInt(imgInfo.width / 2),

      destHeight: parseInt(imgInfo.height / 2),

      success(res) {

        console.log(res);

        self.setData({ compressImageUrl: res.tempFilePath })

        uploadFileOss(

          res.tempFilePath,

          function (fileUrl) {

            console.log('uploadFile', fileUrl)

            self.setData({ compressImageUrl: fileUrl })

          },

          function (err) {

            console.log('err', err)

          })

      },

      fail(info) {

        console.log('myCanvas');

        console.log(info);

      }

    })

实际导出来图片效果如下  黑色部分是透明的


回答关注问题邀请回答
收藏

1 个回答

  • Wang
    Wang
    2018-11-26

    把这几个设为一样大小:

    width: parseInt(imgInfo.width ),

          height: parseInt(imgInfo.height),

          destWidth: parseInt(imgInfo.width / 2),

          destHeight: parseInt(imgInfo.height / 2),


    2018-11-26
    有用
    回复
登录 后发表内容