document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public class ImageHandler {
  2.     public static int[][] loadImage(String imagePath) throws IOException{
  3.         BufferedImage img = ImageIO.read(new File(imagePath));
  4.         int[][] grid = new int[img.getWidth()][img.getHeight()];
  5.        
  6.         for(int x = 0; x < img.getWidth(); ++x){
  7.             for(int y = 0; y < img.getHeight(); ++y){
  8.                 int rgb = img.getRGB(x, y);
  9.                 grid[x][y] = (rgb) & 0x000000FF; //the height map is greyscale so
  10.                                                  //it doesn\'t matter which RGB component
  11.                                                  //is used
  12.             }
  13.         }
  14.        
  15.         return grid;
  16.     }
  17. }
');