如何以全屏模式快速捕获桌面图像? [英] How to capture desktop image in full-screen mode qucikily?

查看:236
本文介绍了如何以全屏模式快速捕获桌面图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Getfrontbufferdata(DirectX9Ex中的接口函数)在win7中捕获桌面图像。但我遇到了以下两个问题。



1.在窗口模式下,我可以正确捕获桌面图像。然后我想以全屏模式捕捉图像。所以我将Windowed值更改为FALSE,但在CreateDeviceEx中失败。



I want to capture desktop image in win7 using Getfrontbufferdata, a interface function in DirectX9Ex. But I met the below two problems.

1. In Windowed Mode,I can capture desktop image correctly. Then I want to capture image in full-screen mode. So I changed the Windowed value into FALSE,But failed in CreateDeviceEx.

...
 d3dppEx.Windowed = FALSE;//changed this
d3dppEx.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
d3dppEx.BackBufferFormat = ddmEx.Format;
d3dppEx.BackBufferHeight = ddmEx.Height;
d3dppEx.BackBufferWidth = ddmEx.Width;
d3dppEx.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dppEx.SwapEffect = D3DSWAPEFFECT_DISCARD;
//d3dpp.hDeviceWindow = hWnd;
d3dppEx.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
d3dppEx.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;




hr = g_pD3DEx-> CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dppEx, NULL, &g_pd3dDeviceEx);//failed and error code is 0x8876086c 



如何解决问题并以全屏模式获取图像?



2.我发现了一个奇怪的现象在测试我的代码时。当win7的Areo效果打开时,捕获率仅为10~20hz(MSDN表示Getfrontbufferdata设计缓慢)。但是当把主题改成Windows经典时会关闭Areo。捕获率变为约60hz。然后我打开Areo并恢复了原来的主题。捕获率仍然保持在60hz左右,这是一个理想的高频率!

我认为它与rdp有关,这与windows远程桌面有关。但我不知道如何在我的代码中申请。



我尝试了什么:



1.我将Windowed值更改为FALSE但未能创建Device。



2.我试图关闭Areo。但是大约需要1分钟才能获得快速的捕捉频率。此外,我还想在我的项目中保持Areo效果。


How can I solve the problem and get the image in full-screen mode?

2. I found a strange phenomenon When test my code. When win7's Areo effects is turn on, the capture rate just be 10~20hz (MSDN said that Getfrontbufferdata is slow by design ). But when changed theme into Windows classic which will turn off the Areo. The capture rate became about 60hz. Then I turn on the Areo and recovered my original theme. The capture rate still keep about 60hz,an ideal high frequence!
I guss it is related to rdp, which windows uesd in remote desktop. But I don't know how to apply in my code.

What I have tried:

1. I changed Windowed value into FALSE but failed to create Device.

2. I tried to off the Areo. But it took about 1 minute that capture frequence be fast. Besides, I also want to keep Areo effect in my project.

hr = DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);



然后我试图打开rdp会话并在我的代码中添加以下代码项目,但没有改变。


Then I tried to turn on rdp session and added below code in my project, but nothing changed.

HRESULT hr2 = S_OK;
hr2 = CoInitialize(NULL);
IRDPSRAPISharingSession* p_ShareSession;
IRDPSRAPIInvitationManager* p_InvitationManager;
IRDPSRAPIInvitation* p_Invitation;
hr2 = CoCreateInstance(__uuidof(RDPSession), NULL, CLSCTX_ALL, __uuidof(IRDPSRAPISharingSession), reinterpret_cast<void**>(&p_ShareSession));
IConnectionPointContainer* pConnectionPointContainer = NULL;
IConnectionPoint* pConnectionPoint = NULL;
unsigned long cid;
hr2 = p_ShareSession->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<void**>(&pConnectionPointContainer));
hr2 = p_ShareSession->Open();

推荐答案

阅读有关捕获图像。诀窍是使用全屏作为设备上下文。
Read the article and code about Capturing an Image. The trick is to use the full screen as device context.


这篇关于如何以全屏模式快速捕获桌面图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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