Scott R. Nelson (srnelson@speedsail.Eng.Sun.COM) wrote:
> I tried that once and even with 100 megabytes of virtual memory it
> ran out of stack space after filling less than 500,000 pixels on the
> background of a complex scene. The system also went through a major
> thrashing period before the program died. That doesn't fit my
> definition of "foolproof".
Well, if U got a proper OS it's foolproof :-)
> A very simple change would be to pick a pixel, then fill horizontally
> in both directions as far as possible. Once done, go check all of the
> pixels above and below that filled region. This uses much less stack
> space and is also faster. There are certainly more speed optimizations
> that could be made to avoid redundant tests if you like to experiment.
I know, and this is what I normally do: Also, a nice thing is to save all
the x1,x2,y positions while filling, and after you are done, you have a list of the entire area. Then, use this for easy pattern filling etc. You also know the min/max of the area, so auto-scaling images for filling etc.
BTW: Any other smart algorithms anyone? This line-scanning is the fastest I've
found so far...
> You might also want to consider checking the 8 adjacent pixels rather
> than 4, if you want it to go through diagonal holes.
Hmm. This is not normal is it? Beides, MORE STACK is needed :-)))