Here you can find the source of getBrightness(int red, int green, int blue)
public static float getBrightness(int red, int green, int blue)
//package com.java2s; //License from project: Open Source License import java.awt.Color; public class Main { public static final int MAX_RGB_COMPONENT_VALUE = 255; public static float getBrightness(Color colour) { return getBrightness(colour.getRed(), colour.getGreen(), colour.getBlue()); }/*from www. j ava 2 s .co m*/ public static float getBrightness(int rgb) { return getBrightness((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF); } public static float getBrightness(int red, int green, int blue) { double cMax = (red > green) ? red : green; if (cMax < blue) cMax = blue; return ((float) cMax / (float) MAX_RGB_COMPONENT_VALUE); } }