Can anybody explain how to get an array of rgb value from a BufferedImage?
I have a grey scale image in a BufferedImage and need to extract an array of 0 to 255 values that describe the image.
I know the BufferedImage is correct because I can save it to PNG. However, if I use int[] dataBuffInt = ((DataBufferInt) heightMap.getDataBuffer()).getData();
I get a bunch of huge negative numbers.
I have searched for a while and seen some references to shifting some values (post) but don't really understand what they are saying.
Basically I want to go from a BufferedImage to an array of 0 to 255 RBG values.
I'm not sure I explained myself properly, plaese ask for more details is needed.
Edit:
@Garbage Thanks for the tip. I tried int[] dataBuffInt = heightMap.getRGB(0, 0, heightMap.getWidth(), heightMap.getHeight(), null, 0, heightMap.getWidth()); But get the same result.
@Greg Kopff The result is 2 and it was set to TYPE_INT_ARGB