| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2190 人关注过本帖
标题:【求助】关于VC++ 图像 像素获取的问题
只看楼主 加入收藏
wj871030
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-6-24
收藏
 问题点数:0 回复次数:1 
【求助】关于VC++ 图像 像素获取的问题
(得不到自动扫描的像素,但是可以得到鼠标指定点的像素)
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;
  }

}

}
搜索更多相关主题的帖子: 鼠标 像素 clr 图像 str 
2008-06-24 10:00
qinyuan98
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2008-6-25
收藏
得分:0 
我把你代码直接加到我的程序里 完全没有问题!
而且你的做法比我好用多了
2008-06-25 10:39
快速回复:【求助】关于VC++ 图像 像素获取的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016056 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved