Here you can find the source of rgb2hsl(int[] rgb)
static int[] rgb2hsl(int[] rgb)
//package com.java2s; //License from project: Apache License public class Main { static int[] rgb2hsl(int[] rgb) { double max = Math.max(Math.max(rgb[0], rgb[1]), rgb[2]); // 0xdd = 221 double delta = max - Math.min(Math.min(rgb[0], rgb[1]), rgb[2]); // 153 double h = 0; int s = 0; int l = (int) Math.round(max * 100d / 255d); // 87 ok if (max != 0) { s = (int) Math.round(delta * 100d / max); // 69 ok if (max == rgb[0]) { h = (rgb[1] - rgb[2]) / delta; } else if (max == rgb[1]) { h = (rgb[2] - rgb[0]) / delta + 2d; } else { h = (rgb[0] - rgb[1]) / delta + 4d; // 4.8888888888 }//from w ww. ja v a 2 s . c om h = Math.min(Math.round(h * 60d), 360d); // 293 if (h < 0d) { h += 360d; } } return new int[] { (int) Math.round(h), Math.round(s), l }; } }