Bitmap/Flood fill: Difference between revisions

Content added Content deleted
Line 306: Line 306:
static BYTE newColor;
static BYTE newColor;



static void skipLine(FILE* file)
void floodFill(int i, int j)
{
if ( 0 <= i && i < height
&& 0 <= j && j < width
&& bitmap[i][j] == oldColor )
{
bitmap[i][j] = newColor;
floodFill(i-1,j);
floodFill(i+1,j);
floodFill(i,j-1);
floodFill(i,j+1);
}
}


/* *****************************************************************************
* Input/output routines.
*/

void skipLine(FILE* file)
{
{
int c;
int c;
Line 323: Line 343:
}
}


void readPortableBitMap(FILE* file)
readPortableBitMap(FILE* file)
{
{
int i,j;
int i,j;
Line 349: Line 369:
fprintf(file,"%1d", bitmap[i][j]);
fprintf(file,"%1d", bitmap[i][j]);
fprintf(file,"\n");
fprintf(file,"\n");
}
}

void floodFill(int i, int j)
{
if ( 0 <= i && i < height
&& 0 <= j && j < width
&& bitmap[i][j] == oldColor )
{
bitmap[i][j] = newColor;
floodFill(i-1,j);
floodFill(i+1,j);
floodFill(i,j-1);
floodFill(i,j+1);
}
}
}
}