the method getPixelColor(int x,int y)
from the Robot class到底是怎么回事?工作?我尝试了这个代码片段:
try
{
Robot robos = new Robot();
}
catch (AWTException e)
{
}
for (int i = 0; i < 100; i++)
robos.getPixelColor(0, 0);
System.out.println("fsadf");
在我的 PC(Core 2 Duo)上,执行打印语句只需要一秒或更短的时间。然而,当我在我的笔记本电脑(核心 i3)上运行相同的代码时,花费了更多时间(大约 2-3 秒)。
这背后的原因是什么?与屏幕质量或类似的东西有关系吗?我该如何解决这个问题?
最佳答案
how can i solve this problem?
不要使用机器人逐像素获取颜色。使用机器人创建屏幕的 BufferedImage。然后您可以使用 BufferedImage 的 getRGB() 方法来获取表示像素颜色的 int 值。然后,您可以使用此 int 创建颜色对象或直接解析出红/绿/蓝值。
关于java - Robot 的 getPixelColor(int x, int y) 方法如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60457062/