MapSuiteGisEditor/GisEditorPluginCore/Shares/UIs/Controls/SolidColorPicker/ColorHelper.cs
/// <summary>
/// Converts from HSV to a RGB <see cref="Color"/>
/// </summary>
/// <param name="hue"></param>
/// <param name="saturation"></param>
/// <param name="value"></param>
/// <returns></returns>
Converts from HSV to a RGB
Converts from HSV to a RGB
public static Color HsvToColor(byte alpha, byte hue, byte saturation, byte value)
        {
            double r, g, b;
            double h = hue * 360.0 / 255;
            double s = saturation / 255.0;
            double v = value / 255.0;
            if (s == 0)
            {
                r = v;
                g = v;
                b = v;
            }
            else
            {
                int i;
                double f, p, q, t;
                if (h == 360)
                    h = 0;
                else
                    h = h / 60;
                i = (int)Math.Truncate(h);
                f = h - i;
                p = v * (1.0 - s);
                q = v * (1.0 - (s * f));
                t = v * (1.0 - (s * (1.0 - f)));
                switch (i)
                {
                    case 0:
                        r = v;
                        g = t;
                        b = p;
                        break;
                    case 1:
                        r = q;
                        g = v;
                        b = p;
                        break;
                    case 2:
                        r = p;
                        g = v;
                        b = t;
                        break;
                    case 3:
                        r = p;
                        g = q;
                        b = v;
                        break;
                    case 4:
                        r = t;
                        g = p;
                        b = v;
                        break;
                    default:
                        r = v;
                        g = p;
                        b = q;
                        break;
                }
            }
            return Color.FromArgb(alpha, (byte)(r * 255), (byte)(g * 255), (byte)(b * 255));
        }
public static Color HsvToColor ( byte alpha , byte hue , byte saturation , byte value ) { double r , g , b ; double h = hue * 360.0 / 255 ; double s = saturation / 255.0 ; double v = value / 255.0 ; if ( s == 0 ) { r = v ; g = v ; b = v ; } else { int i ; double f , p , q , t ; if ( h == 360 ) h = 0 ; else h = h / 60 ; i = ( int ) Math . Truncate ( h ) ; f = h - i ; p = v * ( 1.0 - s ) ; q = v * ( 1.0 - ( s * f ) ) ; t = v * ( 1.0 - ( s * ( 1.0 - f ) ) ) ; switch ( i ) { case 0 : r = v ; g = t ; b = p ; break ; case 1 : r = q ; g = v ; b = p ; break ; case 2 : r = p ; g = v ; b = t ; break ; case 3 : r = p ; g = q ; b = v ; break ; case 4 : r = t ; g = p ; b = v ; break ; default : r = v ; g = p ; b = q ; break ; } } return Color . FromArgb ( alpha , ( byte ) ( r * 255 ) , ( byte ) ( g * 255 ) , ( byte ) ( b * 255 ) ) ; }
Converts from HSV to a RGB
Converts from HSV to a RGB
None
alpha
byte
hue
byte
None
saturation
byte
None
value
byte
None