小程序代码:
wx.canvasGetImageData({
canvasId: ‘PaperCanvas’,
x: 0,
y: 0,
width: 100,
height: 100,
success:function(res) {
console.log(res.width) // 100
console.log(res.height) // 100
console.log(res.data instanceof Uint8ClampedArray) // true
console.log(res.data.length) // 100 * 100 * 4
let pngData = upng.encode([res.data.buffer], res.width, res.height)
let base64 = wx.arrayBufferToBase64(pngData)
},
fail: function (res) {
console.log(res);
return ‘’
}
}, this)
运行后报错:
errMsg:“canvasGetImageData: fail canvas is empty”
请帮忙解答,多谢各位!