/// <summary> /// Get the palette index for the passed color /// </summary> public int GetPaletteIndex(int pixel) { var ret = _root.GetPaletteIndex(pixel, 0); if (ret < 0) { if (_paletteTable == null) { _paletteTable = new PaletteTable(_palette); } ret = _paletteTable.FindClosestPaletteIndex(Color.FromArgb(pixel)); } return(ret); }
/// <summary> /// Get the palette index for the passed color /// </summary> /// <param name="pixel"></param> /// <returns></returns> public int GetPaletteIndex(int 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(Color.FromArgb(pixel)); } return(ret); }
/// <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 (_leafCount > colorCount) { Reduce(); } // Now palletize the nodes var palette = new List <Color>(_leafCount); int paletteIndex = 0; _root.ConstructPalette(palette, ref paletteIndex); // And return the palette _palette = palette.ToArray(); _paletteTable = null; return(palette); }
/// <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); }
/// <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; }
/// <summary> /// Get the palette index for the passed color /// </summary> /// <param name="pixel"></param> /// <returns></returns> public int GetPaletteIndex(int 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(Color.FromArgb(pixel)); } return ret; }