C#使用SlimDX捕获全屏游戏 [英] C# Capturing A Fullscreen Game With SlimDX

查看:465
本文介绍了C#使用SlimDX捕获全屏游戏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近制作了一个应用,该应用可以拍摄游戏的屏幕截图.

I have recently made an application that takes screenshots of games.

首先,我使用GDI来捕获游戏,但是为此我不得不在win7/vis上禁用了Aero,并且在Windows XP上出现了一些问题.

First I used GDI to capture the game but for that I had to disable aero at win7/vis and I had some issues on windows XP.

在我决定使用DirectX并意识到微软的DX对我不起作用之后,我发现了SlimDX屏幕捕获的一个很好的例子(http://spazzarama.wordpress.com/2009/02/07/screencapture-with-direct3d/)

Than I decided going with DirectX and after realizing that microsoft's DX isn't going to work for me, I found this great example of a SlimDX screen capture (http://spazzarama.wordpress.com/2009/02/07/screencapture-with-direct3d/)

SlimDX很棒!它甚至使我无需在win7/vis上禁用Aero即可捕获游戏.

SlimDX worked GREAT! and it even allowed me to capture a game without having to disable aero on win7/vis.

唯一的问题是-当我将游戏切换到全屏模式时,显示"D3DERR_DEVICELOST:设备丢失(-2005530520)".

Only problem is - when I switch the game to fullscreen I get "D3DERR_DEVICELOST: Device lost (-2005530520)".

有人可以建议一种自定义代码的方式,以便捕获全屏应用程序吗?

Can anyone suggest a way to customize the code so it'll capture fullscreen application?

注意:我已经有了一种可以确定游戏是全屏还是全屏游戏的方法.

NOTE : I already have a method that can determine if the game is fullscreen or windowed.

然后我更改此行:

bitmap = new Bitmap(SlimDX.Direct3D9.Surface.ToStream(surface, SlimDX.Direct3D9.ImageFileFormat.Bmp, new Rectangle(region.Left, region.Top, region.Width, region.Height)));

对此:

bitmap = new Bitmap(SlimDX.Direct3D9.Surface.ToStream(surface, SlimDX.Direct3D9.ImageFileFormat.Bmp));

推荐答案

Direct3D设备进入全屏模式时,将被授予对视频卡的独占访问权限.从 MSDN文档:

When a Direct3D device enters fullscreen mode, it's granted exclusive access to the video card. From the MSDN documentation:

当Direct3D对象采用独占模式时,除全屏显示设备以外的所有设备都将处于丢失状态.

when a Direct3D object assumes exclusive mode, all devices other than the one that went full-screen are placed in lost state.

我认为没有任何方法可以使您的技术在进入全屏独占模式后为另一个应用程序截屏.我的理解是,其他检索全屏表面状态的应用程序(即视频记录程序等)通过将自己的代码注入Direct3D库本身来进行此操作.这是不平凡的努力.您可以尝试搜索"directx代码注入",或者如果您对此感兴趣的话,可以尝试类似的搜索.

I don't think there's any way to make your technique work for taking screenshots of another application after it goes into fullscreen exclusive mode. My understanding is that other applications which retrieve the state of fullscreen surfaces (i.e. video recording programs and the like) do so by injecting their own code into the Direct3D libraries themselves. This is a non-trivial endeavor; you can try searching for "directx code injection" or something similar if you're interested in going down that road.

这篇关于C#使用SlimDX捕获全屏游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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