- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想截取一张屏幕截图,如果像素的 RGB 值正确,则截取另一张屏幕截图并找到下一个像素,否则重复。
这是获取像素的代码,它的作用就像一个魅力!
{
BufferedImage image = robot.createScreenCapture(rectangle);
search: for(int x = 0; x < rectangle.getWidth(); x++)
{
for(int y = 0; y < rectangle.getHeight(); y++)
{
if(image.getRGB(x, y) == color3.getRGB())
{
break search;
}
}
}
}
我想知道的是我想如何要求它重复这段代码直到像素等于真实颜色。我要找的颜色是:
Color color3 = new Color(114, 46, 33);
好的上下文,我正在构建一个程序,该程序会执行以下步骤,一个打开给定的谜题,我将其保留下来,因为我可以使用简单的像素数据,然后需要将鼠标居中于中心像素上。问题是我不能只使用第二个获取像素图像,因为游戏需要一段时间才能打开相关的 jpanel,所以我需要我的程序等待,直到它找到一个指示游戏已打开的像素,然后才开始寻找使鼠标居中的像素。
最佳答案
您可以将屏幕截图代码分离到一个方法中并调用它,直到获得所需的结果:
public boolean checkColor(Color inputColor) {
BufferedImage image = robot.createScreenCapture(rectangle);
for(int x = 0; x < rectangle.getWidth(); x++) {
for (int y = 0; y < rectangle.getHeight(); y++) {
if (image.getRGB(x, y) == inputColor.getRGB()) {
return true;
}
}
}
return false;
}
如果可以在屏幕截图中找到给定的inputColor
,则此方法将返回 true。然后您可以在循环中使用它,如下所示:
Color newColor = ...;
while (!checkColor(newColor)) {
new Color = new Color(114, 46, 33);
// Or change color in here for every iteration
}
如果无法将屏幕截图与 newColor
匹配,此循环将终止。
关于java - if/then 与像素查找和循环,所有这些目前都在我之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9090693/
我希望任何人都可以在这个主题上为我提供帮助,即使这不是特定的编程问题。 我正在写一个单例论文,将MySQL与MongoDB进行比较,并且我想写一些有关Youtube的东西,因为该平台必须处理大量数据负
使用W3C validator验证HTML标记中的音频和视频时出现错误。 Validation Output: 1 Error Error Line 28, Column
我正在使用的功能是 function joinslots(freeTimings){ joined=[]; if(freeTimings.length==1){ joi
我的 Play 商店应用遇到问题。目前,一些日常应用统计数据出现延迟。我们希望尽快解决该问题。 最佳答案 请稍等,几天或更快后即可使用。有时他们的服务器重载,这就是原因。 关于google-play
使用外连接合并两个表。让我们说 df1 = ['产品ID', '名称'] df2 = ['用户ID', '产品ID', '使用情况'] 我尝试在 pandas 中使用带有合并功能的外连接。 pd.me
我正在做我的第一个表格计算,这是我在过去一天研究并想出的 jQuery。 顺便说一下,这只是我发现的让一切正常运行的方法,不一定是最好的方法。我的老板希望我使用 .blur() 而不是 .on(),但
Scalamock 拒绝了我的 mock 尝试,说它不支持超过 22 种方法。 原因是因为在我试图模拟的类中总共有超过 22 个方法(2 个是我的,20 多个是混合的(来自 Akka Json 支持)
应用商店里有一个叫 Touchpad 的应用,最后一次更新是在 11 月 29 日,其中包含一个新功能,支持“使用设备键盘上的 Siri 键向电脑发送文本”,我想知道是否有开放的 API Siri现在
目前(2009 年年中)GCJ 的现状如何? 最新消息是2007年的,所以我想知道是否有任何形式的进展?我记得不久前有一个可用的 lucene 编译版本,它使用 gcj 从 java 源代码编译它。目
我是第一次开始使用 OpenCL,我正在尝试优化缩减内核。内核采用大小为宽度像素的 float 正方形网格(数据表示灰度图像的亮度值)。内核对每一列求和并将每一列的总和返回到输出数组。 /* inpu
有一个正在运行的 github 线程(似乎已关闭并且已经完成了一堆提交/合并)。 尽管 VirtualBox 和 Vagrant 还不到 2 周大:*编辑:我仍然看到与/root/.my.cnf 相关
在 Android Studio 的 androidTest 文件夹中,我有几个测试用例,如下所示: Screenshot : Android Studio每个测试类执行后,应用程序退出并重新启动以进
目前正在开发一个包含 google maps 的应用程序,我愿意让它也适用于中国。 我知道中国的情况在过去几年发生了一些变化。所以我想知道:是否可以在中国的 Android 应用程序中使用谷歌地图?
我正在尝试使用 Cosmos DB RestAPI 列出本地(模拟器)实例上的数据库,但进展不够。有谁知道我在这里做错了什么...... var crypto = require("crypto");
有没有办法自定义 HTML 并以 html 格式发送通知电子邮件? 最佳答案 只需调整您的模板,例如 > https://github.com/pinax/django-notification/bl
我正在寻找一种方法来在类似于 Youtube 视频显示的 html5 视频上创建加载动画(引用: https://www.youtube.com/watch?v=5vcCBHVyG50 ) 我用 ca
我正在关注 Google Codelabs for instant app ,我正在尝试创建 topeka-ui(即时应用程序的 UI 功能模块)。 它告诉我为该 UI 模块启用这样的数据绑定(bin
我在 iPad 上使用 APSplitViewController 来获得两侧。在右侧工作时,我有一个位于 UINavigationController 内的 viewController。 当我以模
当前(但不常见),如果您调用以下 url,您会收到内部服务器错误: https://api.linkedin.com/v1/people/~/connections:(id,headline,pict
def cat_latin_word(text): """ convert the string in another form """ constant = "bcdfghj
我是一名优秀的程序员,十分优秀!