MapSuiteGisEditor/GisEditorPluginCore/Shares/UIs/Controls/Utils/ColorConverter.cs
/// <summary>
/// Convert from HSL to RGB color space.
/// </summary>
/// 
/// <param name="hsl">Source color in <b>HSL</b> color space.</param>
/// <param name="rgb">Destination color in <b>RGB</b> color space.</param>
/// 
Convert from HSL to RGB color space.
Convert from HSL to RGB color space .
public static void HSL2RGB(HSL hsl, RGB rgb)
        {
            if (hsl.Saturation == 0)
            {
                rgb.Red = rgb.Green = rgb.Blue = (byte)(hsl.Luminance * 255);
            }
            else
            {
                double v1, v2;
                double hue = (double)hsl.Hue / 360;
                v2 = (hsl.Luminance < 0.5) ?
                    (hsl.Luminance * (1 + hsl.Saturation)) :
                    ((hsl.Luminance + hsl.Saturation) - (hsl.Luminance * hsl.Saturation));
                v1 = 2 * hsl.Luminance - v2;
                rgb.Red = (byte)(255 * Hue_2_RGB(v1, v2, hue + (1.0 / 3)));
                rgb.Green = (byte)(255 * Hue_2_RGB(v1, v2, hue));
                rgb.Blue = (byte)(255 * Hue_2_RGB(v1, v2, hue - (1.0 / 3)));
            }
        }
public static void HSL2RGB ( HSL hsl , RGB rgb ) { if ( hsl . Saturation == 0 ) { rgb . Red = rgb . Green = rgb . Blue = ( byte ) ( hsl . Luminance * 255 ) ; } else { double v1 , v2 ; double hue = ( double ) hsl . Hue / 360 ; v2 = ( hsl . Luminance < 0.5 ) ? ( hsl . Luminance * ( 1 + hsl . Saturation ) ) : ( ( hsl . Luminance + hsl . Saturation ) - ( hsl . Luminance * hsl . Saturation ) ) ; v1 = 2 * hsl . Luminance - v2 ; rgb . Red = ( byte ) ( 255 * Hue_2_RGB ( v1 , v2 , hue + ( 1.0 / 3 ) ) ) ; rgb . Green = ( byte ) ( 255 * Hue_2_RGB ( v1 , v2 , hue ) ) ; rgb . Blue = ( byte ) ( 255 * Hue_2_RGB ( v1 , v2 , hue - ( 1.0 / 3 ) ) ) ; } }
Convert from HSL to RGB color space.
Convert from HSL to RGB color space .
// gray values
hsl
HSL
Source color in HSL
Source color in HSL
rgb
RGB
Destination color in RGB
Destination color in RGB