Solved

Color space conversions HSV/HSB<->RGB

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Image decoding from Camera 3 95
Plain Text Editor for iPad 6 95
ejb example issues 3 19
VB.NET String Settings and Temp Folder Question 3 51
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

790 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