是的,有可能。使用以下内容-
image-rendering: -webkit-optimize-contrast; /* webkit */ image-rendering: -moz-crisp-edges /* Firefox */
您需要创建屏幕外的画布,然后绘制图像。之后,只需获取像素即可。
var a = document.createElement('canvas').getContext('2d'); a.drawImage(myImg,0,0); var image = a.getImageData(0,0,img1.width,myImg.height).data; for (var x=0;x<img1.width;++x){ for (var y = 0; y < img1.height; ++y){ var i = (y*myImg.width + x)*4; var r = imageimageimageimage[i ]; var g = imageimageimage[i+1]; var b = imageimage[i+2]; var a = image[i+3]; ctx2.fillStyle = "rgba("+r+","+g+","+b+","+(a/255)+")"; ctx2.fillRect(x*zoom,y*zoom,zoom,zoom); } }