Ejemplo n.º 1
0
 public static ColorRGB HSVToRGB(ColorHSV colorHSV)
 {
     double num1 = (double)colorHSV.H / 256.0;
     double num2 = (double)colorHSV.S / 256.0;
     double num3 = (double)colorHSV.V / 256.0;
     double num4;
     double num5;
     double num6;
     if (num2 == 0.0)
     {
         double num7;
         num4 = num7 = num3;
         num5 = num7;
         num6 = num7;
     }
     else
     {
         double d = num1 * 6.0;
         int num7 = (int)Math.Floor(d);
         double num8 = d - (double)num7;
         double num9 = num3 * (1.0 - num2);
         double num10 = num3 * (1.0 - num2 * num8);
         double num11 = num3 * (1.0 - num2 * (1.0 - num8));
         switch (num7)
         {
             case 0:
                 num6 = num3;
                 num5 = num11;
                 num4 = num9;
                 break;
             case 1:
                 num6 = num10;
                 num5 = num3;
                 num4 = num9;
                 break;
             case 2:
                 num6 = num9;
                 num5 = num3;
                 num4 = num11;
                 break;
             case 3:
                 num6 = num9;
                 num5 = num10;
                 num4 = num3;
                 break;
             case 4:
                 num6 = num11;
                 num5 = num9;
                 num4 = num3;
                 break;
             case 5:
                 num6 = num3;
                 num5 = num9;
                 num4 = num10;
                 break;
             default:
                 double num12;
                 num4 = num12 = num3;
                 num5 = num12;
                 num6 = num12;
                 break;
         }
     }
     ColorRGB colorRgb;
     colorRgb.R = (int)(num6 * (double)byte.MaxValue);
     colorRgb.G = (int)(num5 * (double)byte.MaxValue);
     colorRgb.B = (int)(num4 * (double)byte.MaxValue);
     return colorRgb;
 }
Ejemplo n.º 2
0
        public static ColorRGB HSVToRGB(ColorHSV colorHSV)
        {
            double num1 = (double)colorHSV.H / 256.0;
            double num2 = (double)colorHSV.S / 256.0;
            double num3 = (double)colorHSV.V / 256.0;
            double num4;
            double num5;
            double num6;

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

                case 1:
                    num6 = num10;
                    num5 = num3;
                    num4 = num9;
                    break;

                case 2:
                    num6 = num9;
                    num5 = num3;
                    num4 = num11;
                    break;

                case 3:
                    num6 = num9;
                    num5 = num10;
                    num4 = num3;
                    break;

                case 4:
                    num6 = num11;
                    num5 = num9;
                    num4 = num3;
                    break;

                case 5:
                    num6 = num3;
                    num5 = num9;
                    num4 = num10;
                    break;

                default:
                    double num12;
                    num4 = num12 = num3;
                    num5 = num12;
                    num6 = num12;
                    break;
                }
            }
            ColorRGB colorRgb;

            colorRgb.R = (int)(num6 * (double)byte.MaxValue);
            colorRgb.G = (int)(num5 * (double)byte.MaxValue);
            colorRgb.B = (int)(num4 * (double)byte.MaxValue);
            return(colorRgb);
        }