home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!portal!lll-winken!fnnews.fnal.gov!mp.cs.niu.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!eehp6!kh5856
- From: kh5856@eehp6 (Kwun-Heng Ho)
- Newsgroups: comp.lang.c
- Subject: Help needed with non-recursive floodfill
- Message-ID: <Bxo6sE.902@news.cso.uiuc.edu>
- Date: 13 Nov 92 19:43:23 GMT
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Organization: University of Illinois at Urbana
- Lines: 31
-
-
- Could anybody out there think up a non-recursive algorithm for floodfill?
- Floodfill is defined as a function/procedure which takes x/y coordinates,
- new color, and border color and fills the region bounded by the border with
- the new color. I tried the recursive method but I ran out of stack space.
- I'm afraid that after using LISP for a year, everything looks recursive to
- me. I can't for the life of me remember the non-recursive algorithm for
- floodfill!
- Maybe somebody could give me a recursive algorithm which takes less
- space that the one I'm using.
-
- void floodfill(int x,y,new,border)
- {
- putpixel(x,y,new);
- if ((getpixel(x+1,y) != border) && (getpixel(x+1,y) != new))
- floodfill(x+1,y,new,border);
- if . . . .
- if . . . .
- if . . . .
- }
-
- You get the idea....
-
-
- Thanks alot...
-
- --
- ************************************************
- * Bor-Tyng Lin *
- * kh5856@eehp6.cen.uiuc.edu *
- * "Love bites" - from "Dracula" *
-