Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CuteBug

Recursion Problem with Fill Algorithm

This topic is 5740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The Boundary fill algorithm or Floodfill Algorithm crashes when the region to be filled is large ( for e.g. a circle with a radius greater than 50). How do we prevent this? Is there a better, efficient and faster algorithm? "A byte is a large bit to crunch!"

Share this post


Link to post
Share on other sites
Advertisement
dont use Recursion. It will fast fill the stack, i think you can set the stacksize someware insiden vc++.

Write the algorithm without the recursion.

Share this post


Link to post
Share on other sites
You are having stack overflows. You can either use an explicit stack, or use a different algorithm.

The other algorithm would be a breadth-first (rather than depth-first) fill. Here''s how it works.

- Color the current pixel.
- Add all the uncolored neighbors to a list.
- Remove the current pixel from the list.
- Repeat with another pixel from the list.
- When the list is empty, you''re done.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!