如何加快BitBlt捕获与Aero的屏幕? [英] How to speed up BitBlt to capture screen with aero?

查看:74
本文介绍了如何加快BitBlt捕获与Aero的屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码通过GDI功能捕获屏幕:

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);

问题是:打开Aero时,BitBlt函数的运行速度很慢–大约需要50毫秒(这对我来说是不可接受的,因为我需要每秒捕获多次).

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直接从视频硬件获取像素数据.但是视频卡在我的测试机器(即Radeon 5470和Radeon 4850)中相当不错,所以我不明白这是怎么回事.我知道这些卡(任何现代卡)在2D中都不如在3D中那样好,但是我认为简单的blit操作无论如何都不会花费50ms.

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.

目标系统是Win7 x64 32位代码.

Target system is Win7 x64, 32-bit code.

提前谢谢!

推荐答案

启用了Aero的BitBlt性能是相关的.另外,还有一种禁用Aero的Windows方法.我也一直无法从航空中获得超过15 fps的速度.很奇怪.

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.

这篇关于如何加快BitBlt捕获与Aero的屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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