Convert RGB To HSB Color - Java 2D Graphics

Java examples for 2D Graphics:Color RGB

Description

Convert RGB To HSB Color

Demo Code


import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
 
public class Main {
 
        public void paint(Graphics g){
                float[] hsbValues = new float[3];
               /*from   w  ww  . ja  va  2s  . co  m*/
                hsbValues = Color.RGBtoHSB(255,10,10,hsbValues);
               
                float hue, saturation, brightness;
                hue = hsbValues[0];
                saturation = hsbValues[1];
                brightness = hsbValues[2];
               
                g.drawString("Hue: " + hue + ", Saturation:" + saturation + ", Brightness:" + brightness,10,50);
        }
}

Related Tutorials