Why function returns wrong color in canvas?
问题 My canvas color is 50 255 50 155. When I do a code: function getClickedAreaColor(x, y) { var data = ctx.getImageData(x, y, 1, 1).data, color = []; for (var i = 0; i < data.length; i++) { color.push(data[i]); } return color; } It returns 49 255 49 155 Why is that? 回答1: There is a note in the specs for the getImageData method for such situations: Due to the lossy nature of converting to and from premultiplied alpha color values, pixels that have just been set using putImageData() might be