获取 canvas 及 canvas context
// wxml type="2d" 是必须的
// js
wx.createSelectorQuery()
.select('#myCanvas').node().exec((res) => {
this.myCanvas = res[0].node
this.myCanvasCtx = this.myCanvas.getContext('2d')
})
canvas 转 base64
let ctxImageData = this.myCanvasCtx.createImageData(width, height);
ctxImageData.data.set(data)
this.myCanvasCtx.putImageData(ctxImageData, 0, 0)
let base64 = this.myCanvas.toDataURL("image/png", 0.7);
这个data是uvbuffer和ybuffer合并后的arraybuffer数据吗