Tuesday, 23 February 2016

Implementation of boundary fill algorithm

Q)Boundary fill algorithm.
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void bounfill(int x,int y)
    { 
int a =getpixel(x,y);
    setcolor(3);
    if(a!=2&&a!=3)
{
    putpixel(x,y,3);
    bounfill(x+1,y);
    bounfill(x-1,y);
    bounfill(x,y+1);
    bounfill(x,y-1);
    }
    }

int main()
{

   int gdriver = DETECT, gmode;
   initgraph(&gdriver, &gmode, "C:\\TC\\bgi");
   setcolor(2);
   circle(250, 250, 50);
   bounfill(250,250);
   getch();
   closegraph();
   return 0;
}

No comments:

Post a Comment