【发布时间】:2018-09-07 07:33:52
【问题描述】:
我有一个用 Java 编写的脚本,它使用 Java Robot 类中的 getPixelColor 方法获取一个像素颜色,并将其与另一种颜色进行比较,看看它们是否相同。它在我的电脑上运行良好,但是当我在安装了 Windows 10 的 Oracle VM VirtualBox 中使用它时,像素总是呈现白色。 (HSB 0,0,1)。 有没有办法从 vm 中获取像素颜色?我错过了一个设置还是应该更改我的代码?
这里是代码和结果的图片:this is the code that checks if the colors match, with a certain tolerance, it returns a booleanThese are the printed results: if all ToCompare values lie between targetplus and targetmin it will return a true
这是我的第一个问题,所以要温柔:)。
【问题讨论】:
-
这可能与虚拟机的渲染有关。
Robot正在“查看”以特殊方式呈现的白色石板。如果存在影响虚拟机硬件图形渲染的设置,请将其关闭并查看行为是否发生变化。 -
Here are pictures of the code- 图片无济于事。发布实际代码。but when i use it in the Oracle VM VirtualBox with a windows 10 installed the pixels always give a white Color. (HSB 0,0,1).- 发布证明这一点的minimal reproducible example。比较逻辑无关紧要。您所需要的只是使用 Robot.getPixelColor() 方法并显示值的简单代码。然后使用不同 JVM 的人可以测试代码以查看他们得到的结果。问题出在您的代码或平台上。
标签: java colors virtual-machine virtualbox pixel