Java examples for 2D Graphics:Color RGB
Converting Between RGB and HSB Colors
import java.awt.Color; public class Main { public void paint() { // Specify 3 RGB values int red = 0x33; int green = 0x66; int blue = 0x99; // Convert RGB to HSB float[] hsb = Color.RGBtoHSB(red, green, blue, null); float hue = hsb[0]; float saturation = hsb[1]; float brightness = hsb[2]; // .6 // Convert HSB to RGB value int rgb = Color.HSBtoRGB(hue, saturation, brightness); red = (rgb >> 16) & 0xFF;/*from w w w . jav a 2 s. co m*/ green = (rgb >> 8) & 0xFF; blue = rgb & 0xFF; } }