Beispiel #1
0
        public static Color HSVtoColor(HSV hsv)
        {
            RGB rGB = ColorHandler.HSVtoRGB(hsv);

            return(Color.FromArgb(rGB.Red, rGB.Green, rGB.Blue));
        }
Beispiel #2
0
        public static RGB HSVtoRGB(HSV HSV)
        {
            double num  = 0.0;
            double num2 = 0.0;
            double num3 = 0.0;
            double num4 = (double)HSV.Hue / 255.0 * 360.0 % 360.0;
            double num5 = (double)HSV.Saturation / 255.0;
            double num6 = (double)HSV.value / 255.0;

            if (num5 == 0.0)
            {
                num  = num6;
                num2 = num6;
                num3 = num6;
            }
            else
            {
                double num7  = num4 / 60.0;
                int    num8  = (int)Math.Floor(num7);
                double num9  = num7 - (double)num8;
                double num10 = num6 * (1.0 - num5);
                double num11 = num6 * (1.0 - num5 * num9);
                double num12 = num6 * (1.0 - num5 * (1.0 - num9));
                switch (num8)
                {
                case 0:
                    num  = num6;
                    num2 = num12;
                    num3 = num10;
                    break;

                case 1:
                    num  = num11;
                    num2 = num6;
                    num3 = num10;
                    break;

                case 2:
                    num  = num10;
                    num2 = num6;
                    num3 = num12;
                    break;

                case 3:
                    num  = num10;
                    num2 = num11;
                    num3 = num6;
                    break;

                case 4:
                    num  = num12;
                    num2 = num10;
                    num3 = num6;
                    break;

                case 5:
                    num  = num6;
                    num2 = num10;
                    num3 = num11;
                    break;
                }
            }
            return(new RGB((int)(num * 255.0), (int)(num2 * 255.0), (int)(num3 * 255.0)));
        }