C#:
public static void FillArea(Bitmap editBitmap, int x, int y, Color replThisColor, Color withThisColor)
{
if(editBitmap.GetPixel(x,y)==replThisColor)
{
editBitmap.SetPixel(x,y, withThisColor);
int l= x-1;
int r= x+1;
int u= y-1;
int d= y+1;
if(r < editBitmap.Width)
{
if(editBitmap.GetPixel(r, y)==replThisColor) FillArea(editBitmap, r, y, replThisColor, withThisColor);
}
if(d < editBitmap.Height)
{
if(editBitmap.GetPixel(x, d)==replThisColor) FillArea(editBitmap, x, d, replThisColor, withThisColor);
}
if(l > -1)
{
if(editBitmap.GetPixel(l, y)==replThisColor) FillArea(editBitmap, l, y, replThisColor, withThisColor);
}
/*if(u > -1)
{
if(editBitmap.GetPixel(x, u)==replThisColor) FillArea(editBitmap, x, u, replThisColor, withThisColor);
}*/
}