Java BufferedImage getting red, green and blue individually

前端 未结 4 1286
时光取名叫无心
时光取名叫无心 2020-11-27 02:23

The getRGB() method returns a single int. How can I get individually the red, green and blue colors all as the values between 0 and 255?

4条回答
  •  醉酒成梦
    2020-11-27 03:06

    Java's Color class can do the conversion:

    Color c = new Color(image.getRGB());
    int red = c.getRed();
    int green = c.getGreen();
    int blue = c.getBlue();
    

提交回复
热议问题