public List<IntPoint> ProcessImage( Bitmap image )
{
// check image format
if (
( image.PixelFormat != PixelFormat.Format8bppIndexed ) &&
( image.PixelFormat != PixelFormat.Format24bppRgb ) &&
( image.PixelFormat != PixelFormat.Format32bppRgb ) &&
( image.PixelFormat != PixelFormat.Format32bppArgb )
)
{
throw new UnsupportedImageFormatException( "Unsupported pixel format of the source image." );
}
// lock source image
BitmapData imageData = image.LockBits(
new Rectangle( 0, 0, image.Width, image.Height ),
ImageLockMode.ReadOnly, image.PixelFormat );
List<IntPoint> corners;
try
{
// process the image
corners = ProcessImage( new UnmanagedImage( imageData ) );
}
finally
{
// unlock image
image.UnlockBits( imageData );
}
return corners;
}