The flood fill algorithm replaces a current color with a new color.Here i have used the 8-point technique to color a region. The program is using a recurssive function. The function return when the pixel to be replaced is not the given old color.
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void flood_fill(int x,int y, int ncolor,int ocolor)
{
if(getpixel(x,y) == ocolor)
{
putpixel(x,y,ncolor);
flood_fill(x+1,y,ncolor,ocolor);
flood_fill(x+1,y-1,ncolor,ocolor);
flood_fill(x+1,y+1,ncolor,ocolor);
flood_fill(x,y-1,ncolor,ocolor);
flood_fill(x,y+1,ncolor,ocolor);
flood_fill(x-1,y,ncolor,ocolor);
flood_fill(x-1,y-1,ncolor,ocolor);
flood_fill(x-1,y+1,ncolor,ocolor);
}
}
void main()
{
int x,y,ncolor,ocolor;
clrscr();
printf("Enter the seed pointn");
scanf("%d%d",&x,&y);
printf("Enter old color : ");
scanf("%d",&ocolor);
printf("Enter new color : ");
scanf("%d",&ncolor);
int gd=DETECT,gm=DETECT;
initgraph(&gd,&gm,"");
cleardevice();
/*
Draw some figures
to create closed shapes
you can use any biut-in functions.
Please everyone make their own figures.
*/
flood_fill(x,y,ncolor,ocolor);
getch();
}

thanks for this programming....this will help me in improvement in my programming.