static public Color HSV_to_RGB(HSV hsv)
        {
            double H = hsv.H;
            double S = hsv.S;
            double V = hsv.V;

            while (H < 0)
            {
                H += 360;
            }
            ;
            while (H >= 360)
            {
                H -= 360;
            }
            ;
            double R, G, B;

            if (V <= 0)
            {
                R = G = B = 0;
            }
            else if (S <= 0)
            {
                R = G = B = V;
            }
            else
            {
                double hf = H / 60.0;
                int    i  = (int)Math.Floor(hf);
                double f  = hf - i;
                double pv = V * (1 - S);
                double qv = V * (1 - S * f);
                double tv = V * (1 - S * (1 - f));
                switch (i)
                {
                case 0:
                    R = V;
                    G = tv;
                    B = pv;
                    break;

                case 1:
                    R = qv;
                    G = V;
                    B = pv;
                    break;

                case 2:
                    R = pv;
                    G = V;
                    B = tv;
                    break;

                case 3:
                    R = pv;
                    G = qv;
                    B = V;
                    break;

                case 4:
                    R = tv;
                    G = pv;
                    B = V;
                    break;

                case 5:
                    R = V;
                    G = pv;
                    B = qv;
                    break;

                case 6:
                    R = V;
                    G = tv;
                    B = pv;
                    break;

                case -1:
                    R = V;
                    G = pv;
                    B = qv;
                    break;

                default:
                    R = G = B = V;
                    break;
                }
            }
            int r = CIELab.FixOutOfRangeVaue((int)(R * 255.0));
            int g = CIELab.FixOutOfRangeVaue((int)(G * 255.0));
            int b = CIELab.FixOutOfRangeVaue((int)(B * 255.0));

            return(Color.FromArgb(r, g, b));
        }
        public void ConvertColor()
        {
            ChangeNeeded = false;
            switch (ConvertType)
            {
            case "RGB":
                TargetRGB = Color.FromArgb(Int32.Parse(RGB_R.Text), Int32.Parse(RGB_G.Text), Int32.Parse(RGB_B.Text));

                TargetXYZ    = CIELab.RGB_to_XYZ(TargetRGB);
                TargetCIELab = CIELab.RGB_to_CIELab(TargetRGB);
                TargetHSV    = HSV.RGB_to_HSV(TargetRGB);

                SetHSV();
                SetXYZ();
                SetCIELab();
                break;

            case "HSV":
                TargetHSV.H = Double.Parse(HSV_H.Text);
                TargetHSV.S = Double.Parse(HSV_S.Text);
                TargetHSV.V = Double.Parse(HSV_V.Text);

                TargetRGB    = HSV.HSV_to_RGB(TargetHSV);
                TargetXYZ    = CIELab.RGB_to_XYZ(TargetRGB);
                TargetCIELab = CIELab.RGB_to_CIELab(TargetRGB);

                SetRGB();
                SetXYZ();
                SetCIELab();
                break;

            case "XYZ":
                TargetXYZ[0] = Double.Parse(XYZ_X.Text) * 100d;
                TargetXYZ[1] = Double.Parse(XYZ_Y.Text) * 100d;
                TargetXYZ[2] = Double.Parse(XYZ_Z.Text) * 100d;

                TargetRGB    = CIELab.XYZ_to_RGB(TargetXYZ);
                TargetCIELab = CIELab.XYZ_to_CIELab(TargetXYZ);
                TargetHSV    = HSV.RGB_to_HSV(TargetRGB);

                SetRGB();
                SetHSV();
                SetCIELab();
                break;

            case "Lab":
                TargetCIELab.L = Double.Parse(Lab_L.Text);
                TargetCIELab.a = Double.Parse(Lab_a.Text);
                TargetCIELab.b = Double.Parse(Lab_b.Text);

                TargetRGB = CIELab.CIELab_to_RGB(TargetCIELab);
                TargetXYZ = CIELab.CIELab_to_XYZ(TargetCIELab);
                TargetHSV = HSV.RGB_to_HSV(TargetRGB);

                SetRGB();
                SetHSV();
                SetXYZ();
                break;
            }
            targetColor.BackColor = TargetRGB;
            ConvertType           = "";
            ChangeNeeded          = true;
        }