1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
//function performs flood fill operation on image
void floodFill( unsigned int fpaRow, unsigned int fpaCol, int fpaColour, int fpaImage[][MAX_COL] )
{
//if the pixels are not the same colour
if ( fpaImage[fpaRow][fpaCol] != fpaImage[fpaRow][fpaCol] )
{
//display image
display( fpaImage );
return;
}
else
{
//change the colour
fpaImage[fpaRow][fpaCol] = fpaColour;
//check pixel above
floodFill( fpaRow+1, fpaCol, fpaColour, fpaImage );
//check pixel below
floodFill( fpaRow-1, fpaCol, fpaColour, fpaImage );
//check pixel to right
floodFill( fpaRow, fpaCol+1, fpaColour, fpaImage );
//check pixel to left
floodFill( fpaRow, fpaCol-1, fpaColour, fpaImage );
return;
}
}
|