Java tutorial
//package com.java2s; //License from project: Apache License public class Main { /** * Returns the saturation component of a color int. * * @return A value between 0.0f and 1.0f * * @hide Pending API council */ public static float saturation(int color) { int r = (color >> 16) & 0xFF; int g = (color >> 8) & 0xFF; int b = color & 0xFF; int V = Math.max(b, Math.max(r, g)); int temp = Math.min(b, Math.min(r, g)); float S; if (V == temp) { S = 0; } else { S = (V - temp) / (float) V; } return S; } }