Anonymous user
Bitmap/Flood fill: Difference between revisions
m
→Simple and complete example in C89
Line 306:
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.
*/
{
int c;
Line 323 ⟶ 343:
}
{
int i,j;
Line 349 ⟶ 369:
fprintf(file,"%1d", bitmap[i][j]);
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);
}
}
|