AForge.Imaging.ComplexImage.FromBitmap C# (CSharp) Method

FromBitmap() public static method

Create complex image from grayscale bitmap.
The source image has incorrect pixel format. Image width and height should be power of 2.
public static FromBitmap ( Bitmap image ) : ComplexImage
image System.Drawing.Bitmap Source grayscale bitmap (8 bpp indexed).
return ComplexImage
        public static ComplexImage FromBitmap( Bitmap image )
        {
            // check image format
            if ( image.PixelFormat != PixelFormat.Format8bppIndexed )
            {
                throw new UnsupportedImageFormatException( "Source image can be graysclae (8bpp indexed) image only." );
            }

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

            ComplexImage complexImage;

            try
            {
                complexImage = FromBitmap( imageData );
            }
            finally
            {
                // unlock source images
                image.UnlockBits( imageData );
            }

            return complexImage;
        }

Same methods

ComplexImage::FromBitmap ( BitmapData imageData ) : ComplexImage