How to speed up BitBlt to capture screen with aero?

我是研究僧i 提交于 2019-12-10 13:45:19

问题


I use following code to capture the screen with GDI functions:

// Prologue:

int iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int iScreenHeight = GetSystemMetrics(SM_CYSCREEN);

HDC hScreenDC = GetDC(0);
HDC hCaptureDC = CreateCompatibleDC(hScreenDC);
HBITMAP hCaptureBitmap = CreateCompatibleBitmap(hScreenDC, iScreenWidth, iScreenHeight);
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCaptureDC, hCaptureBitmap);

// Capture:

BitBlt(hCaptureDC, 0, 0, iScreenWidth, iScreenHeight, hScreenDC, 0, 0, SRCCOPY);

// --- ... --- //

// Epilogue:

SelectObject(hCaptureDC, hOldBitmap);
DeleteObject(hCaptureBitmap);
DeleteDC(hCaptureDC);
ReleaseDC(0, hScreenDC);

The problem is: BitBlt function is WAY slow when Aero is turned on - it takes almost 50 milliseconds (which is unacceptable for me because I need to capture multiple times in second).

BitBlt gets the pixel data directly from video hardware. But video cards are pretty good in my test machines (namely Radeon 5470 and Radeon 4850), so I don't understand what's wrong. I know these cards (any modern cards) are not that good in 2D as they are in 3D, but that simple blit operation should not take 50ms anyway I think.

So, could you please advice what to do? Any kind of "hackish" solution (as long as it's stable working) would do in my case.

Target system is Win7 x64, 32-bit code.

Thanks in advance!


回答1:


BitBlt performance with Aero enabled is related. Also there is a windows method to disable aero. I too have been having problems getting more than 15 fps out of aero. Weird.



来源:https://stackoverflow.com/questions/7044154/how-to-speed-up-bitblt-to-capture-screen-with-aero

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!