Headlines
Loading...
Computer graphics program - Program for 4-connected flood fill algorithm

Computer graphics program - Program for 4-connected flood fill algorithm

Program for four connected flood fill algorithm.
Code
#include<stdio.h>
#include<graphics.h>

void main()
{

 int gd, gm;
 int x,y,o_col,f_col;
 void boundary(int,int,int,int);
 clrscr();

 detectgraph(&gd, &gm);
 initgraph(&gd, &gm, "C:\\TC\\BGI");
 printf("\n Enter x value:");
 scanf("%d",&x);
 printf("\n Enter y value:");
 scanf("%d",&y);
 printf("\n Enter fill color:");
 scanf("%d",&f_col);
 rectangle(100,100,150,150);
 boundary(x,y,f_col,0);
 getch();
 delay(100);
 closegraph();

}

void boundary(x, y, f_col, o_col)
{
int current;
current=getpixel(x,y);

    if(current==o_col)
{
  putpixel(x, y, f_col);
  boundary(x+1, y, f_col, o_col);
  boundary(x-1, y, f_col, o_col);
  boundary(x, y+1, f_col, o_col);
  boundary(x, y-1, f_col, o_col);
}
 }
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***