get Color Brightness - Java 2D Graphics

Java examples for 2D Graphics:Color Light

Description

get Color Brightness

Demo Code


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

public class Main {
    public static double getBrightness(Color c) {
        return Math.sqrt(getNorm(c));
    }/*from   w  w  w .j a  v a2  s  . c om*/

    public static double getNorm(Color c) {
        return (c.getRed() * c.getRed() + c.getGreen() * c.getGreen() + c
                .getBlue() * c.getBlue());
    }
}

Related Tutorials