4***@qq.com
4***@qq.com
  • 发布:2020-02-19 17:53
  • 更新:2020-02-19 17:53
  • 阅读:920

canvasPutImageData无法修改颜色

分类:uni-app

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)  
                        }  
                    });  
              }  
        });
2020-02-19 17:53 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复