如何将ArrayBuffer 转换成 Uint8ClampedArray?
发布于 6 年前 作者 chaoguo 13520 次浏览 来自 问答
  • 需求的场景描述(希望解决的问题)

将云API生成的小程序二维码 arraybuffer 变成Uint8ClampedArray  ,然后通过画布保存下来。

const data = new Uint8ClampedArray(this.data.imageByteArray);
    wx.canvasPutImageData({
      canvasId: 'firstCanvas',
      x: 0,
      y: 0,
      width: 308,
      height:308,
      data: data,
      success(res) {
        wx.canvasToTempFilePath({
          x: 0,
          y: 0,
          width: 308,
          height: 308,
          destWidth: 308,
          destHeight: 308,
          canvasId: 'firstCanvas',
          success(res) {
            console.log(res.tempFilePath)
          }
        })
      },
      fail(e){
        console.error(e);
      }
    })
  • 希望提供的能力
回到顶部