Mail Archives: djgpp/2000/12/13/14:08:15
On Tue, 12 Dec 2000 16:06:45 -0500, Sahab Yazdani
<sahaby AT operamail DOT com> wrote:
>Eli wrote.
>
>>> KNOWN BUGS:
>>> - FloodFills cause GPF
>>
>> Did you implement FloodFill as a recursive function? If so, you might
>> be blowing the stack due to too deep recursion. Post the full crash
>> message, if you cannot figure this out; section 12.2 of the FAQ might
>> help you solve this.
>
>it is a stack problem, i know that for a fact, i just didn't write it
>cuz I didn't think that people would want to know the nitty-gritties of
>the bug.... just as a side note: is there another way to implement a
>Flood Fill??
Pseudocode for horizontal run floodfill, which uses much less stack
than pixel-by-pixel floodfill:
floodfill_int(dc, x, y, destcolor, curcolor)
{
find the left and right sides of the horizontal line
that includes (x, y) and is solid curcolor; be careful
of off-by-one errors
draw that horizontal line in destcolor
for x = left to right
if color above this pixel matches curcolor
x = floodfill_int(x, y, destcolor, curcolor)
for x = left to right
if color below this pixel matches curcolor
x = floodfill_int(x, y, destcolor, curcolor)
return right
}
floodfill(dc, x, y, destcolor)
{
floodfill(dc, x, y, destcolor, getpixel(dc, x, y))
}
If you are filling large bitmaps and have heap space to spare, use a
queue of horizontal lines and a while loop instead of piling recursive
calls on the stack.
You might also want to look at the code for Allegro's floodfill.
--
<O
( \ GNOME vs. KDE: the game!
X http://pineight.8m.com/nes.htm
This is McAfee VirusScan. Add these two lines to your signature to
prevent the spread of signature viruses. http://www.mcafee.com/
- Raw text -