Results 1 to 5 of 5

Thread: Flood-Fill function : C

  1. #1
    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!!!!!

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    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.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,856

    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,393

    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();
    }

  5. #5
    Join Date
    Oct 2005
    Posts
    2,394

    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.

Similar Threads

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •