Get saturation from color - Android Graphics

Android examples for Graphics:Color

Description

Get saturation from color

Demo Code


//package com.java2s;
import android.graphics.Color;

public class Main {
    /**/*from w ww .  jav  a  2 s .  com*/
     * Get saturation from color
     * @param color color
     * @return color saturation value, 0..1
     */
    public static float getSaturationFromColor(int color) {
        return getHSVFromColor(color)[1];
    }

    /**
     * Get HSV array from color
     * @param color color
     * @return HSV array, length = 3
     */
    public static float[] getHSVFromColor(int color) {
        float hsv[] = new float[3];
        Color.colorToHSV(color, hsv);
        return hsv;
    }
}

Related Tutorials