8

Possible Duplicate:
Algorithm to convert RGB to HSV and HSV to RGB?

I'm trying to find an algorithm (prefferabley represented in C++) that converts from RGBto HSB values so that I can process it accordingly. Anyone got any suggestions?

Community
  • 1
  • 1
user965369
  • 5,413
  • 13
  • 33
  • 47
  • LMGTFY: http://stackoverflow.com/questions/3018313/algorithm-to-convert-rgb-to-hsv-and-hsv-to-rgb and http://stackoverflow.com/questions/8215901/why-does-the-hsv-to-rgb-algorithm-work-the-way-it-does – alf Nov 22 '11 at 13:48

2 Answers2

7

It's java and not C++ but it should be close enough to be easily reusable. Look for the RGBtoHSB method in this page:

http://www.docjar.com/html/api/java/awt/Color.java.html

solendil
  • 8,432
  • 4
  • 28
  • 29
2

There's a number of colour algorithms demonstrated here, including the one you require which would be worth reading.

Michael Berry
  • 70,193
  • 21
  • 157
  • 216