Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5566
  • Last Modified:

Color space conversions HSV/HSB<->RGB


I'm working on color picker control and need to be able to convert between color spaces.  I'm trying to match what Adobe Photoshop does with their color picker.  I've had no problem finding HSV to RGB function on the net, but they do not function the same as Photoshop's HSB values.  The hue and the saturation seem the same, but Photoshop's "B" does not seem to correlate with the HSV's "V".

As an example, the following HSB values in the photoshop color picker produce a nice shade of aqua.

H -> 176 degrees
S -> 78%
B -> 100%

However, if I use those same values in the HSV to RGB functions I'm finding, I get pure white.

I'm looking for code to convert HSB (Photoshop style) over to RGB.  Any language should be fine.  I'll be converting it to JavaScript.
0
phasevar
Asked:
phasevar
  • 2
1 Solution
 
ozoCommented:
0
 
phasevarAuthor Commented:
Yes, that's an example of what I'm trying to accomplish.  I took a look at the source code and found that it uses the java.awt.Color library to do the mathmatical conversion.  That's the one peice of source that I need but can't find.
0
 
BRPXQZMECommented:
Check out the source to http://babu.jp/~useyan/m/hsb_rgb.html
It may be in Japanese, but the source is pretty self-explanatory.  

Doesn't tell you much about the why part unfortunately, but hey, it's the code you want in the computer language you want... I'm not too sure whether you're supposed to convert the degrees (if my interpretation of aqua is the same as yours, then you are), but be sure to convert the percentages to be fractions of 255; you won't be satisfied if you don't.
0
 
phasevarAuthor Commented:
Thanks!  The Japanese site will do wonderfully!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now