开发者

How to speed up BitBlt to capture screen with aero?

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 dir开发者_运维百科ectly 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜