delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/12/13/14:08:15

From: Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p>
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: <Pine DOT SUN DOT 3 DOT 91 DOT 1001212112830 DOT 24447M-100000 AT is> <3A369365 DOT 9040700 AT operamail DOT com>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
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
<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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019