Java Color Brighten getBrightness(Color c)

Here you can find the source of getBrightness(Color c)

Description

Returns a value between 0 and 255 where 0 is darkest and 255 is brightest

License

GNU General Public License

Parameter

Parameter Description
c a parameter

Declaration

public static int getBrightness(Color c) 

Method Source Code


//package com.java2s;
/*//from   ww  w  .j  a v  a 2s . c o m
 *                    BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 *
 * Created on May 20, 2010
 * Author: Andreas Prlic 
 *
 */

import java.awt.Color;

public class Main {
    /**
     * Returns a value between 0 and 255 where 0 is darkest and 255 is brightest
     *
     * @param c
     * @return
     */
    public static int getBrightness(Color c) {
        return (int) Math.sqrt(c.getRed() * c.getRed() * .241 + c.getGreen() * c.getGreen() * .691
                + c.getBlue() * c.getBlue() * .068);
    }
}

Related

  1. changeColorBrightness(final Color color, final double delta)
  2. deriveByBrightness(Color original, Color brightnessSource)
  3. deriveColorHSB(Color base, float hue, float saturation, float brightness)
  4. getBrightness(Color c)
  5. getBrightness(Color c)
  6. getBrightness(Color color)
  7. getBrightness(Color color)
  8. getBrightness(Color color)
  9. getBrightness(int red, int green, int blue)