Page 1 of 1

[VB.Net] Flood The Paint Away

Posted: Sun Mar 30, 2014 11:29 am
by Usman55
I made this app for one of the Mad March challenges. It is basically a paint app in which we can select a color a fill it in the clicked region. It is like the Bucket Fill tool in MS Paint or any other image editing software.

I tried writing my own logarithm for flood filling and succeeded to some extent. The code checked the neighboring pixels of the point clicked if they are of the same color or not and filled them if they were. But the problem was that the code was too slow and the app froze until the function was completed. I probably should have used a separate thread but I don't have much experience with thread yet, so that was a no for me. Filling an area as small as 40 pixels took 5 seconds, which was very slow. So I scrapped the idea.

The new code is not by me but from another website, which now I don't remember. I'll see if I find that page and credit the person behind this awesome code. Other methods of flood filling include calling an API ExtFloodFill or by using SafeFloodFill/UnsafeFloodFill. These methods didn't work for me either because I was unable to make them work for a picturebox or they took too long to fill a large area. However, the code in this source is very responsive and at least as fast as the Bucket Fill tool in MS Paint.

Image