如何将ArrayBuffer 转换成 Uint8ClampedArray?

发布于 8 年前作者 chaoguo13732 次浏览最后编辑 8 年前来自 ask
  • 需求的场景描述(希望解决的问题)

将云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);
      }
    })
  • 希望提供的能力
2 回复
weixue
weixue1 楼6 年前

同问

wtan
wtan2 楼6 年前

同问