使用 Java 进行 DirectX 程序的屏幕截图
我编写了一个 Java 应用程序,它使用 java.awt.Robot 来捕获屏幕,并且想知道是否可以使用 DirectX/OpenGL 捕获程序?
每次我尝试执行此操作时,都会出现黑屏
I wrote a Java application that uses the java.awt.Robot to take screen captures of the screen and was wondering if capturing a program using DirectX/OpenGL would be possible?
Each time I try to do this, I get a black screen
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不知道这是否真的是一个解决方案,但似乎有更多可能的方法使用“FrameGrabber”或 JavaCV 中的一些相关类来获取屏幕截图信息:http://code.google.com/p/javacv/
屏幕上显示的一些最终输出可以在显卡上计算,该显卡已将着色器设置为在将图像数据放入显示缓冲区之前对图像数据进行操作,因此如果没有模拟,某些效果可能无法捕获环回(从采集卡上的视频输出到视频输入)。
相关文章如何在Java中快速截取屏幕截图?
Don't know if this is really a solution but seems there's more possible ways to get the screenshot information using a "FrameGrabber" or some related class from JavaCV possibly: http://code.google.com/p/javacv/
Some of the final output shown on the screen could be calculated on a graphics card that has shaders set to act on the image data before it gets put into a display buffer for what's shown so it's possible some effects would be impossible to capture without an analog loopback (go from video out to video in on a capture card).
Related post How to take screenshots fast in Java?
OpenGL 是一个绘图 API,而不是图形系统的通用接口。有时候,通过一些肮脏的黑客手段确实可以使用 OpenGL 截取屏幕截图。然而最近我尝试在现代操作系统上重新实现它,看看它是否仍然有效,不,它不再有效了。
OpenGL is a drawing API, not an all purpose interface to the graphics system. There were times, when taking screenshots with OpenGL was indeed possible through some dirty hacks. However recently I tried to re-implement this on modern OS to see if it still works, and no, it doesn't anymore.
是的,这是可能的。但也许仅限于有限的情况。
我已经使用 Robot createScreenCapture。
有关实现的一些具体信息可能与您不同:
应用。
确保您向其传递了正确的坐标。您可以从 GraphicsEnvironment
Yes it is possible. But maybe only in limited circiumstances.
I've successfully captured the contents on OpenGL (jogl) windows on linux and windows using the Robot createScreenCapture.
Some specific information about the implementation that may be different for you:
application.
Make sure you pass it the correct coordinates. You can get the screen coordinates to use from the GraphicsEnvironment
呃...很难;o)
我尝试了其他一些屏幕截图实用程序,也得到了黑屏。看起来 DirectX 将图形直接传递到显示器输出。我想知道是否可以在 java 应用程序中访问它。
Uhh... a hard one ;o)
I had a try with some other screenshot utils and got a black screen, too. Looks like DirectX is passing the graphics directly to the monitor output. I am wondering if that could be accessed within a java application.