Beispiel #1
0
        public static void Fill(Point p, Color fillColor, ref ZoomPictureBox PicBox)
        {
            int   x = p.X;
            int   y = p.Y;
            Color temp;

            temp = GetPx(x, y, ref PicBox);
            int countLeft  = x;
            int countRight = x;

            while (countLeft - 1 > 0 && GetPx(countLeft - 1, y, ref PicBox).ToArgb() == temp.ToArgb())
            {
                countLeft--;
            }
            while (countRight + 1 < PicBox.image.Width && GetPx(countRight + 1, y, ref PicBox).ToArgb() == temp.ToArgb())
            {
                countRight++;
            }

            for (int i = countLeft; i <= countRight; i++)
            {
                PicBox.image.SetPixel(i, y, fillColor);
            }

            for (int i = countLeft; i <= countRight; i++)
            {
                if (GetPx(i, y - 1, ref PicBox).ToArgb() == temp.ToArgb() && y - 1 > 0)
                {
                    Fill(new Point(i, y - 1), fillColor, ref PicBox);
                }

                if (GetPx(i, y + 1, ref PicBox).ToArgb() == temp.ToArgb() && y + 1 < PicBox.image.Height - 1)
                {
                    Fill(new Point(i, y + 1), fillColor, ref PicBox);
                }
            }
        }
Beispiel #2
0
 public static Color GetPx(int x, int y, ref ZoomPictureBox PicBox)
 {
     return(PicBox.image.GetPixel(x, y));
 }