Accord.Imaging.Filters.Crop.ProcessFilter C# (CSharp) Méthode

ProcessFilter() protected méthode

Process the filter on the specified image.
protected ProcessFilter ( UnmanagedImage sourceData, UnmanagedImage destinationData ) : void
sourceData UnmanagedImage Source image data.
destinationData UnmanagedImage Destination image data.
Résultat void
        protected override unsafe void ProcessFilter( UnmanagedImage sourceData, UnmanagedImage destinationData )
        {
            // validate rectangle
            Rectangle srcRect = rect;
            srcRect.Intersect( new Rectangle( 0, 0, sourceData.Width, sourceData.Height ) );

            int xmin = srcRect.Left;
            int ymin = srcRect.Top;
            int ymax = srcRect.Bottom - 1;
            int copyWidth = srcRect.Width;

            int srcStride = sourceData.Stride;
            int dstStride = destinationData.Stride;
            int pixelSize = Image.GetPixelFormatSize( sourceData.PixelFormat ) / 8;
            int copySize  = copyWidth * pixelSize;

            // do the job
            byte* src = (byte*) sourceData.ImageData.ToPointer( ) + ymin * srcStride + xmin * pixelSize;
            byte* dst = (byte*) destinationData.ImageData.ToPointer( );

            if ( rect.Top < 0 )
            {
                dst -= dstStride * rect.Top;
            }
            if ( rect.Left < 0 )
            {
                dst -= pixelSize * rect.Left;
            }

            // for each line
            for ( int y = ymin; y <= ymax; y++ )
            {
                Accord.SystemTools.CopyUnmanagedMemory(dst, src, copySize);
                src += srcStride;
                dst += dstStride;
            }
        }
    }