Beispiel #1
0
        public int getClosestColor(Color c, Color[] pal)
        {
            int   bestInd = 0;
            float bestDif = ImageIndexer.colorDifferenceWithoutAlpha(pal[0], c);

            for (int i = 0; i < pal.Length; i++)
            {
                float d = ImageIndexer.colorDifferenceWithoutAlpha(pal[i], c);
                if (d < bestDif)
                {
                    bestDif = d;
                    bestInd = i;
                }
            }

            return(bestInd);
        }
        static private int getClosestColor(Color[] pal, Color c)
        {
            if (c.A == 0)
            {
                return(0);
            }

            int   bestInd = 1;
            float bestDif = ImageIndexer.colorDifferenceWithoutAlpha(pal[1], c);

            for (int i = 1; i < pal.Length; i++)
            {
                float d = ImageIndexer.colorDifferenceWithoutAlpha(pal[i], c);
                if (d < bestDif)
                {
                    bestDif = d;
                    bestInd = i;
                }
            }

            return(bestInd);
        }