收藏
回答

canvasToTempFilePath将绘有文字的canvas转成图片,真机不显示?

真机 image不显示canvasToTempFilePath转出来的图片

wx.getImageInfo({
            src: imagePath,
            success:function(res){
              console.log("imgDetail-->imgSize:" + res.width + "*" + res.height);
              self.setData({
                canvasWidth: Number.parseFloat(res.width),
                canvasHeight: Number.parseFloat(res.height),
              })
              var context = wx.createCanvasContext("first");
              context.setFontSize(14)
              for(var index in showData){
                context.fillText(showData[index].words, showData[index].position.left, showData[index].position.top)
              }
              context.draw()

              context.draw(false, function () {
                wx.canvasToTempFilePath({
                  x: 0,
                  y: 0,
                  width: res.width,
                  height: res.height,
                  destWidth: res.width * 2,
                  destHeight: res.height * 2,
                  quality: 1,
                  canvasId: 'first',
                  success(res) {
                    console.log('绘制结果'+JSON.stringify(res))
                    self.setData({
                      imagePath: res.tempFilePath,
                    })
                  }
                })
              });
            }
          })

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

2 个回答

登录 后发表内容
问题标签