private static void convertRGBtoHSL(final int r, final int g, final int b, final float[] hsl) {
            final float varR = (r / 255f);
            final float varG = (g / 255f);
            final float varB = (b / 255f);

            float varMin;
            float varMax;
            float delMax;

            if (varR > varG) {
                varMin = varG;
                varMax = varR;
            } else {
                varMin = varR;
                varMax = varG;
            }
            if (varB > varMax) {
                varMax = varB;
            }
            if (varB < varMin) {
                varMin = varB;
            }

            delMax = varMax - varMin;

            float hue;
            float saturation;
            float lightness;
            lightness = (varMax + varMin) / 2f;

            if (delMax - 0.01f <= 0.0f) {
                hue = 0;
                saturation = 0;
            } else {
                if (lightness < 0.5f) {
                    saturation = delMax / (varMax + varMin);
                } else {
                    saturation = delMax / (2 - varMax - varMin);
                }

                final float delRed = (((varMax - varR) / 6f) + (delMax / 2f)) / delMax;
                final float delGreen = (((varMax - varG) / 6f) + (delMax / 2f)) / delMax;
                final float delBlue = (((varMax - varB) / 6f) + (delMax / 2f)) / delMax;

                if (MathUtils.floatEquals(varR, varMax)) {
                    hue = delBlue - delGreen;
                } else if (MathUtils.floatEquals(varG, varMax)) {
                    hue = (1 / 3f) + delRed - delBlue;
                } else {
                    hue = (2 / 3f) + delGreen - delRed;
                }
                if (hue < 0) {
                    hue += 1;
                }
                if (hue > 1) {
                    hue -= 1;
                }
            }

            hsl[0] = hue;
            hsl[1] = saturation;
            hsl[2] = lightness;
        }