【问题标题】:How to get pixel color from oracle VM如何从 oracle VM 获取像素颜色
【发布时间】: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


【解决方案1】:

经过更多搜索后,我发现 Robot 类能够从 vm 内部获取颜色,但我在代码的其他部分中犯了一个错误,并且由于多线程(当 vm 运行时),我的一些功能被破坏了在 1 个线程上)已通过更改 vm 设置解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-05
    • 1970-01-01
    • 2013-07-11
    • 1970-01-01
    • 1970-01-01
    • 2013-07-21
    • 1970-01-01
    相关资源
    最近更新 更多