You can get the
Raster
out of an image and then get the pixels out of that.
Here's an (unoptimized) example:
package sandbox;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Main {
public static void main(String[] args) {
try {
BufferedImage image = ImageIO.read(new File("c:\\alien.jpg"));
Raster raster = image.getRaster();
int[][] imagePixels = new int[image.getWidth()][image.getHeight()];
for(int x = 0; x < image.getWidth(); ++x) {
for(int y = 0; y < image.getHeight(); ++y) {
int pixel = 0;
int[] pixelData = raster.getPixel(x, y, new int[4]);
for(int i = 0; i < pixelData.length; ++i) {
pixel |= pixelData[i] << (i * 8);
}
}
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
Hope this helps,
Fredrik