canvasPutImageData修改颜色一致报错 {"errMsg":"canvasPutImageData:fail"}
uni.canvasGetImageData({
canvasId: 'canvasImg',
x: 0,
y: 0,
width: uni.upx2px(640),
height: uni.upx2px(640),
success(res) {
for(let i = 0; i < res.height; ++i){
for(let j = 0; j < res.width; ++j){
let x = i*4*res.width + 4*j;
res.data[x] = 22;
res.data[x+1] = 333;
res.data[x+2] = 55;
}
}
uni.canvasPutImageData({
canvasId: 'canvasImg',
x: 0,
y: 0,
width: uni.upx2px(640),
height: uni.upx2px(640),
data: (res.data),
success() {
console.log(11)
},
fail(e) {
console.log(22)
}
});
}
});
0 个回复