public int getClosestColor(int c)
    {
        if (c == 0)
            return 0;

        int bestInd = 0;
        float bestDif = Util.colorDiff(pal[0], c);

        for (int i = 0; i < pal.length; i++)
        {
            float d = Util.colorDiff(pal[i], c);
            if (d < bestDif)
            {
                bestDif = d;
                bestInd = i;
            }
        }

        return bestInd;
    }