8-connectivity

//Program to find the connectivity using 8-connectivity

#include<stdio.h>

#include<conio.h>

#include<dos.h>

#include<graphics.h>

void main()

 {

   int i,j,gd=DETECT,gm,ch1;

   char ch;

   FILE *fp;

   fp = fopen("c:\\a2.bmp","r");

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

   fseek(fp,1078,0L);

   for(i=0;i<256;i++)

    for(j=0;j<256;j++)

     {

      ch = fgetc(fp);

      putpixel(j,256-i,ch);

       }

   getch();

   fclose(fp);

    fp = fopen("c:\\4c.bmp","rb+");

    fseek(fp,1078,0L);

   for(i=1;i<256;i++)

    for(j=1;j<256;j++)

     {

       ch1=getpixel(j,i);

      if(ch1==0)

       con8(j,i);

       }

   getch();

   }

    con8(int x,int y)

   {

     int c;

     c = getpixel(x,y);

     if (c != 0)

      return;

     else

      {

       putpixel(x,y,10);

       delay(20);

       con8(x,y+1);

       con8(x,y-1);

       con8(x+1,y);

       con8(x-1,y);

       con8(x+1,y+1);

       con8(x-1,y-1);

       con8(x+1,y-1);

       con8(x-1,y+1);

      }

   }