[stackoverflow] [progress Openedge Abl] Incorrect Grayscale Values From Java Bufferedimage...

Status
Not open for further replies.
M

Massimo Saliba

Guest
I have a grayscale height map, which I created in Photoshop, and I need to pass it to a Java program for processing. I am loading it by using the ImageIO.read(...) method and then converting it to grayscale with this code:

BufferedImage map = ImageIO.read(new File(...));
BufferedImage heightMap = new BufferedImage(map.getWidth(), map.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
heightMap.getGraphics().drawImage(map, 0, 0, null);
heightMap.getGraphics().dispose();


In Photoshop, pixel (0,0) has a value of 17. When I use heightMap.getData().getSample(0, 0, 0) or ((byte[])(heightMap.getRaster().getDataElements(0, 0, null)))[0] & 0xff, I get a value of 64.

Interestingly, when I run map.getRGB(0, 0)>>16&0xFF, I also get the value of 64.

How do I fix this and get a value of 17?

Thanks.

Continue reading...
 
Status
Not open for further replies.
Top