且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用C#拍摄任何外部应用程序的屏幕截图

更新时间:2023-09-10 11:44:22

答案1:在OpenGL中,您可以调用glReadBuffer和glReadPixels获取屏幕位图。但是,这很慢(因此您不会在每一帧重复调用它),并且当GL窗口与另一个应用程序/窗口重叠时,您也可能会遇到问题。正确的方法是使用 pbuffer

Answer to 1: In OpenGL, you can call glReadBuffer and glReadPixels to get the screen bitmap. However, this is slow (so you don't call it repeatedly every frame) and you might also have problems when th GL window is overlapped by another application / window. The correct way to do this is to "render to texture" (google it) by using a pbuffer.

第2点的想法:如果您有窗口句柄,则可以获取 pixelformatdescriptor 结构并进行检查。从来没有尝试过。

Idea for 2: If you have the handle to window, you might be able to get the pixelformatdescriptor structure it has and check it. Never tried it though.

对于3:顺便说一句,我认为没有任何通用的方法可以做到这一点。

For 3: By the way, I don't think there is a single universal way of doing this without any problems..