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

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

Process the filter on the specified image.
protected ProcessFilter ( UnmanagedImage sourceData, UnmanagedImage destinationData ) : void
sourceData UnmanagedImage Source image data.
destinationData UnmanagedImage Destination image data.
Результат void
        protected override unsafe void ProcessFilter( UnmanagedImage sourceData, UnmanagedImage destinationData )
        {
            // get source image size
            int width   = sourceData.Width;
            int height  = sourceData.Height;

            int pixelSize = Image.GetPixelFormatSize( sourceData.PixelFormat ) / 8;
            int srcStride = sourceData.Stride;
            int dstStride = destinationData.Stride;
            double xFactor = (double) width / newWidth;
            double yFactor = (double) height / newHeight;

            // do the job
            byte* baseSrc = (byte*) sourceData.ImageData.ToPointer( );
            byte* baseDst = (byte*) destinationData.ImageData.ToPointer( );

            // for each line
            for ( int y = 0; y < newHeight; y++ )
            {
                byte* dst = baseDst + dstStride * y;
                byte* src = baseSrc + srcStride * ( (int) ( y * yFactor ) );
                byte* p;

                // for each pixel
                for ( int x = 0; x < newWidth; x++ )
                {
                    p = src + pixelSize * ( (int) ( x * xFactor ) );

                    for ( int i = 0; i < pixelSize; i++, dst++, p++ )
                    {
                        *dst = *p;
                    }
                }
            }
        }
    }