0

I know that the direct conversion from RGB to HSV/HSB is difficult. But the values I get are far away from my expectation.

compare to http://www.rapidtables.com/convert/color/hsv-to-rgb.htm and http://www.rapidtables.com/convert/color/rgb-to-hsv.htm

var color = Color.FromArgb(255, 128, 128) // #FF8080
var hue = color.GetHue(); 
var saturation = color.GetSaturation(); 
var brightness = color.GetBrightness(); 

// Expected:
~ 0
~ 0.5
~ 1

// Actual:
~ 0
~ 1
~ 0.75

What am I doing wrong?

Titanium
  • 83
  • 1
  • 4
  • 1
    Possible duplicate of [Does the .Net Color struct use an HSB or HSL colour space?](http://stackoverflow.com/questions/24732836/does-the-net-color-struct-use-an-hsb-or-hsl-colour-space) – Andrew Morton Apr 15 '16 at 12:59
  • 1
    I marked this as a duplicate because the answer is the same, even though the question is a little different. You are doing nothing wrong: the framework method name "GetBrightness" and the documentation are wrong. – Andrew Morton Apr 15 '16 at 13:01
  • I see, GetBrightness() actual gives me Lightness from the HSL color space. – Titanium Apr 15 '16 at 13:06
  • Yes, and `GetSaturation` gets the saturation from the HSL colour space, which is different in value from the saturation in HSB colour space. – Andrew Morton Apr 15 '16 at 13:26

0 Answers0