Embed presentation
Download to read offline
![/*
Title: Flood Filling Algorithm
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 20150323
*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include"D:/GP/header/grap.h"
double x[]={20,40,40,20};
double y[]={20,20,40,40};
int points=4;
int boundaryColor=15;
int fillColor=10;
int newColor=7;
void drawPolygon()
{
int i,j;
for(i=0;i<points;i++)
{](https://image.slidesharecdn.com/floodfilling-150325025316-conversion-gate01/75/Flood-Filling-Algorithm-in-C-1-2048.jpg)
![j=(i+1)%points;
line(x[i],y[i],x[j],y[j]);
}
}
void bfill4(int x,int y)
{
int currentColor=getpixel(x,y);
if((currentColor!=boundaryColor) && (currentColor!=fillColor))
{
putpixel(x,y,fillColor);
bfill4(x+1,y);
bfill4(x-1,y);
bfill4(x,y+1);
bfill4(x,y-1);
}
}
void bfill8(int x,int y)
{
int currentColor=getpixel(x,y);
if((currentColor!=boundaryColor) && (currentColor!=fillColor))
{](https://image.slidesharecdn.com/floodfilling-150325025316-conversion-gate01/85/Flood-Filling-Algorithm-in-C-2-320.jpg)




This document contains code for implementing flood filling and boundary filling algorithms. It defines functions for 4-connected and 8-connected boundary filling (bfill4 and bfill8) and flood filling (ffill4 and ffill8). These functions recursively change the color of pixels connected to a starting pixel. The main function draws a polygon, performs 8-connected boundary and flood filling, and ends the graphics mode.
![/*
Title: Flood Filling Algorithm
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 20150323
*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include"D:/GP/header/grap.h"
double x[]={20,40,40,20};
double y[]={20,20,40,40};
int points=4;
int boundaryColor=15;
int fillColor=10;
int newColor=7;
void drawPolygon()
{
int i,j;
for(i=0;i<points;i++)
{](https://image.slidesharecdn.com/floodfilling-150325025316-conversion-gate01/75/Flood-Filling-Algorithm-in-C-1-2048.jpg)
![j=(i+1)%points;
line(x[i],y[i],x[j],y[j]);
}
}
void bfill4(int x,int y)
{
int currentColor=getpixel(x,y);
if((currentColor!=boundaryColor) && (currentColor!=fillColor))
{
putpixel(x,y,fillColor);
bfill4(x+1,y);
bfill4(x-1,y);
bfill4(x,y+1);
bfill4(x,y-1);
}
}
void bfill8(int x,int y)
{
int currentColor=getpixel(x,y);
if((currentColor!=boundaryColor) && (currentColor!=fillColor))
{](https://image.slidesharecdn.com/floodfilling-150325025316-conversion-gate01/85/Flood-Filling-Algorithm-in-C-2-320.jpg)


