After putimagedata of canvas, the color value of rgba obtained by getimagedata is incorrect.

After the putimagedata of

canvas, the color value of rgba obtained by getimagedata is not correct

< hr >

let canvas = document.querySelector ("- sharpcanvas");
let cxt = canvas.getContext ("2d");
let imageData = cxt.createImageData (2d2);
for (var iTuno (I < imageData.data.length;i+=4) {

imageData.data[i+0]=64;
imageData.data[i+1]=55;
imageData.data[i+2]=235;
imageData.data[i+3]=133;

}
cxt.putImageData (imageData,0,0)

< hr >

then getImageData
0:63
1:56
236
3
.

this is the result of running under chrome, and the result under firefox is not the same

is really crazy. I need accurate color values in my business, so I can"t do it at all.

who knows why or what the solution is

Mar.28,2021

seems to have something to do with transparency. I don't understand


canvas would lost accurate data when opacity isn't equal to 255

.
Menu