捕捉屏幕,处理DDB数据,如何获取像素数据

WanGong 2012-06-02 11:17:11
使用一下代码获取了当前的屏幕图像,想要直接对其像素数据进行处理,
CRect rect(0, 0, ::GetSystemMetrics(SM_CXSCREEN), ::GetSystemMetrics(SM_CYSCREEN));
// create a screen and a memory device context
HDC hDCScreen = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
HDC hDCMem = ::CreateCompatibleDC(hDCScreen);
// create a compatible bitmap and select it in the memory DC
HBITMAP hBitmap =
::CreateCompatibleBitmap(hDCScreen, rect.Width(), rect.Height());
HBITMAP hBmpOld = (HBITMAP)::SelectObject(hDCMem, hBitmap);

// bit-blit from screen to memory device context
// note: CAPTUREBLT flag is required to capture layered windows
DWORD dwRop = SRCCOPY | CAPTUREBLT;
BOOL bRet = ::BitBlt(hDCMem, 0, 0, rect.Width(), rect.Height(),
hDCScreen,
rect.left, rect.top, dwRop);
CImage m_image。Attach(hBitmap);
但是调用m_image.getBits失败,后查明原因,因为m_image当前是DDB图像,请问各位大侠如何对DBB图像的像素值进行直接处理呢?谢谢!
...全文
99 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Lactoferrin 2012-06-06
  • 打赏
  • 举报
回复
CreateDIBSection
e3internet 2012-06-02
  • 打赏
  • 举报
回复
想要怎么的处理?

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧