Solved

Color space conversions HSV/HSB<->RGB

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
changeXy challenge 13 68
pairs challenge 5 66
How  do I get an older program to run in Windows 10? 20 104
oracle query help 18 99
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

862 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

23 Experts available now in Live!

Get 1:1 Help Now