关于VC++ 图像 像素获取的问题(得不到自动扫描的像素,但是可以得到鼠标指定点的像素)

一土草三工 2008-06-23 05:48:11
void CMy3View::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str;
HDC hDC=::GetDC(NULL); //获取屏幕DC
CPoint pt;
GetCursorPos(&pt); //得到当前鼠标所在位置
COLORREF clr= ::GetPixel(hDC,pt.x,pt.y); //获取当前鼠标点像素值
str.Format("坐标:(%d , %d),灰度值:(%d,%d,%d)",point.x,point.y,GetRValue(clr),GetGValue(clr),GetBValue(clr));
::ReleaseDC(NULL,hDC); //释放屏幕DC
m_tool.UpdateTipText(str,this);

CView::OnMouseMove(nFlags, point);
}
问题出在这:
HDC hDC=::GetDC(NULL);
// TODO: Add your command handler code here
int itop,ibottom,ileft,iright;//定义坐标X,Y和区域的4个值
int ResultS[50],ResultH[700];
int i,j,n1,n2,n3,n4;
CPoint point;
point.x=800;
point.y=400;
//int xsize=800, ysize=400;
for(i=0;i<point.y;i++) { ResultS[i]=0;}
for(i=(float)(point.y*0.25);i<(float)(point.y*0.5);i+=5)
{

ResultS[i]=0;

for (j=45;j<(float)(point.x*0.25);j++)
{
[color=#FF0000]COLORREF clr= ::GetPixel(hDC,j,i); ///??????????????通过断点检查n1的值都是255 没有任何变化
n1=GetRValue(clr);
if(n1>50 && n1<100)
{

ResultS[i]++;
}
if(ResultS[i]>30)
{

itop=i;
}

}

}

...全文
64 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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