public Bitmap Apply( Bitmap image )
{
// lock source bitmap data
BitmapData srcData = image.LockBits(
new Rectangle( 0, 0, image.Width, image.Height ),
ImageLockMode.ReadOnly, image.PixelFormat );
Bitmap dstImage = null;
try
{
// apply the filter
dstImage = Apply( srcData );
if ( ( image.HorizontalResolution > 0 ) && ( image.VerticalResolution > 0 ) )
{
dstImage.SetResolution( image.HorizontalResolution, image.VerticalResolution );
}
}
finally
{
// unlock source image
image.UnlockBits( srcData );
}
return dstImage;
}