protected override unsafe void ProcessFilter( UnmanagedImage image )
{
if ( destinationQuadrilateral == null )
throw new NullReferenceException( "Destination quadrilateral was not set." );
// check overlay type
if ( sourceImage != null )
{
// source and destination images must have same pixel format
if ( image.PixelFormat != sourceImage.PixelFormat )
throw new InvalidImagePropertiesException( "Source and destination images must have same pixel format." );
// lock source image
BitmapData srcData = sourceImage.LockBits(
new Rectangle( 0, 0, sourceImage.Width, sourceImage.Height ),
ImageLockMode.ReadOnly, sourceImage.PixelFormat );
try
{
ProcessFilter( image, new UnmanagedImage( srcData ) );
}
finally
{
// unlock source image
sourceImage.UnlockBits( srcData );
}
}
else if ( sourceUnmanagedImage != null )
{
// source and destination images must have same pixel format
if ( image.PixelFormat != sourceUnmanagedImage.PixelFormat )
throw new InvalidImagePropertiesException( "Source and destination images must have same pixel format." );
ProcessFilter( image, sourceUnmanagedImage );
}
else
{
throw new NullReferenceException( "Source image is not set." );
}
}