From 02ce0e0e8494f2bb94c3fd23439c9573f25d28a8 Mon Sep 17 00:00:00 2001 From: Desmis Date: Sun, 15 Apr 2018 10:57:52 +0200 Subject: [PATCH] Fixed bug generation V2 V4 icc --- rtdata/iccprofiles/output/RT_acesp1_V4.icc | Bin 900 -> 684 bytes rtengine/iccstore.cc | 431 +++++++++------------ rtengine/procparams.cc | 2 +- rtgui/icmpanel.cc | 4 + 4 files changed, 193 insertions(+), 244 deletions(-) diff --git a/rtdata/iccprofiles/output/RT_acesp1_V4.icc b/rtdata/iccprofiles/output/RT_acesp1_V4.icc index 13a689fd60af3404f629d8eb16367b43af739c68..cbabce4837b0c0ac8ea80ae6d69dc72cd8cd6c50 100644 GIT binary patch delta 288 zcmZo+U&E@yz`(R7Cpov6#ejh!H?O29$lXaHA~H&W{SgBT13v=?gBSx}VsdeTZ?Id) z#6+oyZnpK@DXGQD3=E7M3=9l*$pu9vK(+^v?NeS-0Af!8vPF_J5>tTe6+pI55zs&& z`wB=r3BrB>Vy8pce?aV_kRWHETLge?jdTdx0>n;&uoFP+xWzQSge#3oGcY<2^gb(k4R#8$A2 zY17$R*rc+u73`E%`~wtwv4|GY@pos6)v()nhq>pQ^O`f~+=0TAHRDIcD)`+vY+Rdi z78dV2hdxuJ#6d1nb4?W7nxAPhbnSj3XN?~&*jz*11{+FVD>9ICWZpDE7>jqrH`n99 z@}9VCI<5!#-T$Rs;_)I(F=a!c|hS#etZ`9&-BTB^#8^q{zqB)jUxfo=HpBT4pNC&}+C>e*L#pPrM{mz^z` z?a3DRbDsPHM=n9{Y+rX;y?pso@y`M`bko?P_WVj0zQ2IdB8 D50 - D65 = 6504, // for sRGB, AdobeRGB, Bruce Rec2020 -> D65 - D60 = 6005 //for ACESc->D60 - }; - ColorTemp temp = ColorTemp::D50; + enum class ColorTemp { + D50 = 5003, // for Widegamut, Prophoto Best, Beta -> D50 + D65 = 6504, // for sRGB, AdobeRGB, Bruce Rec2020 -> D65 + D60 = 6005 //for ACESc->D60 + }; + ColorTemp temp = ColorTemp::D50; - if (icm.wprimari == "wideg") { - p[0] = 0.7350; //Widegamut primaries - p[1] = 0.2650; - p[2] = 0.1150; - p[3] = 0.8260; - p[4] = 0.1570; - p[5] = 0.0180; - - } else if (icm.wprimari == "adob") { - p[0] = 0.6400; //Adobe primaries - p[1] = 0.3300; - p[2] = 0.2100; - p[3] = 0.7100; - p[4] = 0.1500; - p[5] = 0.0600; - temp = ColorTemp::D65; - } else if (icm.wprimari == "srgb") { - p[0] = 0.6400; // sRGB primaries - p[1] = 0.3300; - p[2] = 0.3000; - p[3] = 0.6000; - p[4] = 0.1500; - p[5] = 0.0600; - temp = ColorTemp::D65; - } else if (icm.wprimari == "BruceRGB") { - p[0] = 0.6400; // Bruce primaries - p[1] = 0.3300; - p[2] = 0.2800; - p[3] = 0.6500; - p[4] = 0.1500; - p[5] = 0.0600; - temp = ColorTemp::D65; - } else if (icm.wprimari == "Beta RGB") { - p[0] = 0.6888; // Beta primaries - p[1] = 0.3112; - p[2] = 0.1986; - p[3] = 0.7551; - p[4] = 0.1265; - p[5] = 0.0352; - } else if (icm.wprimari == "BestRGB") { - p[0] = 0.7347; // Best primaries - p[1] = 0.2653; - p[2] = 0.2150; - p[3] = 0.7750; - p[4] = 0.1300; - p[5] = 0.0350; - } else if (icm.wprimari == "rec2020") { - p[0] = 0.7080; // Rec2020 primaries - p[1] = 0.2920; - p[2] = 0.1700; - p[3] = 0.7970; - p[4] = 0.1310; - p[5] = 0.0460; - temp = ColorTemp::D65; - } else if (icm.wprimari == "acesp0") { - p[0] = 0.7347; // ACES P0 primaries - p[1] = 0.2653; - p[2] = 0.0000; - p[3] = 1.0; - p[4] = 0.0001; - p[5] = -0.0770; - temp = ColorTemp::D60; - } else if (icm.wprimari == "acesp1") { - p[0] = 0.713; // ACES P1 primaries - p[1] = 0.293; - p[2] = 0.165; - p[3] = 0.830; - p[4] = 0.128; - p[5] = 0.044; - temp = ColorTemp::D60; - } else if (icm.wprimari == "proph") { - p[0] = 0.7347; //ProPhoto and default primaries - p[1] = 0.2653; - p[2] = 0.1596; - p[3] = 0.8404; - p[4] = 0.0366; - p[5] = 0.0001; - } else { - p[0] = 0.7347; //ProPhoto and default primaries - p[1] = 0.2653; - p[2] = 0.1596; - p[3] = 0.8404; - p[4] = 0.0366; - p[5] = 0.0001; - } - - cmsCIExyY xyD; - cmsCIExyYTRIPLE Primaries = { - {p[0], p[1], 1.0}, // red - {p[2], p[3], 1.0}, // green - {p[4], p[5], 1.0} // blue - }; - - cmsWhitePointFromTemp(&xyD, (double)temp); - cmsToneCurve* GammaTRC[3]; - - - // Calculate output profile's rTRC gTRC bTRC - GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve(nullptr, 5, Parameters); - - if (icm.wprofile == "v4") { - outputProfile = cmsCreateRGBProfile(&xyD, &Primaries, GammaTRC); - } - - cmsWriteTag(outputProfile, cmsSigRedTRCTag, GammaTRC[0]); - cmsWriteTag(outputProfile, cmsSigGreenTRCTag, GammaTRC[1]); - cmsWriteTag(outputProfile, cmsSigBlueTRCTag, GammaTRC[2]); - - if (icm.freegamma) { - // create description with gamma + slope + primaries - std::wostringstream gammaWs; - //std::string gammaWsICC; - std::wstring gammaStrIC; - - gammaWs.precision(6); - - if (icm.gamma == "Free") { - if (icm.wprofile == "v4") { - outPro = outPr + "_FOIP_V4_" + std::to_string((float)icm.gampos) + " " + std::to_string((float)icm.slpos) + ".icc"; - } else if (icm.wprofile == "v2") { - outPro = outPr + "_FOIP_V2_" + std::to_string((float)icm.gampos) + " " + std::to_string((float)icm.slpos) + ".icc"; - } - - gammaWs << outPro.c_str() << (float)icm.gampos << " s=" << (float)icm.slpos; - - cmsMLUsetWide(mlu, "en", "US", gammaWs.str().c_str()); + if (icm.wprimari == "wideg") { + p[0] = 0.7350; //Widegamut primaries + p[1] = 0.2650; + p[2] = 0.1150; + p[3] = 0.8260; + p[4] = 0.1570; + p[5] = 0.0180; + } else if (icm.wprimari == "adob") { + p[0] = 0.6400; //Adobe primaries + p[1] = 0.3300; + p[2] = 0.2100; + p[3] = 0.7100; + p[4] = 0.1500; + p[5] = 0.0600; + temp = ColorTemp::D65; + } else if (icm.wprimari == "srgb") { + p[0] = 0.6400; // sRGB primaries + p[1] = 0.3300; + p[2] = 0.3000; + p[3] = 0.6000; + p[4] = 0.1500; + p[5] = 0.0600; + temp = ColorTemp::D65; + } else if (icm.wprimari == "BruceRGB") { + p[0] = 0.6400; // Bruce primaries + p[1] = 0.3300; + p[2] = 0.2800; + p[3] = 0.6500; + p[4] = 0.1500; + p[5] = 0.0600; + temp = ColorTemp::D65; + } else if (icm.wprimari == "Beta RGB") { + p[0] = 0.6888; // Beta primaries + p[1] = 0.3112; + p[2] = 0.1986; + p[3] = 0.7551; + p[4] = 0.1265; + p[5] = 0.0352; + } else if (icm.wprimari == "BestRGB") { + p[0] = 0.7347; // Best primaries + p[1] = 0.2653; + p[2] = 0.2150; + p[3] = 0.7750; + p[4] = 0.1300; + p[5] = 0.0350; + } else if (icm.wprimari == "rec2020") { + p[0] = 0.7080; // Rec2020 primaries + p[1] = 0.2920; + p[2] = 0.1700; + p[3] = 0.7970; + p[4] = 0.1310; + p[5] = 0.0460; + temp = ColorTemp::D65; + } else if (icm.wprimari == "acesp0") { + p[0] = 0.7347; // ACES P0 primaries + p[1] = 0.2653; + p[2] = 0.0000; + p[3] = 1.0; + p[4] = 0.0001; + p[5] = -0.0770; + temp = ColorTemp::D60; + } else if (icm.wprimari == "acesp1") { + p[0] = 0.713; // ACES P1 primaries + p[1] = 0.293; + p[2] = 0.165; + p[3] = 0.830; + p[4] = 0.128; + p[5] = 0.044; + temp = ColorTemp::D60; + } else if (icm.wprimari == "proph") { + p[0] = 0.7347; //ProPhoto and default primaries + p[1] = 0.2653; + p[2] = 0.1596; + p[3] = 0.8404; + p[4] = 0.0366; + p[5] = 0.0001; } else { + p[0] = 0.7347; //ProPhoto and default primaries + p[1] = 0.2653; + p[2] = 0.1596; + p[3] = 0.8404; + p[4] = 0.0366; + p[5] = 0.0001; + } - if (icm.wprofile == "v4") { - outPro = outPr + "_FOIP_V4_" + gammaStr + ".icc"; + cmsCIExyY xyD; + cmsCIExyYTRIPLE Primaries = { + {p[0], p[1], 1.0}, // red + {p[2], p[3], 1.0}, // green + {p[4], p[5], 1.0} // blue + }; - } else if (icm.wprofile == "v2") { - outPro = outPr + "_FOIP_V2_" + gammaStr + ".icc"; - } + cmsWhitePointFromTemp(&xyD, (double)temp); + cmsToneCurve* GammaTRC[3]; - gammaWs << outPro.c_str() << " s="; - cmsMLUsetWide(mlu, "en", "US", gammaWs.str().c_str()); + // Calculate output profile's rTRC gTRC bTRC + GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve(nullptr, 5, Parameters); + + if (icm.wprofile == "v4") { + outputProfile = cmsCreateRGBProfile(&xyD, &Primaries, GammaTRC); + } + + cmsWriteTag(outputProfile, cmsSigRedTRCTag, GammaTRC[0]); + cmsWriteTag(outputProfile, cmsSigGreenTRCTag, GammaTRC[1]); + cmsWriteTag(outputProfile, cmsSigBlueTRCTag, GammaTRC[2]); + cmsWriteTag(outputProfile, cmsSigProfileDescriptionTag, mlu);//desc changed + + /* + cmsCIEXYZ *redT = static_cast(cmsReadTag(outputProfile, cmsSigRedMatrixColumnTag)); + cmsCIEXYZ *greenT = static_cast(cmsReadTag(outputProfile, cmsSigGreenMatrixColumnTag)); + cmsCIEXYZ *blueT = static_cast(cmsReadTag(outputProfile, cmsSigBlueMatrixColumnTag)); + printf("rx=%f gx=%f bx=%f ry=%f gy=%f by=%f rz=%f gz=%f bz=%f\n", redT->X, greenT->X, blueT->X, redT->Y, greenT->Y, blueT->Y, redT->Z, greenT->Z, blueT->Z); + */ + + cmsMLUfree(mlu); + + + + if (icm.wprofile == "v2" || icm.wprofile == "v4") { + cmsSaveProfileToFile(outputProfile, outPro.c_str()); } - cmsMLU *copyright = cmsMLUalloc(NULL, 1); - - cmsMLUsetASCII(copyright, "en", "US", "No copyright Rawtherapee"); - cmsWriteTag(outputProfile, cmsSigCopyrightTag, copyright); - cmsMLUfree(copyright); - - - } - - cmsMLU *descrip = cmsMLUalloc(NULL, 1); - cmsMLUsetASCII(descrip, "en", "US", "Rawtherapee"); - cmsWriteTag(outputProfile, cmsSigDeviceModelDescTag, descrip); - cmsMLUfree(descrip); - - cmsWriteTag(outputProfile, cmsSigProfileDescriptionTag, mlu);//desc changed - cmsMLUfree(mlu); - - Glib::ustring manufacturer; - - manufacturer = "RawTherapee_FOIP"; - cmsMLU *MfgDesc; - MfgDesc = cmsMLUalloc(NULL, 1); - cmsMLUsetASCII(MfgDesc, "en", "US", manufacturer.c_str()); - cmsWriteTag(outputProfile, cmsSigDeviceMfgDescTag, MfgDesc); - cmsMLUfree(MfgDesc); - /* - cmsCIEXYZ *red = static_cast(cmsReadTag(outputProfile, cmsSigRedMatrixColumnTag)); - cmsCIEXYZ *green = static_cast(cmsReadTag(outputProfile, cmsSigGreenMatrixColumnTag)); - cmsCIEXYZ *blue = static_cast(cmsReadTag(outputProfile, cmsSigBlueMatrixColumnTag)); - printf("rx=%f gx=%f bx=%f ry=%f gy=%f by=%f rz=%f gz=%f bz=%f\n", red->X, green->X, blue->X, red->Y, green->Y, blue->Y, red->Z, green->Z, blue->Z); - */ - - - if (icm.wprofile == "v2" || icm.wprofile == "v4") { - cmsSaveProfileToFile(outputProfile, outPro.c_str()); - - } - - if (GammaTRC) { - cmsFreeToneCurve(GammaTRC[0]); + if (GammaTRC) { + cmsFreeToneCurve(GammaTRC[0]); + } } return outputProfile; + } diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 07410a086..e2ca3bcf5 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -1956,7 +1956,7 @@ ColorManagementParams::ColorManagementParams() : output("RT_sRGB"), outputIntent(RI_RELATIVE), outputBPC(true), - gamma("default"), + gamma("Free"), gampos(2.4), slpos(12.92310), wprimari("sRGB"), diff --git a/rtgui/icmpanel.cc b/rtgui/icmpanel.cc index e229cdcd1..eb83795bc 100644 --- a/rtgui/icmpanel.cc +++ b/rtgui/icmpanel.cc @@ -591,6 +591,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) wnames->set_active_text(pp->icm.working); wgamma->set_active_text(pp->icm.gamma); + gpChanged(); // wprimari->set_active_text(pp->icm.wprimari); // wprofile->set_active_text (pp->icm.wprofile); @@ -652,9 +653,12 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited) onames->set_sensitive(/*wgamma->get_active_row_number() == 0 &&*/ !pp->icm.freegamma); //"default" wgamma->set_sensitive(pp->icm.freegamma); gampos->set_sensitive(pp->icm.freegamma); + gampos->set_sensitive(pp->icm.gamma == "Free"); slpos->set_sensitive(pp->icm.freegamma); + slpos->set_sensitive(pp->icm.gamma == "Free"); updateRenderingIntent(pp->icm.output); wprimari->set_sensitive(pp->icm.freegamma); + wprofile->set_sensitive(pp->icm.freegamma); } gampos->setValue(pp->icm.gampos);