I reread a bunch of examples, "how to find out the color of a pixel on the canvas." But whether I'm a fool (which is likely), or ...
In the code, I first fill the entire canvas with blue, then draw a picture on it. Clicking on canvas displays a message with a pixel color. But whatever picture I flooded, the conclusion is 0,0,255. If you do not fill with color, then 0,0,0.
<script type="text/javascript"> function Draw(){ var canvas=document.getElementById("can"); var ctx=canvas.getContext("2d"); ctx.fillStyle='#00f'; ctx.fillRect(0,0,200,200); var image=new Image(); image.src="./img.bmp"; image.onload=function(){ ctx.drawImage(image,0,0); } var img_data=ctx.getImageData(0,0,200,200); canvas.onclick=function(e){ var x=e.offsetX; var y=e.offsetY; var pix=img_data.data; var i=((y*200)+x)*4; var R=pix[i]; var G=pix[i+1]; var B=pix[i+2]; var rgb=R+','+G+','+B; alert(rgb); } } </script>