Get the brightness of a color. - Java 2D Graphics

Java examples for 2D Graphics:Color Light

Description

Get the brightness of a color.

Demo Code


//package com.java2s;
import java.awt.*;

public class Main {
    /** Get the brightness of a color. 
     *    The H from HSB!//from  www .  j av  a 2  s  . com
     */
    public static float getBrightness(Color color) {
        float[] hsbvals;

        hsbvals = new float[3];
        Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(),
                hsbvals);

        return hsbvals[2];
    }
}

Related Tutorials