Java examples for 2D Graphics:Color RGB
Gets the intensity of a given rgb 0xFF is to get the last bit blue value
//package com.java2s; public class Main { /**//from www .j a v a2 s . c o m * Gets the intensity of a given rgb * 0xFF is to get the last bit blue value * @param rgb * @return intensity in [0, 255] */ public static int getColorIntensity(int rgb) { int r = (rgb >> 16) & 0xFF; int g = (rgb >> 8) & 0xFF; int b = rgb & 0xFF; return (r * 7471 + g * 38470 + b * 19595) >> 16; } }