Exemplo n.º 1
0
            /// <summary>
            /// Get the palette index for the passed color
            /// </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);
            }
Exemplo n.º 2
0
            /// <summary>
            /// Convert the nodes in the octree to a palette with a maximum of colorCount colors
            /// </summary>
            /// <param name="colorCount">The maximum number of colors</param>
            /// <returns>A list with the palettized colors</returns>
            public List <Color> Palletize(int colorCount)
            {
                while (Leaves > colorCount)
                {
                    Reduce();
                }

                // Now palettize the nodes
                List <Color> palette      = new List <Color>(Leaves);
                int          paletteIndex = 0;

                _root.ConstructPalette(palette, ref paletteIndex);

                // And return the palette
                this._palette     = palette.ToArray();
                this.paletteTable = null;

                return(palette);
            }