Re: Change Brightness via HSB

From: Liz (Liz_at_nospam.com)
Date: 07/29/04


Date: Thu, 29 Jul 2004 15:43:43 GMT


"Petra Neumann" <66789@web.de> wrote in message
news:1df537e3.0407290050.68505836@posting.google.com...
> 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

How about "public Color brighter()"
in java.awt.Color.java;