Screen Capture of DirectX programs with Java

时间秒杀一切 提交于 2019-12-13 05:24:33

问题


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


回答1:


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:

  • The call to createScreenCapture was done from within the OpenGL application.
  • The application used heavyweight GLCanvas
  • It used Java 6

Make sure you pass it the correct coordinates. You can get the screen coordinates to use from the GraphicsEnvironment




回答2:


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?




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/6675693/screen-capture-of-directx-programs-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!