LinHanLao 2009年05月14日
显示图片居然花了700ms时间,请帮我看看是怎么回事?
用如下的代码显示一个800 x 454 24bit的图片时,居然花了700ms时间(CPU主频600M)?请帮忙看看问题在哪里?

case WM_PAINT:
{
HDC hdcmem;
HBITMAP hBitmap, hOldBmp1, hOldBmp2;
BITMAP bmp;
HDC hdcBuf;
HDC hdcBmp;
RECT rc;
TCHAR msg[MAX_PATH] = {0};
DWORD RefTime = 0;


RefTime = GetTickCount();

swprintf(msg, TEXT("Paint Begin = %d\n"), RefTime);
OutputDebugString(msg);

hdc = BeginPaint(hWnd, &ps);

GetClientRect(hWnd, &rc);

if (g_bmBuffer == NULL)
g_bmBuffer = CreateCompatibleBitmap(hdc, rc.right - rc.left, rc.bottom - rc.top);

hdcBuf = CreateCompatibleDC(hdc);
hOldBmp1 = (HBITMAP)SelectObject(hdcBuf, g_bmBuffer);

//显示背景图
hdcBmp = CreateCompatibleDC(hdc);
hOldBmp2 = (HBITMAP)SelectObject(hdcBmp, g_hBitmap[BmpIndex]);


RefTime = GetTickCount();
swprintf(msg, TEXT("BitBlt Begin = %d\n"), RefTime);
OutputDebugString(msg);
BitBlt(hdcBuf, 0, 0, 800, 454, hdcBmp, 0, 0, SRCCOPY); //这里居然用了600ms,为什么会出现这种情况?
RefTime = GetTickCount();
swprintf(msg, TEXT("BitBlt End = %d\n"), RefTime);
OutputDebugString(msg);


SelectObject(hdcBmp, hOldBmp2);
DeleteDC(hdcBmp);

RefTime = GetTickCount();
swprintf(msg, TEXT("BitBlt Begin = %d\n"), RefTime);
OutputDebugString(msg);
BitBlt(hdc, 0, 0, 800, 454, hdcBuf, 0, 0, SRCCOPY);
RefTime = GetTickCount();
swprintf(msg, TEXT("BitBlt End = %d\n"), RefTime);
OutputDebugString(msg);


SelectObject(hdcBuf, hOldBmp1);
DeleteDC(hdcBuf);


EndPaint(hWnd, &ps);

RefTime = GetTickCount();
swprintf(msg, TEXT("Paint End = %d\n"), RefTime);
OutputDebugString(msg);

break;
}
...全文
218 点赞 收藏 18
写回复
18 条回复

还没有回复,快来抢沙发~

发动态
发帖子
嵌入开发(WinCE)
创建于2007-09-28

8163

社区成员

4.1w+

社区内容

硬件/嵌入开发 嵌入开发(WinCE)
社区公告
暂无公告