AForge.Imaging.HorizontalIntensityStatistics.HorizontalIntensityStatistics C# (CSharp) Method

HorizontalIntensityStatistics() public method

Initializes a new instance of the HorizontalIntensityStatistics class.
Unsupported pixel format of the source image.
public HorizontalIntensityStatistics ( Bitmap image ) : System
image System.Drawing.Bitmap Source image.
return System
        public HorizontalIntensityStatistics( Bitmap image )
        {
            // check image format
            if (
                ( image.PixelFormat != PixelFormat.Format8bppIndexed ) &&
                ( image.PixelFormat != PixelFormat.Format16bppGrayScale ) &&
                ( image.PixelFormat != PixelFormat.Format24bppRgb ) &&
                ( image.PixelFormat != PixelFormat.Format32bppRgb ) &&
                ( image.PixelFormat != PixelFormat.Format32bppArgb ) &&
                ( image.PixelFormat != PixelFormat.Format48bppRgb ) &&
                ( image.PixelFormat != PixelFormat.Format64bppArgb )
                )
            {
                throw new UnsupportedImageFormatException( "Unsupported pixel format of the source image." );
            }

            // lock bitmap data
            BitmapData imageData = image.LockBits(
                new Rectangle( 0, 0, image.Width, image.Height ),
                ImageLockMode.ReadOnly, image.PixelFormat );

            try
            {
                // gather statistics
                ProcessImage( new UnmanagedImage( imageData ) );
            }
            finally
            {
                // unlock image
                image.UnlockBits( imageData );
            }
        }

Same methods

HorizontalIntensityStatistics::HorizontalIntensityStatistics ( BitmapData imageData ) : System
HorizontalIntensityStatistics::HorizontalIntensityStatistics ( UnmanagedImage image ) : System