Change Brightness via HSB

From: Petra Neumann (pneumann_at_cs.uni-magdeburg.de)
Date: 07/29/04


Date: Thu, 29 Jul 2004 10:54:53 +0200

Hi,

I would like to change the brightness of a Color object in Java. To do
so I change the Color to the HSB color space, increase the brightness
and convert it back to RGB. However, the output color is NOT brighter,
it seems rather strange.

I have written the following code to do the conversion:

/////////////////
Color c = color.get(); (conversion from a Color3f - Java3D color)
System.out.println(c);

float[] hsb = Color.RGBtoHSB(c.getRed(),c.getGreen(),c.getBlue(),null);
hsb[2]=0.8f;

System.out.println(hsb[0]+" "+hsb[1]+" "+hsb[2]);

Color rgb = Color.getHSBColor(hsb[0],hsb[1],hsb[2]);
System.out.println(rgb);
/////////////////

This is an example output:
-----------------------------
java.awt.Color[r=95,g=28,b=0]
0.04912281 1.0 0.8
java.awt.Color[r=204,g=60,b=0]
------------------------------

The strange thing is that the "b" value always remains zero, but
shouldn't be because the original color should mereley becomes
brighter with a color close to white.

I appreciate any suggestions to solve my problem.
Thank you,

Cheers,
Petra



Relevant Pages

  • Re: Change Brightness via HSB
    ... I changed the "value or brightness" slider and the effect on the ... >> so I change the Color to the HSB color space, ... However, the output color is NOT brighter, ... You are assuming properties of the transformation ...
    (comp.lang.java.gui)
  • Re: Change Brightness via HSB
    ... > I would like to change the brightness of a Color object in Java. ... However, the output color is NOT brighter, ... You are assuming properties of the transformation ... due to the fact that you end up with a saturation of 1.0 (100% ...
    (comp.lang.java.gui)