") private void fill(Bitmap picture, int x, int y, Color bcolor){ fill(bmp, e.X, e.Y, bmp.GetPixel(e.X, e.Y)); pictureBox1.Image = bmp; } ================================================= { if (x > 0 && x < picture.Width && y > 0 && y < picture.Height) { Point p = new Point(x, y); Stack<Point> s = new Stack<Point>(); s.Push(p); while (s.Count != 0) { p = s.Pop(); Color currentcolor = picture.GetPixel(p.X, p.Y); if (currentcolor == bcolor) { picture.SetPixel(p.X, p.Y, currentcolor); s.Push(new Point(p.X - 1, p.Y)); s.Push(new Point(p.X + 1, p.Y)); s.Push(new Point(p.X, p.Y - 1)); s.Push(new Point(p.X, p.Y + 1)); } So ,any suggestion for correcting or a better code for paint bucket? |
Paint Bucket function code in C# ,hangs when running
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Anil Sadangi2 pointsPosted Jan 28, 2016, 4:33 AM EST
Anyway there's some other approach to implementing Paint Bucket in this post:
http://support.leadtools.com/SupportPortal/CS/forums/44770/ShowPost.aspx