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

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

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

void main()
{

 int gd, gm;
 int x,y,b_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 boundary color:");
 scanf("%d",&b_col);
 printf("\n Enter fill color:");
 scanf("%d",&f_col);
 rectangle(150,150,200,200);
 boundary(x,y,f_col,b_col);
 getch();
 delay(100);
 closegraph();
}
void boundary(x, y, f_col, b_col)

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