putImageData方法写在window.onload里面没有效果?
window.onload = function () { image.src = 'imgDemo.jpeg'; image.onload = function () { contexta.drawImage(image, 0, 0, canvasa.width, canvasa.height); } var imgData = contexta.getImageData(0, 0, canvasa.width, canvasa.height); console.log(imgData); contextb.putImageData(imgData, 0, 0, 0, 0, canvasb.width, canvasb.height); }
console.log(imgData);是有数据的,但是运行后,contextb.putImageData
并没有效果,把这段代码挪到外面的方法里就有效了,请问这是为什么呢?