Fixed bug generation V2 V4 icc

This commit is contained in:
Desmis
2018-04-15 10:57:52 +02:00
parent 4eae77956c
commit 02ce0e0e84
4 changed files with 193 additions and 244 deletions

View File

@@ -1557,49 +1557,40 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
gammaStr = "_LAB_g3.0_s9.03296"; gammaStr = "_LAB_g3.0_s9.03296";
} }
// instruction with //ICC are used to generate ICC profile
if (mlu == nullptr) {
printf("Description error\n");
} else {
// Description TAG : selection of gamma and Primaries
if (icm.freegamma && icm.gamma != "Free") {
/*
// std::wstring gammaStr;
if (icm.gamma == "High_g1.3_s3.35") {
gammaStr = "_TRC: High g=1.3 s=3.35";
} else if (icm.gamma == "Low_g2.6_s6.9") {
gammaStr = "_TRC: Low g=2.6 s=6.9";
} else if (icm.gamma == "sRGB_g2.4_s12.92") {
gammaStr = "_TRC: sRGB g=2.4 s=12.92";
} else if (icm.gamma == "BT709_g2.2_s4.5") {
gammaStr = "_TRC: BT709 g=2.2 s=4.5";
} else if (icm.gamma == "linear_g1.0") {
gammaStr = "_TRC: Linear g=1.0";
} else if (icm.gamma == "standard_g2.2") {
gammaStr = "GammaTRC: g=2.2";
} else if (icm.gamma == "standard_g1.8") {
gammaStr = "GammaTRC: g=1.8";
}
*/
//cmsMLUsetWide(mlu, "en", "US", gammaStr.c_str());
} else {
/*
// create description with gamma + slope + primaries // create description with gamma + slope + primaries
std::wostringstream gammaWs; std::wostringstream gammaWs;
//std::string gammaWsICC;
std::wstring gammaStrICC; std::wstring gammaStrICC;
gammaWs.precision(6); gammaWs.precision(3);
if (icm.gamma == "Free") {
if (icm.wprofile == "v4") { if (icm.wprofile == "v4") {
outPro = outPr + "_FOIP_V4_"+ std::to_string((float)icm.gampos)+" "+ std::to_string((float)icm.slpos) + ".icc"; outPro = outPr + "_V4_" + std::to_string((float)icm.gampos) + " " + std::to_string((float)icm.slpos) + ".icc";
} else if (icm.wprofile == "v2") { } else if (icm.wprofile == "v2") {
outPro = outPr + "_FOIP_V2_"+ std::to_string((float)icm.gampos)+" "+ std::to_string((float)icm.slpos) + ".icc"; outPro = outPr + "_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; gammaWs.precision(2);
gammaWs << outPr << (float)icm.gampos << " s=" << (float)icm.slpos;
cmsMLUsetWide(mlu, "en", "US", gammaWs.str().c_str());
} else {
if (icm.wprofile == "v4") {
outPro = outPr + "_V4_" + gammaStr + ".icc";
} else if (icm.wprofile == "v2") {
outPro = outPr + "_V2_" + gammaStr + ".icc";
}
gammaWs << outPro.c_str() << " s=";
}
cmsMLUsetWide(mlu, "en", "US", gammaWs.str().c_str()); cmsMLUsetWide(mlu, "en", "US", gammaWs.str().c_str());
cmsMLU *copyright = cmsMLUalloc(NULL, 1); cmsMLU *copyright = cmsMLUalloc(NULL, 1);
@@ -1607,17 +1598,24 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
cmsMLUsetASCII(copyright, "en", "US", "No copyright Rawtherapee"); cmsMLUsetASCII(copyright, "en", "US", "No copyright Rawtherapee");
cmsWriteTag(outputProfile, cmsSigCopyrightTag, copyright); cmsWriteTag(outputProfile, cmsSigCopyrightTag, copyright);
cmsMLUfree(copyright); cmsMLUfree(copyright);
cmsWriteTag(outputProfile, cmsSigProfileDescriptionTag, mlu);//desc changed
cmsMLU *descrip = cmsMLUalloc(NULL, 1); cmsMLU *descrip = cmsMLUalloc(NULL, 1);
cmsMLUsetASCII(descrip, "en", "US", "Rawtherapee"); cmsMLUsetASCII(descrip, "en", "US", "Rawtherapee");
cmsWriteTag(outputProfile, cmsSigDeviceModelDescTag, descrip); cmsWriteTag(outputProfile, cmsSigDeviceModelDescTag, descrip);
cmsMLUfree(descrip); cmsMLUfree(descrip);
*/
}
}
// instruction with //ICC are used to generate ICC profile
if (mlu == nullptr) {
printf("Description error\n");
} else {
if (icm.wprofile == "v4") { if (icm.wprofile == "v4") {
cmsSetProfileVersion(outputProfile, 4.3); cmsSetProfileVersion(outputProfile, 4.3);
@@ -1743,72 +1741,17 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
cmsWriteTag(outputProfile, cmsSigRedTRCTag, GammaTRC[0]); cmsWriteTag(outputProfile, cmsSigRedTRCTag, GammaTRC[0]);
cmsWriteTag(outputProfile, cmsSigGreenTRCTag, GammaTRC[1]); cmsWriteTag(outputProfile, cmsSigGreenTRCTag, GammaTRC[1]);
cmsWriteTag(outputProfile, cmsSigBlueTRCTag, GammaTRC[2]); 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());
} else {
if (icm.wprofile == "v4") {
outPro = outPr + "_FOIP_V4_" + gammaStr + ".icc";
} else if (icm.wprofile == "v2") {
outPro = outPr + "_FOIP_V2_" + gammaStr + ".icc";
}
gammaWs << outPro.c_str() << " s=";
cmsMLUsetWide(mlu, "en", "US", gammaWs.str().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 cmsWriteTag(outputProfile, cmsSigProfileDescriptionTag, mlu);//desc changed
/*
cmsCIEXYZ *redT = static_cast<cmsCIEXYZ*>(cmsReadTag(outputProfile, cmsSigRedMatrixColumnTag));
cmsCIEXYZ *greenT = static_cast<cmsCIEXYZ*>(cmsReadTag(outputProfile, cmsSigGreenMatrixColumnTag));
cmsCIEXYZ *blueT = static_cast<cmsCIEXYZ*>(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); 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<cmsCIEXYZ *>(cmsReadTag(outputProfile, cmsSigRedMatrixColumnTag));
cmsCIEXYZ *green = static_cast<cmsCIEXYZ *>(cmsReadTag(outputProfile, cmsSigGreenMatrixColumnTag));
cmsCIEXYZ *blue = static_cast<cmsCIEXYZ *>(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") { if (icm.wprofile == "v2" || icm.wprofile == "v4") {
@@ -1819,6 +1762,8 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
if (GammaTRC) { if (GammaTRC) {
cmsFreeToneCurve(GammaTRC[0]); cmsFreeToneCurve(GammaTRC[0]);
} }
}
return outputProfile; return outputProfile;
} }

View File

@@ -1956,7 +1956,7 @@ ColorManagementParams::ColorManagementParams() :
output("RT_sRGB"), output("RT_sRGB"),
outputIntent(RI_RELATIVE), outputIntent(RI_RELATIVE),
outputBPC(true), outputBPC(true),
gamma("default"), gamma("Free"),
gampos(2.4), gampos(2.4),
slpos(12.92310), slpos(12.92310),
wprimari("sRGB"), wprimari("sRGB"),

View File

@@ -591,6 +591,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited)
wnames->set_active_text(pp->icm.working); wnames->set_active_text(pp->icm.working);
wgamma->set_active_text(pp->icm.gamma); wgamma->set_active_text(pp->icm.gamma);
gpChanged();
// wprimari->set_active_text(pp->icm.wprimari); // wprimari->set_active_text(pp->icm.wprimari);
// wprofile->set_active_text (pp->icm.wprofile); // 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" onames->set_sensitive(/*wgamma->get_active_row_number() == 0 &&*/ !pp->icm.freegamma); //"default"
wgamma->set_sensitive(pp->icm.freegamma); wgamma->set_sensitive(pp->icm.freegamma);
gampos->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.freegamma);
slpos->set_sensitive(pp->icm.gamma == "Free");
updateRenderingIntent(pp->icm.output); updateRenderingIntent(pp->icm.output);
wprimari->set_sensitive(pp->icm.freegamma); wprimari->set_sensitive(pp->icm.freegamma);
wprofile->set_sensitive(pp->icm.freegamma);
} }
gampos->setValue(pp->icm.gampos); gampos->setValue(pp->icm.gampos);