在canvas.draw回调内调用canvasToTempFilePath生成图片不完整?
发布于 5 年前 作者 lixiulan 1538 次浏览 来自 问答
     ctx.draw(falsefunction() {

        console.log(w, h, "canvasToTempFilePath")
        setTimeout(function () {
          wx.canvasToTempFilePath({
            width: w,
            height: h,
            fileType'jpg',
            canvasId`bgcavas${bgId}`,
            successfunction (res{
              wx.getImageInfo({
                src: res.tempFilePath,
                successinfo => {
                  console.log(info, "info")
                }
              })
              that.setData({
                bgImg: res.tempFilePath
              });
            },
            completeres => {
              if (res.errMsg == 'canvasToTempFilePath:ok') {
                that.setData({
                  bgImg: res.tempFilePath
                })
              } else {
                console.error('cavas 绘制图片错误')
              }
            }
          }, that)
        }, 3000)
      }); //开始绘制

这是cavas绘制的图片

使用api保存后的图片

1 回复

你好,请使用新的canvas实现:小程序新 Canvas 接口公测? - 微信开放社区 https://developers.weixin.qq.com/community/develop/doc/00020a02c2c040114d19a398f5b001

回到顶部