Android Question Flood Fill?

PenguinHero

Member
Licensed User
Longtime User
Hi All,

Does anyone know of any B4A libraries or code to do a flood fill?

This is where you fill a section of a line drawing (or similar) with a chosen colour. A common thing to do for children's drawing programs, for example.

I searched the B4A forums and found a recursive routine which appears to fail because the Android OS only has a 16K stack. I wrote my own non-recursive routine based on an algorithm that I found online, but it is too slow.
There was one forum reference to someone having an "instant" fill routine, but at the time they didn't want to share it. Perhaps now they do?


Thanks,
PenguinHero.
 

socialnetis

Active Member
Licensed User
Longtime User
A few months ago I wrote a flood fill algorithm and was pretty fast, but I lost it (I wrote in a trip in my netbook, and formatted it a few weeks ago).
Anyway, the algorithm was the one provided by wikipedia: http://en.wikipedia.org/wiki/Flood_fill . You should go with the no-recursive implementation (I used the one that uses a loop for the west and east directions as an optimization).

The performance was very good. Only for very large areas and fussy shapes, my motorola defy (800 mhz, 512mb ram) was a little slow but acceptable (~1sec). And was really smooth with a galaxy tab 2 (1ghz dual core, 1gb ram)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…