
vc++图像处理如何提取像素值
2个回答
展开全部
要想捕获当前线程内(也就是当前CxxxApp)所有窗口上光标所在的像素颜色,需要重载CxxxApp的PreTranslateMessage函数,加:
if ( pMSG->message == WM_MOUSEMOVE)
{
CPoint ptScreen;
GetCursorPos(&ptScreen);
CWnd*DeskWnd = GetDesktopWindow();
CDC*DeskDC = DeskWnd->GetDC();
COLORREF clr = DeskDC->GetPixel(ptScreen);
DeskWnd->ReleaseDC(DeskDC);
CString strShow;
strShow.Format("%d", clr);
...
}
要想捕获当前屏幕任何地方的像素值,要先SetCapute,然后在使用上面的代码。
if ( pMSG->message == WM_MOUSEMOVE)
{
CPoint ptScreen;
GetCursorPos(&ptScreen);
CWnd*DeskWnd = GetDesktopWindow();
CDC*DeskDC = DeskWnd->GetDC();
COLORREF clr = DeskDC->GetPixel(ptScreen);
DeskWnd->ReleaseDC(DeskDC);
CString strShow;
strShow.Format("%d", clr);
...
}
要想捕获当前屏幕任何地方的像素值,要先SetCapute,然后在使用上面的代码。

2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景。ai生...
点击进入详情页
本回答由博思aippt提供
展开全部
CPoint point;
GetCursorPos(&point);//get cursor pos
HDC hDC = ::GetDC(NULL);//lock paint DC
COLORREF colorref = ::GetPixel(hDC, point.x, point.y); //get the cursor color
GetRValue(colorref);//store red color
GetGValue(colorref);//store green color
GetBValue(colorref);//store blue color
::ReleaseDC(NULL, hDC);//unlock DC
GetPixel是CDC类里的函数
GetCursorPos(&point);//get cursor pos
HDC hDC = ::GetDC(NULL);//lock paint DC
COLORREF colorref = ::GetPixel(hDC, point.x, point.y); //get the cursor color
GetRValue(colorref);//store red color
GetGValue(colorref);//store green color
GetBValue(colorref);//store blue color
::ReleaseDC(NULL, hDC);//unlock DC
GetPixel是CDC类里的函数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询