Esempio n. 1
0
            private void ReduceNode(TreeViewImageGenerator.OctreeNode node, int depth)
            {
                ArrayList list = null;

                if (depth < (this._numBits - 2))
                {
                    list = this._levels[depth + 1];
                }
                for (int i = 0; i < 8; i++)
                {
                    TreeViewImageGenerator.OctreeNode node2 = node[i];
                    if (node2 != null)
                    {
                        if (depth < (this._numBits - 2))
                        {
                            this.ReduceNode(node2, depth + 1);
                        }
                        if (list != null)
                        {
                            list.Remove(node2);
                        }
                        if (node2.NodeCount == 0)
                        {
                            this._leafNodes.Remove(node2);
                        }
                        node[i] = null;
                    }
                    this._levels[depth].Remove(node);
                    node.Reduced = true;
                }
            }
Esempio n. 2
0
 public void AddColor(Color c)
 {
     if ((!this._hasTransparency || (this._transparentColor.R != c.R)) || ((this._transparentColor.G != c.G) || (this._transparentColor.B != c.B)))
     {
         int depth = -1;
         if (this._leafNodes.Count >= this._maxColors)
         {
             TreeViewImageGenerator.OctreeNode node = null;
             for (int i = this._numBits - 2; i > 0; i--)
             {
                 ArrayList list = this._levels[i];
                 if (list.Count > 0)
                 {
                     depth = i;
                     int pixelCount = -1;
                     for (int j = 0; j < list.Count; j++)
                     {
                         TreeViewImageGenerator.OctreeNode node2 = (TreeViewImageGenerator.OctreeNode)list[j];
                         if (node2.PixelCount > pixelCount)
                         {
                             node       = node2;
                             pixelCount = node2.PixelCount;
                         }
                     }
                     break;
                 }
             }
             this.ReduceNode(node, depth);
             this._leafNodes.Add(node);
         }
         TreeViewImageGenerator.OctreeNode node3 = this._root;
         depth = 0;
         bool flag = false;
         while (depth < (this._numBits - 1))
         {
             int index = this.GetIndex(c, depth);
             TreeViewImageGenerator.OctreeNode node4 = node3[index];
             if (node4 == null)
             {
                 node4        = new TreeViewImageGenerator.OctreeNode();
                 node3[index] = node4;
                 flag         = true;
                 if (node3.NodeCount == 2)
                 {
                     this._levels[depth].Add(node3);
                 }
             }
             node3 = node4;
             node3.AddColor(c);
             if (node3.Reduced)
             {
                 break;
             }
             depth++;
         }
         if (flag)
         {
             this._leafNodes.Add(node3);
         }
     }
 }
 public void AddColor(Color c)
 {
     if ((!this._hasTransparency || (this._transparentColor.R != c.R)) || ((this._transparentColor.G != c.G) || (this._transparentColor.B != c.B)))
     {
         int depth = -1;
         if (this._leafNodes.Count >= this._maxColors)
         {
             TreeViewImageGenerator.OctreeNode node = null;
             for (int i = this._numBits - 2; i > 0; i--)
             {
                 ArrayList list = this._levels[i];
                 if (list.Count > 0)
                 {
                     depth = i;
                     int pixelCount = -1;
                     for (int j = 0; j < list.Count; j++)
                     {
                         TreeViewImageGenerator.OctreeNode node2 = (TreeViewImageGenerator.OctreeNode) list[j];
                         if (node2.PixelCount > pixelCount)
                         {
                             node = node2;
                             pixelCount = node2.PixelCount;
                         }
                     }
                     break;
                 }
             }
             this.ReduceNode(node, depth);
             this._leafNodes.Add(node);
         }
         TreeViewImageGenerator.OctreeNode node3 = this._root;
         depth = 0;
         bool flag = false;
         while (depth < (this._numBits - 1))
         {
             int index = this.GetIndex(c, depth);
             TreeViewImageGenerator.OctreeNode node4 = node3[index];
             if (node4 == null)
             {
                 node4 = new TreeViewImageGenerator.OctreeNode();
                 node3[index] = node4;
                 flag = true;
                 if (node3.NodeCount == 2)
                 {
                     this._levels[depth].Add(node3);
                 }
             }
             node3 = node4;
             node3.AddColor(c);
             if (node3.Reduced)
             {
                 break;
             }
             depth++;
         }
         if (flag)
         {
             this._leafNodes.Add(node3);
         }
     }
 }