当前位置:编程学习 > VC++ >>

如何用VC抓取屏幕图象并压缩?

 

 

用下面函数可发实现。

HBITMAP GetScreenBmp()

{

HWND hwnd = ::GetDesktopWindow();

HDC hsrc = ::GetDC(hwnd);

HDC hmemdc = ::CreateCompatibleDC(hsrc);

RECT rc; ::GetWindowRect(hwnd,&rc);

SIZE sz;sz.cx=rc.right-rc.left;sz.cy=rc.bottom-rc.top;

HBITMAP hbmp = ::CreateCompatibleBitmap(hsrc,sz.cx,sz.cy);

HGDIOBJ holdbmp = ::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);

return hbmp;

}

 

 

 

 

补充:软件开发 , Vc ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,