Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Flood-Fill function : C

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 27-01-2010
Member
 
Join Date: Jan 2010
Posts: 19
Flood-Fill function : C
  

Hi, How are you all! I am the working in the XYZ company, as a C programmer. I have to submit the presentation on the Flood Fill function to my executive. But I don't know anything about the Flood Fill. So, I would like to know about the Flood Fill function. I also would like to know about the Flood Fill function works and what is the algorithm of the Flood Fill function. So, Is there is anyone who can know about the Flood Fill function ? Please, help me!!!!!

Reply With Quote
  #2  
Old 27-01-2010
Member
 
Join Date: Jan 2008
Posts: 1,507
Flood-Fill function

Hello, Flood fill can also be known as the seed fill. Flood Fill is an algorithm that can determines the area that is connected to a given node in a multi-dimensional array. Flood Fill can be used in the " bucket" fill tool of paint programs. In paint Flood Fill can be used to determine which parts of a bitmap to fill with color and in games like puzzle games such as Magic Drop, Puyo Puyo, Minesweeper, Lumines, Samegame and Magical Drop for determining which pieces are cleared. Flood-Fill can also be known as the Boundary Fill when it is applied on an image to fill a particular area that is bounded with color.
Reply With Quote
  #3  
Old 27-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,842
Flood-Fill function : C

I think the Flood Fill is an algorithm. The Flood Fill algorithm can takes three parameters such as a start node, a target color, and a replacement color. The Flood Fill algorithm is looking for all the nodes in the an array which are connected to the start node by a path of the target color and changes them to the replacement color. Flood Fill algorithm can be structured in many ways but they all make use of a stack or queue data structure implicitly or explicitly.
Reply With Quote
  #4  
Old 27-01-2010
Member
 
Join Date: May 2008
Posts: 2,373
Flood-Fill function : C

I think you have to carefully see the following line of code of C Program that demonstrates the Implementation of Flood Fill Algorithm :
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
void fill_right(p,q)
int p , q ;
{
if(getpixel(p,q) == 0)
{
putpixel(p,q,RED);
fill_right(++p,q);
p = p - 1 ;
fill_right(p,q-1);
fill_right(p,q+1);
}
}
void fill_left(p,q)
int p , q ;
{
if(getpixel(p,q) == 0)
{
putpixel(p,q,RED);
fill_left(--p,q);
p = p + 1 ;
fill_left(p,q-1);
fill_left(p,q+1);
}
}
void main()
{
int p , q ,b[10][10];
int ge, gn ,p,j;
detectgraph(&ge,&gn);
initgraph(&ge,&gn,"c:\\tc\\bgi");
printf(" \n\n\tEnter the no. of edges of polygon : ");
scanf("%d",&p);
printf("\n\n\tEnter the cordinates of polygon :\n\n\n ");
for(j=0;j<p;j++)
{
printf("\tP%d Q%d : ",j,j);
scanf("%d %d",&b[j][0],&b[j][1]);
}
b[p][0]=b[0][0];
b[p][1]=b[0][1];
printf("\n\n\tEnter the seed pt. : ");
scanf("%d%d",&p,&q);
cleardevice();
setcolor(WHITE);
for(j=0;j<p;j++)
{
line(b[j][0],b[j][1],b[j+1][0],b[j+1][1]);
}
fill_right(p,q);
fill_left(p-1,q);
getch();
}
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #5  
Old 27-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,385
Flood-Fill function

I think one of the algorithm such implicitly stack-based i.e. recursive flood-fill implementation for a 2-D array as follows:
Flood-fill (node, target-color, replacement-color):
1. If the color of node is not equal to target-color then return.
2. Set the color of node to replacement-color.
3. Perform Flood-fill (one step to the west of node, target-color, replacement-color).
Perform Flood-fill (one step to the east of node, target-color, replacement-color).
Perform Flood-fill (one step to the north of node, target-color, replacement-color).
Perform Flood-fill (one step to the south of node, target-color, replacement-color).
4. Return.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Flood-Fill function : C"
Thread Thread Starter Forum Replies Last Post
Hypertransport Sync Flood Error with MSI 870-G45 motherboard Prabhukumar Motherboard Processor & RAM 9 13-10-2011 05:01 PM
"Magic Fill import function" in Maxthon 3 Dum Technology & Internet 5 04-07-2011 07:19 PM
IRC/BACKDOOR.FLOOD Trojan zhallart Windows Software 4 18-12-2010 11:31 AM
IRC/Flood.gen.h Virus Problem Adrina_g Networking & Security 5 11-01-2010 11:54 AM


All times are GMT +5.5. The time now is 02:58 PM.