QuickFill/flood fill algorithm in C#/VB.NET

2020-02-13 04:40发布

问题:

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?

Thanks, Erick

回答1:

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.



回答2:

I had a same question a long time ago and I found this