Here you can find the source of getHeight(BufferedImage image, int x, int y)
Parameter | Description |
---|---|
image | the height-map texture |
x | pixel's X coordinate |
y | pixel's Y coordinate |
private static int getHeight(BufferedImage image, int x, int y)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; public class Main { /**/*from w w w. ja va2 s . com*/ * This method returns the height represented by the specified pixel in the * given texture. The given texture should be a height-map. * * @param image * the height-map texture * @param x * pixel's X coordinate * @param y * pixel's Y coordinate * @return height reprezented by the given texture in the specified location */ private static int getHeight(BufferedImage image, int x, int y) { if (x < 0) { x = 0; } else if (x >= image.getWidth()) { x = image.getWidth() - 1; } if (y < 0) { y = 0; } else if (y >= image.getHeight()) { y = image.getHeight() - 1; } return image.getRGB(x, y) & 0xff; } }