生成画布图片失败!
发布于 6 年前 作者 yanggao 12134 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo
wx.canvasToTempFilePath({
            x: 0,
            y: 0,
            width: 600,
            height: 950,
            destWidth: posterWidth * 4,
            destHeight: posterHeight * 4,
            canvasId: 'shareImgOne',
            success: function (res) {
              console.log(res.tempFilePath);
              that.setData({
                shareImgSrc: res.tempFilePath
              })
              //wx.saveImageToPhotosAlbum将图片保存到本地  3
              wx.saveImageToPhotosAlbum({
                filePath: that.data.shareImgSrc,
                success(res) {
                  wx.hideLoading();
                  wx.showModal({
                    title: '存图成功',
                    content: '图片成功保存到相册了,去发圈噻~',
                    showCancel: false,
                    confirmText: '好哒',
                    confirmColor: '#72B9C3',
                    success: function (res) {
                      if (res.confirm) {
                        that.setData({
                          bigModel: false
                        })
                        console.log('用户点击确定');
                      }
                    }
                  })
                }
              })
            },
            fail: function (res) {
              console.log(res);
              that.setData({
                bigModel: false
              })
            }
          });

总是提示canvasToTempFilePath:fail:create bitmap failed,搞不懂啥原因

posterWidth

posterHeight

这两个是屏幕的宽高

2 回复

你好,麻烦在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点

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

回到顶部