Solved

Color space conversions HSV/HSB<->RGB

Posted on 2004-04-17
4
5,545 Views
Last Modified: 2012-05-04

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
Comment
Question by:phasevar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 10850981
0
 

Author Comment

by:phasevar
ID: 10851136
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
 
LVL 1

Accepted Solution

by:
BRPXQZME earned 500 total points
ID: 10851242
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
 

Author Comment

by:phasevar
ID: 10851323
Thanks!  The Japanese site will do wonderfully!
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question