19,469
社区成员
发帖
与我相关
我的任务
分享
int CDesktopGDI::GetDesktopBitmapBuff( void* pBuff )
{
HDC hDeskDc = GetDC(NULL);
BitBlt(m_MemoryDC.m_hDC, 0, 0, m_bmStruct.bmWidth, m_bmStruct.bmHeight, hDeskDc, 0, 0, SRCCOPY);
m_MemoryBitmap.GetBitmapBits(m_iBitNum, pBuff);
ReleaseDC(NULL, hDeskDc);
return m_iBitNum;
}
void CtestDlg::OnBnClickedButton1()
{
BITMAP bm;
GetDesktopWindow()->GetDC()->GetCurrentBitmap()->GetBitmap(&bm);
byte *pBuff = new byte[bm.bmWidthBytes * bm.bmHeight];
CDesktopGDI dg(bm);
clock_t te,ts;
ts=clock();
for(int i = 0; i < 30; i++)
{
dg.GetDesktopBitmapBuff(pBuff);
}
te=clock();
CString str;
str.Format(_T("%d"), te - ts);
MessageBox(str);
delete[]pBuff;
}