コード例 #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 = this._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);
            }
コード例 #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 (this.Leaves > colorCount)
                {
                    this.Reduce();
                }
                // Now palettize the nodes
                List <Color> palette      = new List <Color>(this.Leaves);
                int          paletteIndex = 0;

                this._root.ConstructPalette(palette, ref paletteIndex);
                // And return the palette
                this._palette     = palette.ToArray();
                this.paletteTable = null;
                return(palette);
            }
コード例 #3
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 (this.Leaves > colorCount) {
         this.Reduce();
     }
     // Now palettize the nodes
     List<Color> palette = new List<Color>(this.Leaves);
     int paletteIndex = 0;
     this._root.ConstructPalette(palette, ref paletteIndex);
     // And return the palette
     this._palette = palette.ToArray();
     this.paletteTable = null;
     return palette;
 }
コード例 #4
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 = this._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;
 }