如何通过directX捕获另一个进程窗口 [英] How to capture another process'window by directX

查看:174
本文介绍了如何通过directX捕获另一个进程窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只能通过函数GetFrontBufferData()来捕获桌面。

有没有办法捕获窗口?

I can only capture the desktop by the function GetFrontBufferData()
Is there any way to capture a window?

推荐答案

否,通过DirectX没有通用的解决方案。



原因是你试图捕获的Window可能根本没有存在于DirectX中。如果它属于一个没有使用DirectX的应用程序,那么从DirectX的角度来看,从DirectX的角度来看,你看到的屏幕区域没有什么特别之处只是像素区域中的一些像素没有任何边界或相关对象。



以下是一些潜在的解决方案:



你最好通过操作系统窗口管理器,至少最初计算哪些像素是捕获区域的一部分,哪些不是。不幸的是,这也没有一个简单的通用解决方案。在WinXP上,您可以使用Win32 API,在Vista上它可能已损坏/丢失,但应该可以通过桌面窗口管理器获取,因为它在Windows7上。在Windows 8上,显然DWM已经消失,但我无法确认。



可能使用DirectX或OpenCV的方法是获取屏幕缓冲区域'对图形硬件很感兴趣。但是你仍然需要Win32 API,比如 GetWindowPos 来计算要捕获的内容。



它最终可能更容易捕获整个屏幕,然后只复制你感兴趣的部分并抛弃原始捕获。效率低但可能比试图让系统为您完成更容易。
No, there is no general solution to this via DirectX.

The reason for this is that the Window you''re trying to capture may have no existance in DirectX at all. If it belongs to an application that doesn''t use DirectX then from the DirectX point of view there is nothing special about that area of the screen you see as a window you want to capture, from the point of view of DirectX it''s just some pixels in a larger area of pixels without any boundary or associated object.

Here are some ideas for potential work arounds:

You''re better off going via the OS window manager at least to work out initially which pixels are part of the capture area and which aren''t. Unfortunately there''s no one simple general solution to this either. On WinXP you can use Win32 API, on Vista it''s likely broken/missing but should be avalable through Desktop Window Manager as it is on Windows7. On Windows 8 apparently DWM is gone but I can''t confirm.

An approach that might use DirectX or OpenCV is to get the area of the screen buffer you''re interested in from the Graphics hardware. However you''re still going to need probably Win32 APIs like GetWindowPos to work out what to capture.

It might in the end be easier to capture the whole screen and then duplicate only the part you''re interested in and throw the original capture away. Inefficient but possibly easier than trying to get the system to do it for you.


这篇关于如何通过directX捕获另一个进程窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆