如何用VC抓取屏幕图象并压缩
2008-11-13 19:33:10 来源:WEB开发网核心提示:用下面函数可发实现。HBITMAPGetScreenBmp()HWNDhwnd=::GetDesktopWindow();HDChsrc=::GetDC(hwnd);HDChmemdc=::CreateCompatibleDC(hsrc);RECTrc;::GetWindowRect(hwnd,&rc);SIZEsz;
用下面函数可发实现。
HBITMAPGetScreenBmp()
HWNDhwnd=::GetDesktopWindow();
HDChsrc=::GetDC(hwnd);
HDChmemdc=::CreateCompatibleDC(hsrc);
RECTrc;::GetWindowRect(hwnd,&rc);
SIZEsz;sz.cx=rc.right-rc.left;sz.cy=rc.bottom-rc.top;
HBITMAPhbmp=::CreateCompatibleBitmap(hsrc,sz.cx,sz.cy);
HGDIOBJholdbmp=::SelectObject(hmemdc,hbmp);
::BitBlt(hmemdc,0,0,sz.cx,sz.cy,hsrc,rc.left,rc.top,SRCCOPY);
::SelectObject(hmemdc,holdbmp);
::DeleteObject(hmemdc);
::ReleaseDC(hwnd,hsrc);
returnhbmp;
更多精彩
赞助商链接