首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

MFC实现四连通种子填充算法的有关问题

2013-05-02 
MFC实现四连通种子填充算法的问题。程序不知道哪出错了,最后在屏幕上只能打印种子点和其上、下、左、右五个点,

MFC实现四连通种子填充算法的问题。
程序不知道哪出错了,最后在屏幕上只能打印种子点和其上、下、左、右五个点,无法实现填充,希望得到指点,以下是我的代码。
void CFill_fourView::OnLButtonDown(UINT nFlags, CPoint point) 
{
// TODO: Add your message handler code here and/or call default
m_point = point;
//flag = true;
Fill_four(m_point);

CView::OnLButtonDown(nFlags, point);
}

void CFill_fourView::Fill_four(CPoint point)
{
CPoint p;
CPoint rPoint,lPoint,tPoint,bPoint;
CClientDC dc(this);
COLORREF color;
stack.Push(point);
while(stack.Pop(p))
{

dc.SetPixel(p,RGB(0,0,255));

rPoint.x = point.x+1;
rPoint.y = point.y;
lPoint.x = point.x-1;
lPoint.y = point.y;
tPoint.x = point.x;
tPoint.y = point.y-1;
bPoint.x = point.x;
bPoint.y = point.y+1;

color = dc.GetPixel(tPoint);
if(color != RGB(0,0,0) && color != RGB(0,0,255))
stack.Push(tPoint);

color = dc.GetPixel(bPoint);
if(color != RGB(0,0,0) && color != RGB(0,0,255))
stack.Push(bPoint);

color = dc.GetPixel(lPoint);
if(color != RGB(0,0,0) && color != RGB(0,0,255))
stack.Push(lPoint);

color = dc.GetPixel(rPoint);
if(color != RGB(0,0,0) && color != RGB(0,0,255))
stack.Push(rPoint);

}
} MFC 算法 图形学
[解决办法]
我记得XP自带画图用的不是这个算法。是E字打头的那个边界填充

热点排行