public class ImageHandler {
public static int[][] loadImage(String imagePath) throws IOException{
BufferedImage img = ImageIO.read(new File(imagePath));
int[][] grid = new int[img.getWidth()][img.getHeight()];
for(int x = 0; x < img.getWidth(); ++x){
for(int y = 0; y < img.getHeight(); ++y){
int rgb = img.getRGB(x, y);
grid[x][y] = (rgb) & 0x000000FF; //the height map is greyscale so
//it doesn\'t matter which RGB component
//is used
}
}
return grid;
}
}