I'm trying to make a program and I need to basically take the screen and check if a certain pixel, as in like coordinate (100,100) is a certain color code.
Asked
Active
Viewed 1,218 times
0
-
Possible duplicate: http://stackoverflow.com/questions/1599963/how-to-read-pixel-color-in-a-java-bufferedimage-with-transparency – Mapsy Jul 23 '15 at 05:48
-
This question is [too broad](http://stackoverflow.com/help/on-topic). There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. – Jørgen R Aug 05 '15 at 16:08
1 Answers
0
Maybe this helps? (from duplicate)
BufferedImage image;
int x = 100;
int y = 100;
try {
image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
int color = image.getRGB(x, y);
int red = (color & 0x00ff0000) >> 16;
int green = (color & 0x0000ff00) >> 8;
int blue = color & 0x000000ff;
System.out.println(red + " " + green + " " + blue);
} catch (HeadlessException | AWTException e) {
e.printStackTrace();
}

MrT
- 16
- 2