Search code examples
javacolorsawtawtrobot

RGB integer to Color object


I am drawing an integer from a Color using this code:

robot.getPixelColor(x, y).getRGB()

Now how do I go from an integer back to an RGB color? I've looked about and I havn't seen anything that does this...

Thanks!


Solution

  • Actually getPixelColor(x,y) returns a java.awt.Color.

    Color color = robot.getPixelColor(x,y);
    int rgb = color.getRGB();
    Color color2 = new Color(rgb);