Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement