Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » GDI+ » General » Downloads
 
Add your own
alternative version

Flood Fill Algorithms in C# and GDI+

, 4 Oct 2003
Discusses and demonstrates flood fill algorithms in C# with GDI+.
floodfill_demo.zip
FloodFill.cmbx
FloodFill.MainForm.resources
FloodFill.prjx
demo.JPG
FloodFill.exe
floodfill_src.zip
FloodFill.cmbx
FloodFill.MainForm.resources
FloodFill.prjx
<?xml version="1.0"?>
<abouttext>


<about id="Linear">LINEAR ALGORITHM
The linear algorithm first finds the horizontal extent of the color on a given level, then it loops across initializing the fill loop upwards and downwards for each point along the way. 

By handling vertical and horizontal checking separately, this algorithm consumes only half the stack space that the recursive algorithm uses, while avoiding the extra heap space needed for a queue.  It is also just as fast as the recursive algorithm.
</about>

<about id="Queue">QUEUE ALGORITHM
The queue algorithm is similar to the recursive algorithm, except that it adds the points to be checked to a queue rather than calling them directly.  The loop returns immediately to the main fill method, rather than calling itself recursively.  It requires extra heap space for a queue, but it uses hardly any stack space.  

The queue algorithm is by far the slowest algorithm, taking about twice as long as the others.  This may be partly because of lack of optimizations in the .NET Queue class, but the queue method would be slower regardless of whether the Queue class was optimized.

</about>

<about id="Recursive">RECURSIVE ALGORITHM
This is the most common, and simplest to implement.  The recursive algorithm branches in all directions at once.  This can (read: often will) lead to stack overflows in a managed environment.
</about>

</abouttext>

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

J. Dunlap
Web Developer
United States United States
My main goal as a developer is to improve the way software is designed, and how it interacts with the user. I like designing software best, but I also like coding and documentation. I especially like to work with user interfaces and graphics.
 
I have extensive knowledge of the .NET Framework, and like to delve into its internals. I specialize in working with VG.net and MyXaml. I also like to work with ASP.NET, AJAX, and DHTML.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 5 Oct 2003
Article Copyright 2003 by J. Dunlap
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid