我试图制作一个程序,我需要基本上拍摄屏幕并检查是否某个像素,如同坐标(100,100)中的某个颜色代码。
答案 0 :(得分:0)
也许这会有帮助吗? (来自重复)
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();
}