From: Damian Yerrick Newsgroups: comp.os.msdos.djgpp Subject: Re: ANNOUNCE: GRFX2 Gaming Library Organization: Pin Eight Software http://pineight.8m.com/ Message-ID: <3f3f3t8so841tscibdqejiptuaqhennrmn@4ax.com> References: <3A369365 DOT 9040700 AT operamail DOT com> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 55 X-Trace: +4f596rVsb61VL7UW0j2kZ0Gi+JijOiQsdyLzmX684KtvGdxk5LZ3d54pbXFzW4/UjxP20XGso68!G3FlbOEHcq3jeiJyZkQ2zNtNWKgzEas4pNA81bIvnw7Uwy2LRK+8NFhVBWdaEBp3eqF6dGR/XqGd!z3J5Zg== X-Complaints-To: abuse AT gte DOT net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly NNTP-Posting-Date: Wed, 13 Dec 2000 15:02:55 GMT Distribution: world Date: Wed, 13 Dec 2000 15:02:55 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Tue, 12 Dec 2000 16:06:45 -0500, Sahab Yazdani 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. --