使用DirectX从游戏环境中截取屏幕截图 [英] taking screenshots from game environment using DirectX

查看:513
本文介绍了使用DirectX从游戏环境中截取屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试编写一个简单的应用程序,该应用程序从游戏环境中截取屏幕截图.我已经搜索了,根据我的搜索,我需要使用DirecX backbuffer.我试图编写一些代码,使用带桌面缓冲的桌面缓冲区的前缓冲区可以正常工作,但是当我使用后缓冲区并启动游戏拍照时,它会从Device()函数中显示错误:应用程序中存在错误".如何从游戏中截取屏幕截图?此代码有什么问题?
谢谢.

代码:

Hi,
I am trying to write a simple application that takes screenshots from games environment. I''ve search and based on my searches I need to use DirecX backbuffer. I tried to write some code, it works fine using frontbuffer that takes desktop screenshots, but when I use backbuffer and start a game to take pictures, it gives an error from Device() function saying : "Error in the application". How can I take screenshots from a game? what is wrong with this code?
Thanks.

Code:

PresentParameters pp = new PresentParameters();
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
Device device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, pp);
Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
SurfaceLoader.Save("1.bmp", ImageFileFormat.Bmp, backbuffer);

推荐答案

关注:
在C#中使用DirectX进行非常快速的屏幕捕获 [ ^ ]
Follow:
Very fast screen capture using DirectX in C#[^]


这篇关于使用DirectX从游戏环境中截取屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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