AForge.Imaging.Filters.VerticalRunLengthSmoothing.ProcessFilter C# (CSharp) Метод

ProcessFilter() защищенный Метод

Process the filter on the specified image.
protected ProcessFilter ( UnmanagedImage image, Rectangle rect ) : void
image UnmanagedImage Source image data.
rect System.Drawing.Rectangle Image rectangle for processing by the filter.
Результат void
        protected override unsafe void ProcessFilter( UnmanagedImage image, Rectangle rect )
        {
            int startX = rect.Left;
            int stopX  = startX + rect.Width;

            int height = rect.Height;

            int stride = image.Stride;

            byte* basePtr = (byte*) image.ImageData.ToPointer( ) + rect.Top * stride + startX;

            for ( int x = startX; x < stopX; x++ )
            {
                byte* ptr = basePtr;
                byte* columnStartPtr = ptr;
                byte* columnEndPtr = ptr + stride * height;

                // fill gaps between white pixels
                while ( ptr < columnEndPtr )
                {
                    byte* gapStart = ptr;
                    int  gapSize = 0;

                    // look for non black pixel
                    while ( ( ptr < columnEndPtr ) && ( *ptr == 0 ) )
                    {
                        ptr += stride;
                        gapSize++;
                    }

                    // fill the gap between white areas
                    if ( gapSize <= maxGapSize )
                    {
                        if ( ( processGapsWithImageBorders ) ||
                           ( ( gapStart != columnStartPtr ) && ( ptr != columnEndPtr ) ) )
                        {
                            while ( gapStart < ptr )
                            {
                                *gapStart = 255;
                                gapStart += stride;
                            }
                        }
                    }

                    // skip all non black pixels
                    while ( ( ptr < columnEndPtr ) && ( *ptr != 0 ) )
                    {
                        ptr += stride;
                    }
                }

                basePtr++;
            }
        }
    }