C++ PROGRAM TO IMPLEMENT THE CONCEPT OF 8 WAY BOUNDARY FILLING ALGORITHM

C++ PROGRAM TO IMPLEMENT THE CONCEPT OF 8 WAY BOUNDARY FILLING ALGORITHM

CODE:

#include<stdio.h>

#include <graphics.h>

void boundaryFill8(int x, int y, int fill_color,int boundary_color)

{

    if(getpixel(x, y) != boundary_color &&

       getpixel(x, y) != fill_color)

    {

        putpixel(x, y, fill_color);

        boundaryFill8(x + 1, y, fill_color, boundary_color);

        boundaryFill8(x, y + 1, fill_color, boundary_color);

        boundaryFill8(x - 1, y, fill_color, boundary_color);

        boundaryFill8(x, y - 1, fill_color, boundary_color);

        boundaryFill8(x - 1, y - 1, fill_color, boundary_color);

        boundaryFill8(x - 1, y + 1, fill_color, boundary_color);

        boundaryFill8(x + 1, y - 1, fill_color, boundary_color);

        boundaryFill8(x + 1, y + 1, fill_color, boundary_color);

    }

}


int main()

{

    int gd = DETECT, gm;

    initgraph(&gd, &gm, "");

    rectangle(50, 50, 200, 200);

    boundaryFill8(55, 55, 4, 15);

    delay(10000);

    getch();

    closegraph();

    return 0;

}



OUTPUT:





Comments

Popular posts from this blog

C++ PROGRAM TO IMPLEMENT THE CONCEPT OF REFLEXION

C++ PROGRAM TO IMPLEMENT THE CONCEPT OF FIXED SCALING

C++ PROGRAM TO IMPLEMEMT THE CONCEPT OF FLOODFILL ALGORITHM