Here you can find the source of brightness(int rgb)
public static int brightness(int rgb)
//package com.java2s; public class Main { public static int brightness(int rgb) { int r = (rgb >> 16) & 0xff; int g = (rgb >> 8) & 0xff; int b = rgb & 0xff; return (r + g + b) / 3; }//w ww .j a va 2s. c om }