public int GetPaletteIndex(Color32 *pixel, int level) { int pindex = paletteIndex; if (!Leaf) { int shift = 7 - level; int index = ((pixel->Red & mask[level]) >> (shift - 2)) | ((pixel->Green & mask[level]) >> (shift - 1)) | ((pixel->Blue & mask[level]) >> (shift)); OcTreeNode child = Children[index]; if (child != null) { child.GetPaletteIndex(pixel, level + 1); } else { throw new Exception("不可预料的事情发生了!"); } } return(pindex); }
internal int GetPaletteIndex(Color32 *pixel) { return(_rootNode.GetPaletteIndex(pixel, 0)); }