home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / graphics / 14279 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.8 KB

  1. Path: sparky!uunet!news.univie.ac.at!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!rpi!usc!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!exodus.Eng.Sun.COM!speedsail.Eng.Sun.COM!srnelson
  2. From: srnelson@speedsail.Eng.Sun.COM (Scott R. Nelson)
  3. Newsgroups: comp.graphics
  4. Subject: Re: "fill" algorithm
  5. Date: 27 Jan 1993 16:39:26 GMT
  6. Organization: Sun Microsystems Inc., Mountain View, CA
  7. Lines: 31
  8. Message-ID: <lmdeluINNs7o@exodus.Eng.Sun.COM>
  9. References: <kenb.0pwj@amiganet.chi.il.us> <1993Jan27.122027.9461@ulrik.uio.no>
  10. NNTP-Posting-Host: speedsail
  11.  
  12. eivind@kih.no (eivind hagen) writes:
  13.  
  14. >Ken Boi (kenb@amiganet.chi.il.us) wrote:
  15. >> Could someone inform me as to how a 'fill' works in graphical painting. 
  16. >
  17. >If you want it EASY, make a recursive call to the 4 adjacent pixels, and
  18. >for each pixel, check if it is the right color, and then change the
  19. >pixels color.
  20. >This is very slow, needs a BIG stack, but is foolproof!
  21.  
  22. I tried that once and even with 100 megabytes of virtual memory it
  23. ran out of stack space after filling less than 500,000 pixels on the
  24. background of a complex scene.  The system also went through a major
  25. thrashing period before the program died.  That doesn't fit my
  26. definition of "foolproof".
  27.  
  28. A very simple change would be to pick a pixel, then fill horizontally
  29. in both directions as far as possible.  Once done, go check all of the
  30. pixels above and below that filled region.  This uses much less stack
  31. space and is also faster.  There are certainly more speed optimizations
  32. that could be made to avoid redundant tests if you like to experiment.
  33.  
  34. You might also want to consider checking the 8 adjacent pixels rather
  35. than 4, if you want it to go through diagonal holes.
  36.  
  37. ---
  38.  
  39. Scott R. Nelson            srnelson@eng.sun.com
  40. Sun Microsystems
  41.  
  42. "Proofread carefully to see if you any words out."
  43.