AForge.Imaging.ColorReduction.MedianCutQuantizer.GetPalette C# (CSharp) Method

GetPalette() public method

Get paletter of the specified size.

The method must be called after continuously calling AddColor method and returns reduced color palette for colors accumulated/processed so far.

public GetPalette ( int colorCount ) : Color[]
colorCount int Palette size to get.
return Color[]
        public Color[] GetPalette( int colorCount )
        {
            List<MedianCutCube> cubes = new List<MedianCutCube>( );
            cubes.Add( new MedianCutCube( colors ) );

            // split the cube until we get required amount of colors
            SplitCubes( cubes, colorCount );

            // get the final palette
            Color[] palette = new Color[colorCount];

            for ( int i = 0; i < colorCount; i++ )
            {
                palette[i] = cubes[i].Color;
            }

            return palette;
        }