种子填充算法

lmlanren1234 2011-05-23 07:17:20
种子填充算法中取一个像素点时,为什么编译时在return pDC->Getpixel(x,y)这一步出现error C2039: 'Getpixel' : is not a member of 'CDC'
e:\语言\microsoft visual studio\vc98\mfc\include\afxwin.h(636) : see declaration of 'CDC'
Error executing cl.exe.
小妹初学计算机图形学,还请各位高手帮忙解决一下

void CMyDrawView::GetIJ(CDC *pDC, int x, int y)
{
x=x*10;
y=y*10;
x=x+5;
y=y+5;
return pDC->Getpixel(x,y);

}

void CMyDrawView::seed_fill(CDC *pDC, int x, int y, int ecolor, int fcolor)
{
ecolor=RGB(0,0,255);
fcolor=RGB(255,0,0);
if(Getpixel(x,y)!=ecolor&&Getpixel(x,y)!=fcolor)
{

setpixel(pDC,x,y);
seed_fill(pDC,x,y+1,ecolor,fcolor);
seed_fill(pDC,x,y-1,ecolor,fcolor);
seed_fill(pDC,x+1,y,ecolor,fcolor);
seed_fill(pDC,x-1,y,ecolor,fcolor);
}
}


void CMyDrawView::setpixel(CDC *pDC, int i, int j)
{
CBrush br(RGB(255,0,0));
pDC->SelectObject(&br);
pDC->Rectangle(i*10,j*10,i*10+10,j*10+10);
}
...全文
466 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lmlanren1234 2011-06-04
  • 打赏
  • 举报
回复
原先我那填充的像素刚好选在边上了,所以填充不了
lmlanren1234 2011-06-04
  • 打赏
  • 举报
回复
你们的方法都行得通,谢谢你们了!!
xiaohuh421 2011-05-28
  • 打赏
  • 举报
回复
注意大小写,同学
tt2com 2011-05-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lmlanren1234 的回复:]
把 pDC->Getpixel(x,y)
改为
GetPixel(pDC->GetSafeHdc(), x, y)
调试没问题了,可是他还是填充不了,那是怎么一回事啊?
[/Quote]
gdi 我没用过,不是很清楚。我只能说个大概
setpixel();
你用什么来填充的看不到你用dc,如果你做图像处理而不是图形图像建议不要使用gdi。我看过不少帖子直接用gdi说效率不高的
lmlanren1234 2011-05-27
  • 打赏
  • 举报
回复
把 pDC->Getpixel(x,y)
改为
GetPixel(pDC->GetSafeHdc(), x, y)
调试没问题了,可是他还是填充不了,那是怎么一回事啊?
tt2com 2011-05-24
  • 打赏
  • 举报
回复
把 pDC->Getpixel(x,y)
改为
GetPixel(pDC->GetSafeHdc(), x, y)试试看
tt2com 2011-05-24
  • 打赏
  • 举报
回复
Getpixel
不是cdc的成员函数

19,469

社区成员

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

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