コード例 #1
0
            public Node(int level, OctreeQuantizer parent)
            {
                nodes = new Node[8];

                if (level < 7)
                {
                    parent.AddLevelNode(level, this);
                }
            }
コード例 #2
0
            /// <summary>
            /// Removes the leaves by summing all it's color components and pixel presence.
            /// </summary>
            /// <returns></returns>
            public int RemoveLeaves(int level, int activeColorCount, int targetColorCount, OctreeQuantizer parent)
            {
                int result = 0;

                // scans thru all the active nodes
                for (int index = 0; index < 8; index++)
                {
                    Node node = nodes[index];

                    if (node != null)
                    {
                        // sums up their color components
                        red   += node.red;
                        green += node.green;
                        blue  += node.blue;

                        // and pixel presence
                        pixelCount += node.pixelCount;

                        // increases the count of reduced nodes
                        result++;
                    }
                }

                // returns a number of reduced sub-nodes, minus one because this node becomes a leaf
                return(result - 1);
            }