收藏
回答

pc端在canvas.draw回调内调用canvasToTempFilePath生成图片不全

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug canvasToTempFilePath 工具 3.1.0.67 2.15.0
上面是原图:

下面是draw后canvasToTempFilePath生成图片:

正常的pc:wx.getSystemInfoSync().pixelRatio: 1

不全的pc:wx.getSystemInfoSync().pixelRatio: 1.5

宽高打印出来的数据一致


html片段:

   
js片段:
ctx.draw(false, () => {
              wx.canvasToTempFilePath(
                {
                  x0,
                  y0,
                  // width: _this.data.boxWidth,
                  // height: _this.data.boxHeight,
                  width: tempPosition.dWidth,
                  height: tempPosition.dHeight,
                  // destWidth: _this.data.boxWidth * wx.getSystemInfoSync().pixelRatio,
                  // destHeight: _this.data.boxHeight * wx.getSystemInfoSync().pixelRatio,
                  // destWidth: tempPosition.dWidth * wx.getSystemInfoSync().pixelRatio,
                  // destHeight: tempPosition.dHeight * wx.getSystemInfoSync().pixelRatio,
                  destWidth: tempPosition.dWidth,
                  destHeight: tempPosition.dHeight,
                  fileType'png',
                  quality1,
                  canvasId'tempCanvas',
                  success(res) {
                    console.log('编辑成功', res.tempFilePath)
                    wx.hideLoading()
                    _this.triggerEvent('editorImageOk', {
                      tempFilePath: res.tempFilePath
                    })
                  },
                  fail() {
                    console.log('编辑失败', e)
                    wx.hideLoading()
                    wx.showToast({ title'保存失败'icon'none' })
                    _this.closelEditor()
                  }
                },
                _this
              )
            })

thinkpad笔记本,分辨率1920*1080,微信版本3.1.0.67, 小程序基础库2.15.0。
部分PC电脑版微信 小程序wx.canvasToTempFilePath生成图片显示不全。不是开发者工具!
最后一次编辑于  2021-02-24
回答关注问题邀请回答
收藏

3 个回答

  • 广
    广
    2022-11-09

    快两年了,, 楼主这个问题最后解决了吗 请指教

    2022-11-09
    有用
    回复
  • 行走的纪录片🐯
    行走的纪录片🐯
    2022-05-31

    这个问题最后咋解决哦 楼主 请指教

    2022-05-31
    有用
    回复
  • 太阳照耀我
    太阳照耀我
    2021-02-23

    你画布不全,不是这个方法问题

    2021-02-23
    有用
    回复 5
    • 松
      2021-02-23
      画布canvas是全的,可以画上。保存的时候只留下了左上1/2的图。是destWidth 导致的么?
      2021-02-23
      回复
    • 太阳照耀我
      太阳照耀我
      2021-02-23回复
      打印看呗
      2021-02-23
      回复
    • 陌上华年
      陌上华年
      2021-03-08回复
      兄弟解决了么?
      2021-03-08
      回复
    • 松
      2021-03-12回复陌上华年
      并没有,缩小可以看到效果,放大就只能到这了,显示不全。不知道是哪没算对。不全的pc:wx.getSystemInfoSync().pixelRatio: 1.5 跟这个有关
      2021-03-12
      回复
    • 陌上华年
      陌上华年
      2021-03-17回复
      看来只能判断是PC就把画板放大1.5,内容保存原来的尺寸生成,这坑爹的
      2021-03-17
      回复
登录 后发表内容
问题标签