void FromRGB(RgbColor cc)
{
double r = (double)cc.R / 255d;
double g = (double)cc.G / 255d;
double b = (double)cc.B / 255d;
double min = Math.Min(Math.Min(r, g), b);
double max = Math.Max(Math.Max(r, g), b);
// calulate hue according formula given in
// "Conversion from RGB to HSL or HSV"
m_hue = 0;
if (min != max)
{
if (r == max && g >= b)
{
m_hue = 60 * ((g - b) / (max - min)) + 0;
}
else
if (r == max && g < b)
{
m_hue = 60 * ((g - b) / (max - min)) + 360;
}
else
if (g == max)
{
m_hue = 60 * ((b - r) / (max - min)) + 120;
}
else
if (b == max)
{
m_hue = 60 * ((r - g) / (max - min)) + 240;
}
}
// find lightness
m_lightness = (min+max)/2;
// find saturation
if (m_lightness == 0 ||min == max)
m_saturation = 0;
else
if (m_lightness > 0 && m_lightness <= 0.5)
m_saturation = (max-min)/(2*m_lightness);
else
if (m_lightness > 0.5)
m_saturation = (max-min)/(2-2*m_lightness);
}
RgbColor ToRGB()