Search code examples
c#.netalgorithmgraphicsflood-fill

QuickFill/flood fill algorithm


I need a flood fill algorithm to fill existing raster shapes with various colors and fill patterns. From what I know, the QuickFill algorithm is the best way to do a flood fill. I've found a number of implementations, but they are all in C++ and use Windows SDK functions. The problem is that I need a .NET implementation.

If worse comes to worse I can write a new implementation, but I would rather use an existing implementation (that hopefully doesn't have bugs). Is anyone aware of an existing flood fill implementation in C#/VB.NET?


Solution

  • I like a lot to work with the Aforge Library that has two good FlodFill implementations, but both are 4 directional only.

    If you need other implementations there exist two code project articles Flood Fill Algorithms in C# and GDI+ and Queue-Linear Flood Fill: A Fast Flood Fill Algorithm.

    And if you like to dig in the code and learn, there is the Paint .Net project that has an excelent flood fill implementation.