Convert HSB to RGB value in Java

Description

The following code shows how to convert HSB to RGB value.

Example


    /* ww  w .ja  va 2  s  .  co  m*/



import java.awt.Color;

public class Main {
  public static void main() {

    float hue = 12; 
    float saturation = 13;
    float brightness = 14;
    
    int rgb = Color.HSBtoRGB(hue, saturation, brightness);
    int red = (rgb >> 16) & 0xFF;
    int green = (rgb >> 8) & 0xFF;
    int blue = rgb & 0xFF;
    
    System.out.println(red);
    System.out.println(green);
    System.out.println(blue);

  }
}




















Home »
  Java Tutorial »
    Graphics »




Animation
BufferedImage
Color
Font
Gradient
Graphics Settings
Image
Mouse Draw
Print
Shape
Text
Transform