将窗口内容捕获到纹理
首先让我明确一下我的开发要点。我正在编写一个 Windows DLL。我关注的编程语言是 C/C++。当我的任务需要时,汇编块也是可能的。也许甚至是司机,但我根本没有任何与他们打交道的经验。 DLL 被注入到主机进程中。这始终是 Directx 环境。 Dx9、Dx10 或 Dx11,可以在全屏或窗口模式下运行。 该方法应支持 Windows XP 到 Windows 7,并且仅在 x86 中编译。
目标是提出一个对给定进程窗口进行屏幕截图的函数。屏幕截图永远不会从主机进程本身获取。它总是另一个过程!该窗口可能包含 directx 或 gdi32 内容。也许其他内容是可能的,我目前没有想到(我想到了 Windows 表单。我不确定它是如何在内部呈现的)。窗口可以最小化。
该屏幕截图需要可访问/可转换为 Directx 纹理,例如 Texture2D,具体取决于我正在使用的 Directx 环境。将屏幕截图保存为 png/bmp 就足够了,因为我确实知道如何从内存创建这样的纹理。
我已经尝试过旧式的 BitBlt 方式,但它不适用于最小化的应用程序。当我向目标窗口发送 WM_PAINT 消息时,正在绘制最小化的应用程序。这对我来说不是一个解决方案,因为我还需要跟上不对此类消息做出反应的 directx 应用程序。
也许我需要挂钩每个 DirectX 窗口来完成我的任务,直接访问后备缓冲区,无论如何我确实希望有一些更好的方法。
由于我确实从多个窗口中获取了大量屏幕截图,因此我想实现一种快速方法,这不是 CPU 伪造的。当有这样的性能需求时,从 VideoRAM 复制可能不是一个好方法。
我确实希望得到一些想法,也许是代码示例,因为我不熟悉我可以寻求的所有可能性。我查看了一些 Windows 缩略图 api,但据我所知,它不支持 xp。
提前致谢, 坦率
let me first specify my development essentials. I am writing an Windows DLL. The programming language i do focus on is C/C++. Asm blocks are possible aswell when required for my task. Maybe even a driver, but i do not have any experience with them at all.
The DLL is being injected into a host process. That's always a Directx environment. Either Dx9, Dx10 or Dx11 and may run in fullscreen or windowed mode.
The method should support windows xp up to windows 7 and is being compiled in x86 only.
The goal is to come up with a function taking a screenshot of a given process-window. The screenshot is never being taken from the host process itself. Its always another process! The window may contain directx or gdi32 content. Maybe other contents are possible i do not think of at the moment (windows forms comes to my mind. i am not sure how that is being rendered internally). The windows may be minimized.
That screenshot needs to be accessable/convertable to an directx texture such as Texture2D, depending on the Directx environment i am working in. Saving the screenshot as an png/bmp is enough thoe, as i do know how to create such a texture from memory.
I've already tried the oldstyle BitBlt way, that didnt work on minimized applications thoe. The minimized applications are being drawn, when i send WM_PAINT messages to the targeting window. That aint a solution for me, as i also need to keep up with directx applications which doesnt react to such messages.
Maybe i need to hook each single DirectX window to accomblish my task, to access the backbuffer directly, i do hope for some better methods anyways.
For the reason that i do take a lot of screenshots from multiple windows, i would like to implement a fast method, which isnt such a cpu bogus. Copying from VideoRAM may be a bad way to go when having such performance needs.
I do hope for some ideas, maybe code samples as i am not familar with all the possibilities i could go for. I've looked at some windows thumbnail api, but that didnt support xp from what i could read.
Thanks in advance,
Frank
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论