protected unsafe override void ProcessFilter( UnmanagedImage image, Rectangle rect )
{
// skip, if there is nothing to fill
if ( !rect.Contains( startingPoint.X, startingPoint.Y ) )
return;
// save bounding rectangle
startX = rect.Left;
startY = rect.Top;
stopX = rect.Right - 1;
stopY = rect.Bottom - 1;
// save image properties
scan0 = image.ImageData.ToInt32( );
stride = image.Stride;
// create map visited pixels
checkedPixels = new bool[image.Height, image.Width];
if ( image.PixelFormat == PixelFormat.Format8bppIndexed )
{
byte startColor = *( (byte*) CoordsToPointerGray( startingPoint.X, startingPoint.Y ) );
minG = (byte) ( Math.Max( 0, startColor - tolerance.G ) );
maxG = (byte) ( Math.Min( 255, startColor + tolerance.G ) );
LinearFloodFill4Gray( startingPoint );
}
else
{
byte* startColor = (byte*) CoordsToPointerRGB( startingPoint.X, startingPoint.Y );
minR = (byte) ( Math.Max( 0, startColor[RGB.R] - tolerance.R ) );
maxR = (byte) ( Math.Min( 255, startColor[RGB.R] + tolerance.R ) );
minG = (byte) ( Math.Max( 0, startColor[RGB.G] - tolerance.G ) );
maxG = (byte) ( Math.Min( 255, startColor[RGB.G] + tolerance.G ) );
minB = (byte) ( Math.Max( 0, startColor[RGB.B] - tolerance.B ) );
maxB = (byte) ( Math.Min( 255, startColor[RGB.B] + tolerance.B ) );
LinearFloodFill4RGB( startingPoint );
}
}