public ImageStatisticsYCbCr( Bitmap image, Bitmap mask )
{
CheckSourceFormat( image.PixelFormat );
CheckMaskProperties( mask.PixelFormat, new Size( mask.Width, mask.Height ), new Size( image.Width, image.Height ) );
// lock bitmap and mask data
BitmapData imageData = image.LockBits(
new Rectangle( 0, 0, image.Width, image.Height ),
ImageLockMode.ReadOnly, image.PixelFormat );
BitmapData maskData = mask.LockBits(
new Rectangle( 0, 0, mask.Width, mask.Height ),
ImageLockMode.ReadOnly, mask.PixelFormat );
try
{
// gather statistics
unsafe
{
ProcessImage( new UnmanagedImage( imageData ), (byte*) maskData.Scan0.ToPointer( ), maskData.Stride );
}
}
finally
{
// unlock images
image.UnlockBits( imageData );
mask.UnlockBits( maskData );
}
}