AForge.Imaging.ColorReduction.ErrorDiffusionColorDithering.Apply C# (CSharp) Method

Apply() public method

Perform color dithering for the specified image.
Unsupported pixel format of the source image. It must 24 or 32 bpp color image.
public Apply ( Bitmap sourceImage ) : Bitmap
sourceImage System.Drawing.Bitmap Source image to do color dithering for.
return System.Drawing.Bitmap
        public Bitmap Apply( Bitmap sourceImage )
        {
            BitmapData data = sourceImage.LockBits( new Rectangle( 0, 0, sourceImage.Width, sourceImage.Height ),
                ImageLockMode.ReadOnly, sourceImage.PixelFormat );

            Bitmap result = null;

            try
            {
                result = Apply( new UnmanagedImage( data ) );
                if ( ( sourceImage.HorizontalResolution > 0 ) && ( sourceImage.VerticalResolution > 0 ) )
                {
                    result.SetResolution( sourceImage.HorizontalResolution, sourceImage.VerticalResolution );
                }
            }
            finally
            {
                sourceImage.UnlockBits( data );
            }

            return result;
        }

Same methods

ErrorDiffusionColorDithering::Apply ( UnmanagedImage sourceImage ) : Bitmap