Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9095681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:40:01+00:00 2026-06-16T23:40:01+00:00

I am currently creating a little paint program for exercise. Right now i’m trying

  • 0

I am currently creating a little paint program for exercise. Right now i’m trying to do the paint bucket tool, or in other words a flood fill. The funny thing is: if the number of pixels which have to be filled is small, everything works fine. If hate number of to filling pixels is higher, it gives me a SO-Exception. Here is my code:

private void FloodFill(Bitmap picture, int x, int y)
{
  if (x <= 0 || y <= 0 || x >= DrawingPanel.Width || y >= DrawingPanel.Height)
  {
    return;
  }

  if (picture.GetPixel(x, y) != löschFarbe)
  {
    return;
  }

  if (picture.GetPixel(x, y) == löschFarbe)
  {
    picture.SetPixel(x, y, ColorButton.BackColor);
  }

  FloodFill(picture, x + 1, y);
  FloodFill(picture, x, y + 1);
  FloodFill(picture, x - 1, y);
  FloodFill(picture, x, y - 1);
  FloodFill(picture, x + 1, y + 1);
  FloodFill(picture, x - 1, y + 1);
  FloodFill(picture, x + 1, y - 1);
  FloodFill(picture, x - 1, y - 1);
}

“löschFarbe” is the color which is clicked (which will be erased/overwritten with another color)

Error occurring: If i want to fill the complete picture or a big space, I get an error here:

if (picture.GetPixel(x, y) != löschFarbe)
  {
    return;
  }

Anyone knows how I can solve this?

BTW this is a picture of my program:
Paint

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:40:02+00:00Added an answer on June 16, 2026 at 11:40 pm

    Even a moderate sized floodfill will blow your call stack.

    Try converting this recursion based method to a stack based method as in this question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After creating a GUI for my personal little application, I am trying to compile
Currently I´m coding a little app, that allows to finger-paint over a given picture.
A little background first as to why I need this. I am currently creating
I'm currently working on creating my own blog section.. After brainstorming a little while
I'm creating a tftp-like program but instead of stop and wait, I'm trying to
I am building a little tool in ruby for creating directories and files based
im currently creating a graph for an app, using coreplot and have a problem
I am currently creating an application for compiling multiple java projects in one go
I'm currently creating a payment SDK for android, as such I want to send
I'm currently creating an iPhone app (Xcode 4.3.1, IOS 5) that could use Bluetooth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.