Wednesday, 9 November 2011

BOUNDARY-FILL PROGRAM IN C

BOUNDARY FILL PROGRAM IN C

//***PROGRAM FOR BOUNDARY FILL ALGORITHM***//

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void b_fill(int x,int y,int f,int b)
{
  int c;
  c=getpixel(x,y);
  if((c!=b)&&(c!=f))
  {
      putpixel(x,y,f);
      delay(10);
      b_fill(x+1,y,f,b);
      b_fill(x,y+1,f,b);
      b_fill(x+1,y+1,f,b);
      b_fill(x-1,y-1,f,b);
      b_fill(x-1,y,f,b);
      b_fill(x,y-1,f,b);
      b_fill(x-1,y+1,f,b);
      b_fill(x+1,y-1,f,b);
  }
}
//void b_fill(int,int,int,int);
void main()
{
  int gd=DETECT,gm;
  initgraph(&gd,&gm,"c:\\tc\\bgi");
  rectangle(50,50,100,100);
  b_fill(55,55,4,15);
  getch();
}

3 comments:

  1. what is 'b' and 'f' in this example?

    ReplyDelete
  2. Those are the colours f- fill colour
    b- boundary colour

    ReplyDelete

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel