由于某种原因,下面的代码将不起作用。它停在与getImageData
。IE9 抛出此错误:SCRIPT5022: DOM Exception: INDEX_SIZE_ERR (1)
. 有没有办法解决这个问题?但是,它适用于 Chrome 和 FF。
//Select our canvas and context
var canvas = document.getElementById("imageCanvas");
var context = canvas.getContext('2d');
//Select the image from the DOM
var selectedImage = document.getElementById("image");
//Draw the image to the canvas then read in the data
context.drawImage(selectedImage, 0, 0);
var originalLakeImageData = context.getImageData(0,0, width, height);
//Image data is now stored in an array in the form
//originalLakeImageData.data = [r1, g1, b1, a1, r2, g2, b2, a2....]