Accord.Imaging.ColorReduction.ColorImageQuantizer.ReduceColors C# (CSharp) Method

ReduceColors() public method

Create an image with reduced number of colors using the specified palette.

See ReduceColors(UnmanagedImage, Color[]) for details.

public ReduceColors ( Bitmap image, Color palette ) : Bitmap
image System.Drawing.Bitmap Source image to process.
palette Color Target color palette. Must contatin 2-256 colors.
return System.Drawing.Bitmap
        public Bitmap ReduceColors( Bitmap image, Color[] palette )
        {
            BitmapData data = image.LockBits( new Rectangle( 0, 0, image.Width, image.Height ),
                ImageLockMode.ReadOnly, image.PixelFormat );

            try
            {
                Bitmap result = ReduceColors( new UnmanagedImage( data ), palette );
                if ( ( image.HorizontalResolution > 0 ) && ( image.VerticalResolution > 0 ) )
                {
                    result.SetResolution( image.HorizontalResolution, image.VerticalResolution );
                }
                return result;
            }
            finally
            {
                image.UnlockBits( data );
            }
        }

Same methods

ColorImageQuantizer::ReduceColors ( Bitmap image, int paletteSize ) : Bitmap
ColorImageQuantizer::ReduceColors ( UnmanagedImage image, Color palette ) : Bitmap
ColorImageQuantizer::ReduceColors ( UnmanagedImage image, int paletteSize ) : Bitmap