Ejemplo n.º 1
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="colorCount"></param>
            /// <returns></returns>
            public List <Color> Palletize(int colorCount)
            {
                while (Leaves > colorCount)
                {
                    Reduce();
                }

                List <Color> palette      = new List <Color>(Leaves);
                int          paletteIndex = 0;

                _root.ConstructPalette(palette, ref paletteIndex);

                this._palette     = palette.ToArray();
                this.paletteTable = null;

                return(palette);
            }
Ejemplo n.º 2
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="pixel"></param>
            /// <returns></returns>
            public int GetPaletteIndex(ColorBgra *pixel)
            {
                int ret = -1;

                ret = _root.GetPaletteIndex(pixel, 0);

                if (ret < 0)
                {
                    if (this.paletteTable == null)
                    {
                        this.paletteTable = new PaletteTable(this._palette);
                    }

                    ret = this.paletteTable.FindClosestPaletteIndex(pixel->ToColor());
                }

                return(ret);
            }