Solved

Color space conversions HSV/HSB<->RGB

Posted on 2004-04-17
4
5,525 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wefewf 2 43
VBA color chart bars 12 65
listing all functions in JavaScript 19 101
Device same like our heart 12 45
A short article about a problem I had getting the GPS LocationListener working.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now