Tuesday, May 5, 2009

C Program to implement Boundary Fill Algorithm

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>



void fill_right(x,y)
int x , y ;
{
if((getpixel(x,y) != WHITE)&&(getpixel(x,y) != RED))
{
putpixel(x,y,RED);
fill_right(++x,y);
x = x - 1 ;
fill_right(x,y-1);
fill_right(x,y+1);
}
delay(1);
}


void fill_left(x,y)
int x , y ;
{
if((getpixel(x,y) != WHITE)&&(getpixel(x,y) != RED))
{
putpixel(x,y,RED);

fill_left(--x,y);
x = x + 1 ;
fill_left(x,y-1);
fill_left(x,y+1);
}
delay(1);
}


void main()
{
int x,y,n,i;
int gd=DETECT,gm;
clrscr();

initgraph(&gd,&gm,"c:\\tc\\bgi");



/*- draw object -*/

line (50,50,200,50);
line (200,50,200,300);
line (200,300,50,300);
line (50,300,50,50);

/*- set seed point -*/
x = 100; y = 100;

fill_right(x,y);
fill_left(x-1,y);

getch();
}

6 comments:

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

awesome site... keep it up... vry helpful!!! :-)

Easy Tutor said...

Great website bro... Keep it up.

I thought you might also be interested in more C, C++ Programs

q-q said...

great site! very helpful. keep on sharing info similar to this. kudos!

www.triciajoy.com

Unknown said...

Hi, I think now I have a strong hold over the topic after going through the post. The subject that you have discussed in the post is really amazing; I will surely come back for more information.

Sorn
www.gofastek.com

Tutorialspoint said...

Yes its Great Website

SAP Tutorial
Computer Fundamentals Tutorial
Computer Graphics Tutorial
Salesforce Tutorial
sap c4c Online Training
c sharp Online Training
magento Online Training