コード例 #1
0
        private void Convert_Button_Click(object sender, EventArgs e)
        {
            switch (((Button)sender).Name)
            {
                case "RGB_Button":
                    try
                    {
                        if (RGBSpace != RGBSpaceName.ICC) ColRGB = new ColorRGB(RGBSpace, RGB[0], RGB[1], RGB[2]);
                        else ColRGB = new ColorRGB(RGB_ICC, RGB[0], RGB[1], RGB[2]);
                        Conversion(ColRGB);
                    }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "XYZ_Button":
                    try { ColXYZ = new ColorXYZ(XYZwp, XYZ[0], XYZ[1], XYZ[2]); Conversion(ColXYZ); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "Lab_Button":
                    try { ColLab = new ColorLab(Labwp, Lab[0], Lab[1], Lab[2]); Conversion(ColLab); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "Luv_Button":
                    try { ColLuv = new ColorLuv(Luvwp, Luv[0], Luv[1], Luv[2]); Conversion(ColLuv); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "Yxy_Button":
                    try { ColYxy = new ColorYxy(Yxywp, Yxy[0], Yxy[1], Yxy[2]); Conversion(ColYxy); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "LCHab_Button":
                    try { ColLCHab = new ColorLCHab(LCHabwp, LCHab[0], LCHab[1], LCHab[2]); Conversion(ColLCHab); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "LCHuv_Button":
                    try { ColLCHuv = new ColorLCHuv(LCHuvwp, LCHuv[0], LCHuv[1], LCHuv[2]); Conversion(ColLCHuv); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "LCH99_Button":
                    try { ColLCH99 = new ColorLCH99(LCH99[0], LCH99[1], LCH99[2]); Conversion(ColLCH99); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "LCH99b_Button":
                    try { ColLCH99b = new ColorLCH99b(LCH99b[0], LCH99b[1], LCH99b[2]); Conversion(ColLCH99b); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "LCH99c_Button":
                    try { ColLCH99c = new ColorLCH99c(LCH99c[0], LCH99c[1], LCH99c[2]); Conversion(ColLCH99c); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "LCH99d_Button":
                    try { ColLCH99d = new ColorLCH99d(LCH99d[0], LCH99d[1], LCH99d[2]); Conversion(ColLCH99d); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "HSV_Button":
                    try
                    {
                        if (HSVSpace != RGBSpaceName.ICC) ColHSV = new ColorHSV(HSVSpace, HSV[0], HSV[1], HSV[2]);
                        else ColHSV = new ColorHSV(HSV_ICC, HSV[0], HSV[1], HSV[2]);
                        Conversion(ColHSV);
                    }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "HSL_Button":
                    try
                    {
                        if (HSLSpace != RGBSpaceName.ICC) ColHSL = new ColorHSL(HSLSpace, HSL[0], HSL[1], HSL[2]);
                        else ColHSL = new ColorHSL(HSL_ICC, HSL[0], HSL[1], HSL[2]);
                        Conversion(ColHSL);
                    }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "CMY_Button":
                    try { ColCMY = new ColorCMY(CMY_ICC, CMY[0], CMY[1], CMY[2]); Conversion(ColCMY); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "CMYK_Button":
                    try { ColCMYK = new ColorCMYK(CMYK_ICC, CMYK[0], CMYK[1], CMYK[2], CMYK[3]); Conversion(ColCMYK); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "Gray_Button":
                    try
                    {
                        if (Gray_ICC != null) ColGray = new ColorGray(Gray_ICC, Gray[0]);
                        else ColGray = new ColorGray(Gray[0]);
                        Conversion(ColGray);
                    }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "YCbCr_Button":
                    try
                    {
                        if (YCbCrSpace == YCbCrSpaceName.ICC) ColYCbCr = new ColorYCbCr(YCbCr_ICC, YCbCr[0], YCbCr[1], YCbCr[2]);
                        else ColYCbCr = new ColorYCbCr(YCbCrSpace, YCbCr[0], YCbCr[1], YCbCr[2]);
                        Conversion(ColYCbCr);
                    }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "XColor_Button":
                    try { ColX = new ColorX(XColor_ICC, XColor.Take(XColor_Channels).ToArray()); Conversion(ColX); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "DEF_Button":
                    try { ColDEF = new ColorDEF(DEFwp, DEF[0], DEF[1], DEF[2]); Conversion(ColDEF); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "Bef_Button":
                    try { ColBef = new ColorBef(Befwp, Bef[0], Bef[1], Bef[2]); Conversion(ColBef); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;

                case "BCH_Button":
                    try { ColBCH = new ColorBCH(BCHwp, BCH[0], BCH[1], BCH[2]); Conversion(ColBCH); }
                    catch (FormatException) { MessageBox.Show("Not a number!"); }
                    catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message); }
                    break;
            }
        }
コード例 #2
0
 /// <summary>
 /// Get the difference between two colors
 /// </summary>
 /// <param name="Color1">First color</param>
 /// <param name="Color2">Second color</param>
 /// <returns>The difference between Color1 and Color2</returns>
 public static double GetDeltaE_DIN99(ColorLCH99b Color1, ColorLCH99b Color2)
 {
     return(GetDeltaE_DIN99_Base(Color1, Color2));
 }
コード例 #3
0
        private void Conversion(Color inColor)
        {
            Color inColor2 = inColor;
            if (inColor.IsICCcolor && !inColor.IsPCScolor) { inColor2 = Converter.ToICC(inColor); }

            if (inColor.Model != ColorModel.CIEXYZ) ColXYZ = Converter.ToXYZ(inColor2, XYZwp);
            if (inColor.Model != ColorModel.CIELab) ColLab = Converter.ToLab(inColor2, Labwp);
            if (inColor.Model != ColorModel.CIELuv) ColLuv = Converter.ToLuv(inColor2, Luvwp);
            if (inColor.Model != ColorModel.CIELCHab) ColLCHab = Converter.ToLCHab(inColor2, LCHabwp);
            if (inColor.Model != ColorModel.CIELCHuv) ColLCHuv = Converter.ToLCHuv(inColor2, LCHuvwp);
            if (inColor.Model != ColorModel.CIEYxy) ColYxy = Converter.ToYxy(inColor2, Yxywp);
            if (inColor.Model != ColorModel.LCH99) ColLCH99 = Converter.ToLCH99(inColor2);
            if (inColor.Model != ColorModel.LCH99b) ColLCH99b = Converter.ToLCH99b(inColor2);
            if (inColor.Model != ColorModel.LCH99c) ColLCH99c = Converter.ToLCH99c(inColor2);
            if (inColor.Model != ColorModel.LCH99d) ColLCH99d = Converter.ToLCH99d(inColor2);
            if (inColor.Model != ColorModel.DEF) ColDEF = Converter.ToDEF(inColor2);
            if (inColor.Model != ColorModel.Bef) ColBef = Converter.ToBef(inColor2);
            if (inColor.Model != ColorModel.BCH) ColBCH = Converter.ToBCH(inColor2);

            if (inColor.Model != ColorModel.RGB)
            {
                if (RGBSpace != RGBSpaceName.ICC) ColRGB = Converter.ToRGB(inColor2, RGBSpace);
                else ColRGB = (ColorRGB)Converter.ToICC(Converter.ToICC_PCS(inColor2, RGB_ICC), RGB_ICC);
            }
            if (inColor.Model != ColorModel.HSV)
            {
                if (HSVSpace != RGBSpaceName.ICC) ColHSV = Converter.ToHSV(inColor2, HSVSpace);
                else ColHSV = (ColorHSV)Converter.ToICC(Converter.ToICC_PCS(inColor2, HSV_ICC), HSV_ICC);
            }
            if (inColor.Model != ColorModel.HSL)
            {
                if (HSLSpace != RGBSpaceName.ICC) ColHSL = Converter.ToHSL(inColor2, HSLSpace);
                else ColHSL = (ColorHSL)Converter.ToICC(Converter.ToICC_PCS(inColor2, HSL_ICC), HSL_ICC);
            }
            if (inColor.Model != ColorModel.CMY && CMY_ICC != null) ColCMY = (ColorCMY)Converter.ToICC(Converter.ToICC_PCS(inColor2, CMY_ICC), CMY_ICC);
            if (inColor.Model != ColorModel.CMYK && CMYK_ICC != null) ColCMYK = (ColorCMYK)Converter.ToICC(Converter.ToICC_PCS(inColor2, CMYK_ICC), CMYK_ICC);
            if (inColor.Model != ColorModel.YCbCr)
            {
                if (YCbCrSpace != YCbCrSpaceName.ICC) ColYCbCr = Converter.ToYCbCr(inColor2, YCbCrSpace);
                else ColYCbCr = (ColorYCbCr)Converter.ToICC(Converter.ToICC_PCS(inColor2, YCbCr_ICC), YCbCr_ICC);
            }
            if (inColor.Model != ColorModel.Gray)
            {
                if (CMY_ICC != null) ColGray = (ColorGray)Converter.ToICC(Converter.ToICC_PCS(inColor2, Gray_ICC), Gray_ICC);
                else ColGray = Converter.ToGray(inColor2);
            }
            if (!IsXColor(inColor.Model) && XColor_ICC != null) ColX = (ColorX)Converter.ToICC(Converter.ToICC_PCS(inColor2, XColor_ICC), XColor_ICC);

            FillFields();
        }
コード例 #4
0
 /// <summary>
 /// Get the Chroma difference between two colors
 /// </summary>
 /// <param name="Color1">First color</param>
 /// <param name="Color2">Second color</param>
 /// <returns>The Chroma difference between Color1 and Color2</returns>
 public static double GetDeltaC_DIN99(ColorLCH99b Color1, ColorLCH99b Color2)
 {
     return GetDeltaC_DIN99_Base(Color1, Color2);
 }