AForge.Imaging.Filters.GammaCorrection.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 pixelSize = ( image.PixelFormat == PixelFormat.Format8bppIndexed ) ? 1 : 3;

            // processing start and stop X,Y positions
            int startX  = rect.Left * pixelSize;
            int startY  = rect.Top;
            int stopX   = startX + rect.Width * pixelSize;
            int stopY   = startY + rect.Height;
            int offset  = image.Stride - rect.Width * pixelSize;

            // do the job
            byte* ptr = (byte*) image.ImageData.ToPointer( );

            // allign pointer to the first pixel to process
            ptr += ( startY * image.Stride + startX );

            // gamma correction
            for ( int y = startY; y < stopY; y++ )
            {
                for ( int x = startX; x < stopX; x++, ptr++ )
                {
                    // process each pixel
                    *ptr = table[*ptr];
                }
                ptr += offset;
            }
        }
    }