/// <summary> /// Adds the color. /// </summary> /// <param name="color">The color.</param> /// <param name="paletteIndex">Index of the palette.</param> /// <param name="level">The level.</param> public void AddColor(Color color, Int32 paletteIndex, Int32 level) { // if this node is a leaf, then increase a color amount, and pixel presence entries.Add(paletteIndex, color); if (level < 8) // otherwise goes one level deeper { // calculates an index for the next sub-branch Int32 index = GetColorIndexAtLevel(color, level); // if that branch doesn't exist, grows it if (nodes[index] == null) { nodes[index] = new OctreeCacheNode(); } // adds a color to that branch nodes[index].AddColor(color, paletteIndex, level + 1); } }
/// <summary> /// See <see cref="BaseColorCache.Prepare"/> for more details. /// </summary> public override void Prepare() { base.Prepare(); root = new OctreeCacheNode(); }
/// <summary> /// Initializes a new instance of the <see cref="OctreeColorCache"/> class. /// </summary> public OctreeColorCache() { ColorModel = ColorModel.RedGreenBlue; root = new OctreeCacheNode(); }