image_floodfill_span library
A class that implements the flood fill algorithm for an image.
The flood fill algorithm starts at a given point and spreads outwards, filling all connected pixels that have the same color as the starting point with a new color.
The algorithm processes the image in smaller chunks to avoid memory spikes.
Example usage:
final ui.Image image = ...; // Load your image
final ImageFloodFillSpanImpl floodFill = ImageFloodFillSpanImpl(image);
final ui.Image? filledImage = await floodFill.fill(startX, startY, newColor);
The fill
method takes the starting coordinates (startX
, startY
) and the
new color (newColor
) to fill the connected area.
The chunkSize
constant defines the number of pixels to process in each chunk.
The _isInside
method checks if a pixel is inside the image boundaries and
has the target color.