public void FillArea(Bitmap screen, Color color, Point point)
{
int currentY = 0;
int minY = 0;
int maxY = 0;
//screen.SetPixel(x, y, color);
currentY = point.Y - 1;
while (currentY >= 0 && screen.GetPixel(point.X, currentY) != color)
{
screen.SetPixel(point.X, currentY, color);
currentY--;
}
minY = currentY + 1;
currentY = point.Y;
while (currentY < screen.Height && screen.GetPixel(point.X, currentY) != color)
{
screen.SetPixel(point.X, currentY, color);
currentY++;
}
maxY = currentY - 1;
for (int i = minY; i < maxY; i++)
{
if (point.X > 0 && screen.GetPixel(point.X - 1, i) != color)
{
FillArea(screen, color, new Point(point.X - 1, i));
}
if (point.X < screen.Width - 1 && screen.GetPixel(point.X + 1, i) != color)
{
FillArea(screen, color, new Point(point.X + 1, i));
}
}
}