I’ve got a BufferedImage i and I’d like to get the Color from a certain pixel of that image including the alpha value. The pixel is identified using x and y coordinates.
Here’s what I tried:
Color c = new Color(i.getRGB(x, y));
For some reason, the new color object contains the correct RGB but the alpha gets lost.
What am I doing wrong?
Thanks in advance
The single-parameter
Colorconstructor you’re using discards alpha information. Use the two-parameter version instead and pass intrueforhasalpha:The relevant Javadoc: