BufferedImage image = ...
int[][] array = new int[image.getWidth()][image.getHeight()];
for(int i = 0 ; i < image.getWidth(); i ++)
for(int j = 0 ; j < image.getHeight(); j++)
array[i][j]=image.getRGB(i,j);
myBufferedImage.getRaster().getPixel(int x, int y, int w, int h, int[] iArray);
/**
* Returns the data of the given image as an int[] array.
* The image must have the type BufferedImage.TYPE_INT_ARGB,
* BufferedImage.TYPE_INT_BGR or BufferedImage.TYPE_INT_RGB.
* For other types, an IllegalArgumentException will be thrown.
*
* @param image The image
* @return The data of the image.
* @throws IllegalArgumentException If the image does not have
* a DataBufferInt.
*/
private static int[] getDataArray(BufferedImage image)
{
Raster raster = image.getRaster();
DataBuffer dataBuffer = raster.getDataBuffer();
if (!(dataBuffer instanceof DataBufferInt))
{
throw new IllegalArgumentException(
"Image does not have a DataBufferInt");
}
DataBufferInt dataBufferInt = (DataBufferInt)dataBuffer;
int data[] = dataBufferInt.getData();
return data;
}