1
Vote

ColorSpace.ConvertRgbToHsv

description

ConvertRgbToHsv(Color c) returns an HSV with the H component == NaN if all R,G, and B components are equal (eg. gray color). Here's how the implementation should look like, I guess:
 
double h = max == min ? 0
: max == r && g >= b ? 60 * (g - b) / (max - min)
: max == r && g < b ? 60 * (g - b) / (max - min) + 360
: max == g ? 60 * (b - r) / (max - min) + 120
: max == b ? 60 * (r - g) / (max - min) + 240 : 0;

comments