wx.canvasPutImageData绘制图片的width和height限制
我对于API:wx.canvasGetImageData和wx.canvasPutImageData非常疑惑,
wx.canvasGetImageData({
canvasId: 'myCanvas',
x: 0,
y: 0,
width: 100,
height: 100,
success(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
}
})
wx.canvasPutImageData({
canvasId: 'myCanvas'
x: 0,
y: 0,
width: 100,
height: 100,
data: data
success(res) {}
})
canvasGetImageData所截图获取的width和height,必须和canvasPutImageData设置的一样才能正确显示图片,如果canvasGetImageData的width和height设置为100,那么canvasPutImageData的width和height必须也设置为100,不然就会发生[object DOMException]渲染层错误
我想问,这是bug还是本身API就是这么限制的?因为我的理解是:canvasPutImageData不应该是把传入的数据自适应canvasPutImageData设置的宽高,达到放大或者缩小canvas操作的吗?