Click here to Skip to main content
15,892,575 members
Articles / Desktop Programming / MFC

QuickFill: An Efficient Flood Fill Algorithm

Rate me:
Please Sign up or sign in to vote.
4.84/5 (71 votes)
12 Mar 200413 min read 528.3K   12K   103  
Design and implementation of efficient flood fill algorithms.
// QuickFillDemoView.h : interface of the CQuickFillDemoView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_QUICKFILLDEMOVIEW_H__2DDFAE38_E030_4BB8_B81E_A6B77A4711E6__INCLUDED_)
#define AFX_QUICKFILLDEMOVIEW_H__2DDFAE38_E030_4BB8_B81E_A6B77A4711E6__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef __CDIBDATA_H__
#include "QuickFill.h"
#endif

class CQuickFillDemoView : public CScrollView
{
protected: // create from serialization only
	CQuickFillDemoView();
	DECLARE_DYNCREATE(CQuickFillDemoView)

private:
	CRect m_rcPos;
	COLORREF m_clrFill;
	int m_nMag;
	unsigned m_nMask;
	double m_dSeconds;
	CPoint m_AnchorPoint;
	CRect m_rcSelect;
	BOOL m_bSelecting;
	BOOL m_bSelected;

// Attributes
public:
	CQuickFillDemoDoc* GetDocument();
	CQuickFill m_Fill;

// Operations
public:
	void Magnify(int nMag);
	void DrawSelectRect(CDC* pDC);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CQuickFillDemoView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	virtual void OnInitialUpdate(); // called first time after construct
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CQuickFillDemoView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CQuickFillDemoView)
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnOpenpattern();
	afx_msg void OnUpdateOpenpattern(CCmdUI* pCmdUI);
	afx_msg void OnSlowmode();
	afx_msg void OnUpdateSlowmode(CCmdUI* pCmdUI);
	afx_msg void OnFillcolor();
	afx_msg void OnUpdateFillcolor(CCmdUI* pCmdUI);
	afx_msg void OnPatternclearcolor();
	afx_msg void OnUpdatePatternclearcolor(CCmdUI* pCmdUI);
	afx_msg void OnClosepattern();
	afx_msg void OnUpdateClosepattern(CCmdUI* pCmdUI);
	afx_msg void OnViewMag1();
	afx_msg void OnUpdateViewMag1(CCmdUI* pCmdUI);
	afx_msg void OnViewMag2();
	afx_msg void OnUpdateViewMag2(CCmdUI* pCmdUI);
	afx_msg void OnViewMag3();
	afx_msg void OnUpdateViewMag3(CCmdUI* pCmdUI);
	afx_msg void OnViewMag4();
	afx_msg void OnUpdateViewMag4(CCmdUI* pCmdUI);
	afx_msg void OnViewMag5();
	afx_msg void OnUpdateViewMag5(CCmdUI* pCmdUI);
	afx_msg void OnViewMag6();
	afx_msg void OnUpdateViewMag6(CCmdUI* pCmdUI);
	afx_msg void OnViewMag7();
	afx_msg void OnUpdateViewMag7(CCmdUI* pCmdUI);
	afx_msg void OnViewMag8();
	afx_msg void OnUpdateViewMag8(CCmdUI* pCmdUI);
	afx_msg void OnViewMag9();
	afx_msg void OnUpdateViewMag9(CCmdUI* pCmdUI);
	afx_msg void OnViewMag10();
	afx_msg void OnUpdateViewMag10(CCmdUI* pCmdUI);
	afx_msg void OnFillmask();
	afx_msg void OnUpdateFillmask(CCmdUI* pCmdUI);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnShowrevisit();
	afx_msg void OnUpdateShowrevisit(CCmdUI* pCmdUI);
	//}}AFX_MSG
	afx_msg void OnUpdatePos(CCmdUI *pCmdUI);
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in QuickFillDemoView.cpp
inline CQuickFillDemoDoc* CQuickFillDemoView::GetDocument()
   { return (CQuickFillDemoDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_QUICKFILLDEMOVIEW_H__2DDFAE38_E030_4BB8_B81E_A6B77A4711E6__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Software Developer (Senior)
United States United States
I am a senior software engineer who has been designing and developing software for many years, mostly in C/C++. You might say that I think in code; which is why I am passionate about my first rule of coding: “First do no harm”. So if I get carried away in my explanations, please realize that it is just part of my personality. I enjoy learning new things and, when I have the time, passing that knowledge onto others.

Comments and Discussions