Java Utililty Methods HSV Color to HSB

List of utility methods to do HSV Color to HSB

Description

The list of methods to do HSV Color to HSB are organized into topic(s).

Method

int[]hsv2rgb(float h, float s, float v)
hsvrgb
float c = v * s;
float x = c * (1 - Math.abs((h / 60) % 2 - 1));
float m = v - c;
float r1 = 0, g1 = 0, b1 = 0;
if (h < 60) {
    r1 = c;
    g1 = x;
    b1 = 0;
...
voidhsv2rgb(float h, float s, float v, float[] rgb)
hsvrgb
float m, n, f;
int i;
float[] hsv = new float[3];
hsv[0] = h;
hsv[1] = s;
hsv[2] = v;
System.out.println("H: " + h + " S: " + s + " V:" + v);
if (hsv[0] == -1) {
...
Stringhsv2rgb_hex(float h, float s, float v)
hsvrghex
while (h < 0) {
    h += 360;
while (h > 360) {
    h -= 360f;
s = (s <= 0) ? 0f : (s > 100f) ? 100f : s;
v = (v <= 0) ? 0f : (v > 100f) ? 100f : v;
...
doublehsva(double hue, double saturation, double value, double alpha)
hsva
hue = ((hue % 360) / 360) * 360;
int i = (int) Math.floor((hue / 60) % 6);
double f = (hue / 60) - i;
double[] vs = { value, value * (1 - saturation), value * (1 - f * saturation),
        value * (1 - (1 - f) * saturation) };
return rgba(vs[HSVA_PERM[i][0]] * 255, vs[HSVA_PERM[i][1]] * 255, vs[HSVA_PERM[i][2]] * 255, alpha);
intHSVToColor(float[] hsv)
HSV To Color
return HSVToColor(255, hsv);
floathsvToRgb(double hue, double saturation, double value)
Convert a hue, saturation, and value to a float compatible with NIVision.
int h = (int) (hue * 6);
double f = hue * 6 - h;
double p = value * (1 - saturation);
double q = value * (1 - f * saturation);
double t = value * (1 - (1 - f) * saturation);
switch (h) {
case 0:
    return getColor((int) (value * 256.0), (int) (t * 256.0), (int) (p * 256.0));
...
int[]HSVtoRGB(double hue, double saturation, double value)
Method returns three integers representing the RGB values of a HSV input Values in input must be between 0 and 1 Values in output are between 0 and 255.
int R, G, B;
if (saturation == 0) 
    R = new Double(value * 255).intValue();
    G = new Double(value * 255).intValue();
    B = new Double(value * 255).intValue();
} else {
    double var_h = hue * 6;
...
int[]hsvToRgb(double[] hsv)
Converts an HSV color value [0-1] to RGB [0-255].
double r = 0.0;
double g = 0.0;
double b = 0.0;
double i = Math.floor(hsv[0] * 6.0);
double f = hsv[0] * 6.0 - i;
double p = hsv[2] * (1.0 - hsv[1]);
double q = hsv[2] * (1.0 - f * hsv[1]);
double t = hsv[2] * (1.0 - (1 - f) * hsv[1]);
...
float[]HSVtoRGB(float h, float s, float v)
HS Vto RGB
float m, n, f;
int i;
float[] hsv = new float[3];
float[] rgb = new float[3];
hsv[0] = h;
hsv[1] = s;
hsv[2] = v;
if (hsv[0] == -1) {
...
float[]HSVtoRGB(float h, float s, float v, float[] result)
http://www.cs.rit.edu/~ncs/color/t_convert.html
if (result == null) {
    result = new float[3];
float r, g, b;
int i;
float f, p, q, t;
if (s == 0) {
    r = g = b = v;
...