Change Brightness via HSB
From: Petra Neumann (pneumann_at_cs.uni-magdeburg.de)
Date: 07/29/04
- Next message: Thomas Weidenfeller: "Re: Displaying Japanese character in applet problem"
- Previous message: Thomas Weidenfeller: "Re: How to write a java program which will work in background"
- Next in thread: Thomas Weidenfeller: "Re: Change Brightness via HSB"
- Reply: Thomas Weidenfeller: "Re: Change Brightness via HSB"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Thomas Weidenfeller: "Re: Displaying Japanese character in applet problem"
- Previous message: Thomas Weidenfeller: "Re: How to write a java program which will work in background"
- Next in thread: Thomas Weidenfeller: "Re: Change Brightness via HSB"
- Reply: Thomas Weidenfeller: "Re: Change Brightness via HSB"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|