AForge.Imaging.Filters.BaseFilter.Apply C# (CSharp) Method

Apply() public method

Apply filter to an image in unmanaged memory.

The method keeps the source image unchanged and puts result of image processing into destination image.

The destination image must have the same width and height as source image. Also destination image must have pixel format, which is expected by particular filter (see FormatTranslations property for information about pixel format conversions).

Unsupported pixel format of the source image. Incorrect destination pixel format. Destination image has wrong width and/or height.
public Apply ( UnmanagedImage sourceImage, UnmanagedImage destinationImage ) : void
sourceImage UnmanagedImage Source image in unmanaged memory to apply filter to.
destinationImage UnmanagedImage Destination image in unmanaged memory to put result into.
return void
        public void Apply( UnmanagedImage sourceImage, UnmanagedImage destinationImage )
        {
            // check pixel format of the source and destination images
            CheckSourceFormat( sourceImage.PixelFormat );

            // ensure destination image has correct format
            if ( destinationImage.PixelFormat != FormatTranslations[sourceImage.PixelFormat] )
            {
                throw new InvalidImagePropertiesException( "Destination pixel format is specified incorrectly." );
            }

            // ensure destination image has correct size
            if ( ( destinationImage.Width != sourceImage.Width ) || ( destinationImage.Height != sourceImage.Height ) )
            {
                throw new InvalidImagePropertiesException( "Destination image must have the same width and height as source image." );
            }

            // process the filter
            ProcessFilter( sourceImage, destinationImage );
        }

Same methods

BaseFilter::Apply ( Bitmap image ) : Bitmap
BaseFilter::Apply ( BitmapData imageData ) : Bitmap
BaseFilter::Apply ( UnmanagedImage image ) : UnmanagedImage