收藏
回答

vivo手机wx.canvasToTempFilePath设置参数后生成的图片歪曲?

API:wx.canvasToTempFilePath

微信版本号:8.0.27

问题描述:我使用wx.canvasToTempFilePath()方法导出图片:不带参数时,图片能够正常导出;带参数时,vivo手机的图片永远是横向倾斜45°,别的机型似乎是正常的,这让我很困惑……

// 绘制临时图片
    async onDraw() {
        wx.showLoading({
          title'图片生成中',
        })
        const query = wx.createSelectorQuery()
        const canvasObj = await new Promise((resolve, reject) => {
            query.select('#myCanvas')
                .fields({ nodetruesizetrue })
                .exec(async (res) => {
                    resolve(res[0].node)
                })
        })
        let that = this
        wx.canvasToTempFilePath({
            canvas: canvasObj,
            fileType'jpg',
            // x: this._canvasX,    // 以下参数设置后vivo手机内导出的图片就会异常,而华为、苹果的机型则正常
            // y: this._canvasY,
            // width: this._canvasWidth,
            // height: this._canvasHeight,
            // destWidth: this._destWidth,
            // destHeight: this._destHeight,
            success(res) {
                wx.hideLoading()
                that.setData({
                    orderImage: res.tempFilePath,
                })
            }
        })
    },

主要是项目中对图片的宽高有要求,若不带参数则不同机型生成的图片似乎大小差异比较大,且仅需要截取canvas中的部分生成图片,因此带参数生成的图片更符合项目的需求,求大神帮我指条明路……


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

1 个回答

  • Riven.
    Riven.
    2022-09-04

    你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

    2022-09-04
    有用
    回复 1
    • 三孚
      三孚
      2022-09-05
      谢谢,当天晚上这个bug就恢复正常了(3台vivo手机同时出现该问题,又同时恢复……)代码没变bug就自动消失了……
      2022-09-05
      回复
登录 后发表内容