generate free ICC v2 or v4

This commit is contained in:
Desmis
2018-04-08 11:18:54 +02:00
parent 5e4ed74932
commit 6047430b43
8 changed files with 89 additions and 6 deletions

View File

@@ -1594,6 +1594,10 @@ TP_GAMMA_CURV;Gamma
TP_GAMMA_FREE;Free Output Integrate Profile (FOIP)
TP_GAMMA_PRIM;Primaries Output profile
TP_GAMMA_OUTPUT;Output gamma
TP_GAMMA_PROF;Generate ICC profile
TP_GAMMA_PROF_NONE;none
TP_GAMMA_PROF_V2;ICC V2
TP_GAMMA_PROF_V4;ICC V4
TP_GAMMA_SLOP;Slope (linear)
TP_GENERAL_11SCALE_TOOLTIP;The effects of this tool are only visible or only accurate at a preview scale of 1:1.
TP_GRADIENT_CENTER;Center

View File

@@ -1520,8 +1520,12 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
std::wstring gammaStrICC;
gammaWs.precision(6);
outPro = outProfile + "_FOIP"+ std::to_string((float)icm.gampos)+" "+ std::to_string((float)icm.slpos) + ".icc";
if(icm.wprofile == "v4") {
outPro = outProfile + "_FOIP_V4_"+ std::to_string((float)icm.gampos)+" "+ std::to_string((float)icm.slpos) + ".icc";
} else if(icm.wprofile == "v2") {
outPro = outProfile + "_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());
@@ -1538,7 +1542,12 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
cmsMLUfree(mlu);
}
cmsSetProfileVersion(outputProfile, 4.3);
if(icm.wprofile == "v4") {
cmsSetProfileVersion(outputProfile, 4.3);
}
else {
cmsSetProfileVersion(outputProfile, 2.0);
}
//change
enum class ColorTemp {
D50 = 5003, // for Widegamut, Prophoto Best, Beta -> D50
@@ -1622,12 +1631,15 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
// Calculate output profile's rTRC gTRC bTRC
GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve(nullptr, 5, Parameters);
outputProfile = cmsCreateRGBProfile(&xyD, &Primaries, GammaTRC);
if(icm.wprofile == "v4") {
outputProfile = cmsCreateRGBProfile(&xyD, &Primaries, GammaTRC);
}
cmsWriteTag(outputProfile, cmsSigRedTRCTag,GammaTRC[0] );
cmsWriteTag(outputProfile, cmsSigGreenTRCTag,GammaTRC[1] );
cmsWriteTag(outputProfile, cmsSigBlueTRCTag,GammaTRC[2] );
cmsSaveProfileToFile(outputProfile, outPro.c_str());
if(icm.wprofile == "v2" || icm.wprofile == "v4") {
cmsSaveProfileToFile(outputProfile, outPro.c_str());
}
if (GammaTRC) {
cmsFreeToneCurve(GammaTRC[0]);
}

View File

@@ -1951,6 +1951,7 @@ ColorManagementParams::ColorManagementParams() :
gampos(2.4),
slpos(12.92310),
wprimari("sRGB"),
wprofile("none"),
freegamma(false)
{
}
@@ -1972,6 +1973,7 @@ bool ColorManagementParams::operator ==(const ColorManagementParams& other) cons
&& gampos == other.gampos
&& slpos == other.slpos
&& wprimari == other.wprimari
&& wprofile == other.wprofile
&& freegamma == other.freegamma;
}
@@ -3185,6 +3187,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
saveToKeyfile(!pedited || pedited->icm.gampos, "Color Management", "GammaValue", icm.gampos, keyFile);
saveToKeyfile(!pedited || pedited->icm.slpos, "Color Management", "GammaSlope", icm.slpos, keyFile);
saveToKeyfile(!pedited || pedited->icm.wprimari, "Color Management", "GammaPrimari", icm.wprimari, keyFile);
saveToKeyfile(!pedited || pedited->icm.wprofile, "Color Management", "GammaProfile", icm.wprofile, keyFile);
// Wavelet
saveToKeyfile(!pedited || pedited->wavelet.enabled, "Wavelet", "Enabled", wavelet.enabled, keyFile);
@@ -4210,6 +4213,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
assignFromKeyfile(keyFile, "Color Management", "GammaValue", pedited, icm.gampos, pedited->icm.gampos);
assignFromKeyfile(keyFile, "Color Management", "GammaSlope", pedited, icm.slpos, pedited->icm.slpos);
assignFromKeyfile(keyFile, "Color Management", "GammaPrimari", pedited, icm.wprimari, pedited->icm.wprimari);
assignFromKeyfile(keyFile, "Color Management", "GammaProfile", pedited, icm.wprofile, pedited->icm.wprofile);
}
if (keyFile.has_group ("Wavelet")) {

View File

@@ -1024,6 +1024,7 @@ struct ColorManagementParams {
double slpos;
bool freegamma;
Glib::ustring wprimari;
Glib::ustring wprofile;
static const Glib::ustring NoICMString;

View File

@@ -35,6 +35,7 @@ ICMPanel::ICMPanel () : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iunch
{
auto m = ProcEventMapper::getInstance();
EvICMprimariMethod = m->newEvent(GAMMA, "HISTORY_MSG_ICMPRIMARI");
EvICMprofileMethod = m->newEvent(GAMMA, "HISTORY_MSG_ICMPROFILE");
isBatchMode = lastToneCurve = lastApplyLookTable = lastApplyBaselineExposureOffset = lastApplyHueSatMap = lastgamfree = false;
@@ -285,6 +286,23 @@ ICMPanel::ICMPanel () : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iunch
fgVBox->pack_start( *gampos, Gtk::PACK_SHRINK);//gamma
fgVBox->pack_start( *slpos, Gtk::PACK_SHRINK);//slope
Gtk::HBox* profHBox = Gtk::manage (new Gtk::HBox ());
Gtk::Label* proflab = Gtk::manage (new Gtk::Label (M("TP_GAMMA_PROF") + ":"));
profHBox->pack_start (*proflab, Gtk::PACK_SHRINK);
wprofile = Gtk::manage (new MyComboBoxText ());
profHBox->pack_start (*wprofile, Gtk::PACK_EXPAND_WIDGET);
fgVBox->pack_start(*profHBox, Gtk::PACK_EXPAND_WIDGET);
wprofile->append (M("TP_GAMMA_PROF_NONE"));
wprofile->append (M("TP_GAMMA_PROF_V2"));
wprofile->append (M("TP_GAMMA_PROF_V4"));
wprofileconn = wprofile->signal_changed().connect ( sigc::mem_fun(*this, &ICMPanel::wprofileChanged) );
wprofile->set_active (0);
fgFrame->add(*fgVBox);
oVBox->pack_start(*fgFrame, Gtk::PACK_EXPAND_WIDGET);
@@ -521,6 +539,7 @@ void ICMPanel::read (const ProcParams* pp, const ParamsEdited* pedited)
ConnectionBlocker wgammaconn_(wgammaconn);
ConnectionBlocker dcpillconn_(dcpillconn);
ConnectionBlocker wprimariconn_(wprimariconn);
ConnectionBlocker wprofileconn_(wprofileconn);
if(pp->icm.input.substr(0, 5) != "file:" && !ipDialog->get_filename().empty()) {
ipDialog->set_filename(pp->icm.input);
@@ -557,7 +576,18 @@ void ICMPanel::read (const ProcParams* pp, const ParamsEdited* pedited)
wnames->set_active_text (pp->icm.working);
wgamma->set_active_text (pp->icm.gamma);
wprimari->set_active_text (pp->icm.wprimari);
// wprofile->set_active_text (pp->icm.wprofile);
if (pp->icm.wprofile == "none") {
wprofile->set_active (0);
} else if (pp->icm.wprofile == "v2") {
wprofile->set_active (1);
} else if (pp->icm.wprofile == "v4") {
wprofile->set_active (2);
}
// wprofileChanged();
if (pp->icm.output == ColorManagementParams::NoICMString) {
onames->set_active_text (M("TP_ICM_NOICM"));
} else {
@@ -626,6 +656,9 @@ void ICMPanel::read (const ProcParams* pp, const ParamsEdited* pedited)
if (!pedited->icm.wprimari) {
wprimari->set_active_text(M("GENERAL_UNCHANGED"));
}
if (!pedited->icm.wprofile) {
wprofile->set_active_text(M("GENERAL_UNCHANGED"));
}
gampos->setEditedState (pedited->icm.gampos ? Edited : UnEdited);
slpos->setEditedState (pedited->icm.slpos ? Edited : UnEdited);
@@ -660,6 +693,7 @@ void ICMPanel::write (ProcParams* pp, ParamsEdited* pedited)
pp->icm.gamma = wgamma->get_active_text ();
pp->icm.dcpIlluminant = rtengine::max<int>(dcpIll->get_active_row_number(), 0);
pp->icm.wprimari = wprimari->get_active_text ();
// pp->icm.wprofile = wprofile->get_active_text ();
if (onames->get_active_text() == M("TP_ICM_NOICM")) {
pp->icm.output = ColorManagementParams::NoICMString;
@@ -674,6 +708,14 @@ void ICMPanel::write (ProcParams* pp, ParamsEdited* pedited)
pp->icm.outputIntent = rtengine::RI_RELATIVE;
}
if (wprofile->get_active_row_number() == 0) {
pp->icm.wprofile = "none";
} else if (wprofile->get_active_row_number() == 1) {
pp->icm.wprofile = "v2";
} else if (wprofile->get_active_row_number() == 2) {
pp->icm.wprofile = "v4";
}
pp->icm.freegamma = freegamma->get_active();
pp->icm.toneCurve = ckbToneCurve->get_active ();
pp->icm.applyLookTable = ckbApplyLookTable->get_active ();
@@ -699,6 +741,7 @@ void ICMPanel::write (ProcParams* pp, ParamsEdited* pedited)
pedited->icm.gampos = gampos->getEditedState ();
pedited->icm.slpos = slpos->getEditedState ();
pedited->icm.wprimari = wprimari->get_active_text() != M("GENERAL_UNCHANGED");
pedited->icm.wprofile = wprofile->get_active_text() != M("GENERAL_UNCHANGED");
}
}
@@ -753,6 +796,13 @@ void ICMPanel::wprimariChanged ()
}
}
void ICMPanel::wprofileChanged ()
{
if (listener) {
listener->panelChanged (EvICMprofileMethod, wprofile->get_active_text ());
}
}
void ICMPanel::gpChanged ()
{
@@ -1105,6 +1155,7 @@ void ICMPanel::setBatchMode (bool batchMode)
wnames->append (M("GENERAL_UNCHANGED"));
wgamma->append (M("GENERAL_UNCHANGED"));
wprimari->append (M("GENERAL_UNCHANGED"));
wprofile->append (M("GENERAL_UNCHANGED"));
dcpIll->append (M("GENERAL_UNCHANGED"));
gampos->showEditedCB ();
slpos->showEditedCB ();

View File

@@ -60,6 +60,7 @@ protected:
private:
rtengine::ProcEvent EvICMprimariMethod;
rtengine::ProcEvent EvICMprofileMethod;
Gtk::VBox * iVBox;
@@ -84,6 +85,8 @@ private:
sigc::connection wgammaconn;
MyComboBoxText* wprimari;
sigc::connection wprimariconn;
MyComboBoxText* wprofile;
sigc::connection wprofileconn;
MyComboBoxText* onames;
sigc::connection onamesconn;
@@ -114,6 +117,7 @@ public:
void wpChanged ();
void wprimariChanged ();
void wprofileChanged ();
void opChanged ();
void oiChanged (int n);
void oBPCChanged ();

View File

@@ -389,6 +389,7 @@ void ParamsEdited::set (bool v)
icm.gampos = v;
icm.slpos = v;
icm.wprimari = v;
icm.wprofile = v;
raw.bayersensor.method = v;
raw.bayersensor.imageNum = v;
raw.bayersensor.ccSteps = v;
@@ -953,6 +954,7 @@ void ParamsEdited::initFrom (const std::vector<rtengine::procparams::ProcParams>
icm.gampos = icm.gampos && p.icm.gampos == other.icm.gampos;
icm.slpos = icm.slpos && p.icm.slpos == other.icm.slpos;
icm.wprimari = icm.wprimari && p.icm.wprimari == other.icm.wprimari;
icm.wprofile = icm.wprofile && p.icm.wprofile == other.icm.wprofile;
raw.bayersensor.method = raw.bayersensor.method && p.raw.bayersensor.method == other.raw.bayersensor.method;
raw.bayersensor.imageNum = raw.bayersensor.imageNum && p.raw.bayersensor.imageNum == other.raw.bayersensor.imageNum;
raw.bayersensor.ccSteps = raw.bayersensor.ccSteps && p.raw.bayersensor.ccSteps == other.raw.bayersensor.ccSteps;
@@ -2470,6 +2472,10 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
toEdit.icm.wprimari = mods.icm.wprimari;
}
if (icm.wprofile) {
toEdit.icm.wprofile = mods.icm.wprofile;
}
if (icm.freegamma) {
toEdit.icm.freegamma = mods.icm.freegamma;
}

View File

@@ -587,6 +587,7 @@ public:
bool slpos;
bool freegamma;
bool wprimari;
bool wprofile;
};
class WaveletParamsEdited
{