astyle on files edited by rec2020 branch

This commit is contained in:
Beep6581
2016-04-30 16:20:45 +02:00
parent 56af7e88ce
commit 59a9d2dc2f
4 changed files with 791 additions and 775 deletions

View File

@@ -41,8 +41,9 @@ void loadProfiles (const Glib::ustring& dirName,
std::map<Glib::ustring, Glib::ustring>* profileNames, std::map<Glib::ustring, Glib::ustring>* profileNames,
bool nameUpper, bool onlyRgb) bool nameUpper, bool onlyRgb)
{ {
if (dirName.empty ()) if (dirName.empty ()) {
return; return;
}
try { try {
@@ -52,23 +53,27 @@ void loadProfiles (const Glib::ustring& dirName,
const Glib::ustring fileName = *entry; const Glib::ustring fileName = *entry;
if (fileName.size () < 4) if (fileName.size () < 4) {
continue; continue;
}
const Glib::ustring extension = fileName.substr (fileName.size () - 4).casefold (); const Glib::ustring extension = fileName.substr (fileName.size () - 4).casefold ();
if (extension.compare (".icc") != 0 && extension.compare (".icm") != 0) if (extension.compare (".icc") != 0 && extension.compare (".icm") != 0) {
continue; continue;
}
const Glib::ustring filePath = Glib::build_filename (dirName, fileName); const Glib::ustring filePath = Glib::build_filename (dirName, fileName);
if (!Glib::file_test (filePath, Glib::FILE_TEST_IS_REGULAR)) if (!Glib::file_test (filePath, Glib::FILE_TEST_IS_REGULAR)) {
continue; continue;
}
Glib::ustring name = fileName.substr (0, fileName.size() - 4); Glib::ustring name = fileName.substr (0, fileName.size() - 4);
if (nameUpper) if (nameUpper) {
name = name.uppercase (); name = name.uppercase ();
}
if (profiles) { if (profiles) {
const rtengine::ProfileContent content (filePath); const rtengine::ProfileContent content (filePath);
@@ -77,28 +82,31 @@ void loadProfiles (const Glib::ustring& dirName,
if (profile && (!onlyRgb || cmsGetColorSpace (profile) == cmsSigRgbData)) { if (profile && (!onlyRgb || cmsGetColorSpace (profile) == cmsSigRgbData)) {
profiles->insert (std::make_pair (name, profile)); profiles->insert (std::make_pair (name, profile));
if (profileContents) if (profileContents) {
profileContents->insert (std::make_pair (name, content)); profileContents->insert (std::make_pair (name, content));
} }
} }
}
if (profileNames) if (profileNames) {
profileNames->insert (std::make_pair (name, filePath)); profileNames->insert (std::make_pair (name, filePath));
} }
} }
catch (Glib::Exception&) {} } catch (Glib::Exception&) {}
} }
inline void getSupportedIntent (cmsHPROFILE profile, cmsUInt32Number intent, cmsUInt32Number direction, std::uint8_t& result) inline void getSupportedIntent (cmsHPROFILE profile, cmsUInt32Number intent, cmsUInt32Number direction, std::uint8_t& result)
{ {
if (cmsIsIntentSupported (profile, intent, direction)) if (cmsIsIntentSupported (profile, intent, direction)) {
result |= 1 << intent; result |= 1 << intent;
}
} }
inline std::uint8_t getSupportedIntents (cmsHPROFILE profile, cmsUInt32Number direction) inline std::uint8_t getSupportedIntents (cmsHPROFILE profile, cmsUInt32Number direction)
{ {
if (!profile) if (!profile) {
return 0; return 0;
}
std::uint8_t result = 0; std::uint8_t result = 0;
@@ -137,7 +145,7 @@ std::vector<Glib::ustring> getGamma ()
std::vector<Glib::ustring> res; std::vector<Glib::ustring> res;
for (unsigned int i = 0; i < sizeof(wpgamma) / sizeof(wpgamma[0]); i++) { for (unsigned int i = 0; i < sizeof (wpgamma) / sizeof (wpgamma[0]); i++) {
res.push_back (wpgamma[i]); res.push_back (wpgamma[i]);
} }
@@ -149,7 +157,7 @@ std::vector<Glib::ustring> getWorkingProfiles ()
std::vector<Glib::ustring> res; std::vector<Glib::ustring> res;
for (unsigned int i = 0; i < sizeof(wpnames) / sizeof(wpnames[0]); i++) { for (unsigned int i = 0; i < sizeof (wpnames) / sizeof (wpnames[0]); i++) {
res.push_back (wpnames[i]); res.push_back (wpnames[i]);
} }
@@ -159,12 +167,13 @@ std::vector<Glib::ustring> getWorkingProfiles ()
std::vector<Glib::ustring> ICCStore::getProfiles () const std::vector<Glib::ustring> ICCStore::getProfiles () const
{ {
MyMutex::MyLock lock(mutex_); MyMutex::MyLock lock (mutex_);
std::vector<Glib::ustring> res; std::vector<Glib::ustring> res;
for (ProfileMap::const_iterator profile = fileProfiles.begin (); profile != fileProfiles.end (); ++profile) for (ProfileMap::const_iterator profile = fileProfiles.begin (); profile != fileProfiles.end (); ++profile) {
res.push_back (profile->first); res.push_back (profile->first);
}
return res; return res;
} }
@@ -172,7 +181,7 @@ std::vector<Glib::ustring> ICCStore::getProfiles () const
std::vector<Glib::ustring> ICCStore::getProfilesFromDir (const Glib::ustring& dirName) const std::vector<Glib::ustring> ICCStore::getProfilesFromDir (const Glib::ustring& dirName) const
{ {
MyMutex::MyLock lock(mutex_); MyMutex::MyLock lock (mutex_);
std::vector<Glib::ustring> res; std::vector<Glib::ustring> res;
@@ -181,8 +190,9 @@ std::vector<Glib::ustring> ICCStore::getProfilesFromDir (const Glib::ustring& di
loadProfiles (profilesDir, &profiles, NULL, NULL, false, true); loadProfiles (profilesDir, &profiles, NULL, NULL, false, true);
loadProfiles (dirName, &profiles, NULL, NULL, false, true); loadProfiles (dirName, &profiles, NULL, NULL, false, true);
for (ProfileMap::const_iterator profile = profiles.begin (); profile != profiles.end (); ++profile) for (ProfileMap::const_iterator profile = profiles.begin (); profile != profiles.end (); ++profile) {
res.push_back (profile->first); res.push_back (profile->first);
}
return res; return res;
} }
@@ -195,19 +205,19 @@ cmsHPROFILE ICCStore::makeStdGammaProfile (cmsHPROFILE iprof)
} }
cmsUInt32Number bytesNeeded = 0; cmsUInt32Number bytesNeeded = 0;
cmsSaveProfileToMem(iprof, 0, &bytesNeeded); cmsSaveProfileToMem (iprof, 0, &bytesNeeded);
if (bytesNeeded == 0) { if (bytesNeeded == 0) {
return NULL; return NULL;
} }
uint8_t *data = new uint8_t[bytesNeeded + 1]; uint8_t *data = new uint8_t[bytesNeeded + 1];
cmsSaveProfileToMem(iprof, data, &bytesNeeded); cmsSaveProfileToMem (iprof, data, &bytesNeeded);
const uint8_t *p = &data[128]; // skip 128 byte header const uint8_t *p = &data[128]; // skip 128 byte header
uint32_t tag_count; uint32_t tag_count;
memcpy(&tag_count, p, 4); memcpy (&tag_count, p, 4);
p += 4; p += 4;
tag_count = ntohl(tag_count); tag_count = ntohl (tag_count);
struct icctag { struct icctag {
uint32_t sig; uint32_t sig;
@@ -220,10 +230,10 @@ cmsHPROFILE ICCStore::makeStdGammaProfile (cmsHPROFILE iprof)
int data_size = (gamma_size + 3) & ~3; int data_size = (gamma_size + 3) & ~3;
for (uint32_t i = 0; i < tag_count; i++) { for (uint32_t i = 0; i < tag_count; i++) {
memcpy(&tags[i], p, 12); memcpy (&tags[i], p, 12);
tags[i].sig = ntohl(tags[i].sig); tags[i].sig = ntohl (tags[i].sig);
tags[i].offset = ntohl(tags[i].offset); tags[i].offset = ntohl (tags[i].offset);
tags[i].size = ntohl(tags[i].size); tags[i].size = ntohl (tags[i].size);
p += 12; p += 12;
if (tags[i].sig != 0x62545243 && // bTRC if (tags[i].sig != 0x62545243 && // bTRC
@@ -236,16 +246,16 @@ cmsHPROFILE ICCStore::makeStdGammaProfile (cmsHPROFILE iprof)
uint32_t sz = 128 + 4 + tag_count * 12 + data_size; uint32_t sz = 128 + 4 + tag_count * 12 + data_size;
uint8_t *nd = new uint8_t[sz]; uint8_t *nd = new uint8_t[sz];
memset(nd, 0, sz); memset (nd, 0, sz);
memcpy(nd, data, 128 + 4); memcpy (nd, data, 128 + 4);
sz = htonl(sz); sz = htonl (sz);
memcpy(nd, &sz, 4); memcpy (nd, &sz, 4);
uint32_t offset = 128 + 4 + tag_count * 12; uint32_t offset = 128 + 4 + tag_count * 12;
uint32_t gamma_offset = 0; uint32_t gamma_offset = 0;
for (uint32_t i = 0; i < tag_count; i++) { for (uint32_t i = 0; i < tag_count; i++) {
struct icctag tag; struct icctag tag;
tag.sig = htonl(tags[i].sig); tag.sig = htonl (tags[i].sig);
if (tags[i].sig == 0x62545243 || // bTRC if (tags[i].sig == 0x62545243 || // bTRC
tags[i].sig == 0x67545243 || // gTRC tags[i].sig == 0x67545243 || // gTRC
@@ -253,30 +263,30 @@ cmsHPROFILE ICCStore::makeStdGammaProfile (cmsHPROFILE iprof)
tags[i].sig == 0x6B545243) { // kTRC tags[i].sig == 0x6B545243) { // kTRC
if (gamma_offset == 0) { if (gamma_offset == 0) {
gamma_offset = offset; gamma_offset = offset;
uint32_t pcurve[] = { htonl(0x63757276), htonl(0), htonl(gamma_size == 12 ? 0 : 1) }; uint32_t pcurve[] = { htonl (0x63757276), htonl (0), htonl (gamma_size == 12 ? 0 : 1) };
memcpy(&nd[offset], pcurve, 12); memcpy (&nd[offset], pcurve, 12);
if (gamma_size == 14) { if (gamma_size == 14) {
uint16_t gm = htons(gamma); uint16_t gm = htons (gamma);
memcpy(&nd[offset + 12], &gm, 2); memcpy (&nd[offset + 12], &gm, 2);
} }
offset += (gamma_size + 3) & ~3; offset += (gamma_size + 3) & ~3;
} }
tag.offset = htonl(gamma_offset); tag.offset = htonl (gamma_offset);
tag.size = htonl(gamma_size); tag.size = htonl (gamma_size);
} else { } else {
tag.offset = htonl(offset); tag.offset = htonl (offset);
tag.size = htonl(tags[i].size); tag.size = htonl (tags[i].size);
memcpy(&nd[offset], &data[tags[i].offset], tags[i].size); memcpy (&nd[offset], &data[tags[i].offset], tags[i].size);
offset += (tags[i].size + 3) & ~3; offset += (tags[i].size + 3) & ~3;
} }
memcpy(&nd[128 + 4 + i * 12], &tag, 12); memcpy (&nd[128 + 4 + i * 12], &tag, 12);
} }
cmsHPROFILE oprof = cmsOpenProfileFromMem (nd, ntohl(sz)); cmsHPROFILE oprof = cmsOpenProfileFromMem (nd, ntohl (sz));
delete [] nd; delete [] nd;
delete [] data; delete [] data;
return oprof; return oprof;
@@ -294,7 +304,7 @@ ICCStore::ICCStore () :
{ {
//cmsErrorAction (LCMS_ERROR_SHOW); //cmsErrorAction (LCMS_ERROR_SHOW);
int N = sizeof(wpnames) / sizeof(wpnames[0]); int N = sizeof (wpnames) / sizeof (wpnames[0]);
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
wProfiles[wpnames[i]] = createFromMatrix (wprofiles[i]); wProfiles[wpnames[i]] = createFromMatrix (wprofiles[i]);
@@ -355,7 +365,7 @@ cmsHPROFILE ICCStore::workingSpaceGamma (const Glib::ustring& name) const
cmsHPROFILE ICCStore::getProfile (const Glib::ustring& name) const cmsHPROFILE ICCStore::getProfile (const Glib::ustring& name) const
{ {
MyMutex::MyLock lock(mutex_); MyMutex::MyLock lock (mutex_);
const ProfileMap::const_iterator r = fileProfiles.find (name); const ProfileMap::const_iterator r = fileProfiles.find (name);
@@ -368,8 +378,8 @@ cmsHPROFILE ICCStore::getProfile (const Glib::ustring& name) const
const cmsHPROFILE profile = content.toProfile (); const cmsHPROFILE profile = content.toProfile ();
if (profile) { if (profile) {
const_cast<ProfileMap&>(fileProfiles).insert(std::make_pair(name, profile)); const_cast<ProfileMap&> (fileProfiles).insert (std::make_pair (name, profile));
const_cast<ContentMap&>(fileProfileContents).insert(std::make_pair(name, content)); const_cast<ContentMap&> (fileProfileContents).insert (std::make_pair (name, content));
return profile; return profile;
} }
@@ -383,37 +393,40 @@ cmsHPROFILE ICCStore::getStdProfile (const Glib::ustring& name) const
const Glib::ustring nameUpper = name.uppercase (); const Glib::ustring nameUpper = name.uppercase ();
MyMutex::MyLock lock(mutex_); MyMutex::MyLock lock (mutex_);
const ProfileMap::const_iterator r = fileStdProfiles.find (nameUpper); const ProfileMap::const_iterator r = fileStdProfiles.find (nameUpper);
// return profile from store // return profile from store
if (r != fileStdProfiles.end ()) if (r != fileStdProfiles.end ()) {
return r->second; return r->second;
}
// profile is not yet in store // profile is not yet in store
const NameMap::const_iterator f = fileStdProfilesFileNames.find (nameUpper); const NameMap::const_iterator f = fileStdProfilesFileNames.find (nameUpper);
// profile does not exist // profile does not exist
if (f == fileStdProfilesFileNames.end ()) if (f == fileStdProfilesFileNames.end ()) {
return NULL; return NULL;
}
// but there exists one => load it // but there exists one => load it
const ProfileContent content (f->second); const ProfileContent content (f->second);
const cmsHPROFILE profile = content.toProfile (); const cmsHPROFILE profile = content.toProfile ();
if (profile) if (profile) {
const_cast<ProfileMap&>(fileStdProfiles).insert (std::make_pair (f->first, profile)); const_cast<ProfileMap&> (fileStdProfiles).insert (std::make_pair (f->first, profile));
}
// profile is not valid or it is now stored => remove entry from fileStdProfilesFileNames // profile is not valid or it is now stored => remove entry from fileStdProfilesFileNames
const_cast<NameMap&>(fileStdProfilesFileNames).erase (f); const_cast<NameMap&> (fileStdProfilesFileNames).erase (f);
return profile; return profile;
} }
ProfileContent ICCStore::getContent (const Glib::ustring& name) const ProfileContent ICCStore::getContent (const Glib::ustring& name) const
{ {
MyMutex::MyLock lock(mutex_); MyMutex::MyLock lock (mutex_);
const ContentMap::const_iterator r = fileProfileContents.find (name); const ContentMap::const_iterator r = fileProfileContents.find (name);
@@ -445,7 +458,7 @@ std::uint8_t ICCStore::getProofIntents (cmsHPROFILE profile) const
void ICCStore::init (const Glib::ustring& usrICCDir, const Glib::ustring& rtICCDir) void ICCStore::init (const Glib::ustring& usrICCDir, const Glib::ustring& rtICCDir)
{ {
MyMutex::MyLock lock(mutex_); MyMutex::MyLock lock (mutex_);
// RawTherapee's profiles take precedence if a user's profile of the same name exists // RawTherapee's profiles take precedence if a user's profile of the same name exists
profilesDir = Glib::build_filename (rtICCDir, "output"); profilesDir = Glib::build_filename (rtICCDir, "output");
@@ -470,26 +483,27 @@ void ICCStore::findDefaultMonitorProfile ()
#ifdef WIN32 #ifdef WIN32
// Get current main monitor. Could be fine tuned to get the current windows monitor (multi monitor setup), // Get current main monitor. Could be fine tuned to get the current windows monitor (multi monitor setup),
// but problem is that we live in RTEngine with no GUI window to query around // but problem is that we live in RTEngine with no GUI window to query around
HDC hDC = GetDC(NULL); HDC hDC = GetDC (NULL);
if (hDC != NULL) { if (hDC != NULL) {
if (SetICMMode(hDC, ICM_ON)) { if (SetICMMode (hDC, ICM_ON)) {
char profileName[MAX_PATH + 1]; char profileName[MAX_PATH + 1];
DWORD profileLength = MAX_PATH; DWORD profileLength = MAX_PATH;
if (GetICMProfileA(hDC, &profileLength, profileName)) { if (GetICMProfileA (hDC, &profileLength, profileName)) {
defaultMonitorProfile = Glib::ustring(profileName); defaultMonitorProfile = Glib::ustring (profileName);
defaultMonitorProfile = Glib::path_get_basename(defaultMonitorProfile); defaultMonitorProfile = Glib::path_get_basename (defaultMonitorProfile);
size_t pos = defaultMonitorProfile.rfind("."); size_t pos = defaultMonitorProfile.rfind (".");
if (pos != Glib::ustring::npos) { if (pos != Glib::ustring::npos) {
defaultMonitorProfile = defaultMonitorProfile.substr(0, pos); defaultMonitorProfile = defaultMonitorProfile.substr (0, pos);
} }
} }
// might fail if e.g. the monitor has no profile // might fail if e.g. the monitor has no profile
} }
ReleaseDC(NULL, hDC); ReleaseDC (NULL, hDC);
} }
#else #else
@@ -497,11 +511,11 @@ void ICCStore::findDefaultMonitorProfile ()
#endif #endif
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Default monitor profile is: %s\n", defaultMonitorProfile.c_str()); printf ("Default monitor profile is: %s\n", defaultMonitorProfile.c_str());
} }
} }
ProfileContent::ProfileContent (const Glib::ustring& fileName) : data(NULL), length(0) ProfileContent::ProfileContent (const Glib::ustring& fileName) : data (NULL), length (0)
{ {
FILE* f = g_fopen (fileName.c_str (), "rb"); FILE* f = g_fopen (fileName.c_str (), "rb");
@@ -532,16 +546,16 @@ ProfileContent::ProfileContent (const ProfileContent& other)
} }
} }
ProfileContent::ProfileContent (cmsHPROFILE hProfile) : data(NULL), length(0) ProfileContent::ProfileContent (cmsHPROFILE hProfile) : data (NULL), length (0)
{ {
if (hProfile != NULL) { if (hProfile != NULL) {
cmsUInt32Number bytesNeeded = 0; cmsUInt32Number bytesNeeded = 0;
cmsSaveProfileToMem(hProfile, 0, &bytesNeeded); cmsSaveProfileToMem (hProfile, 0, &bytesNeeded);
if (bytesNeeded > 0) { if (bytesNeeded > 0) {
data = new char[bytesNeeded + 1]; data = new char[bytesNeeded + 1];
cmsSaveProfileToMem(hProfile, data, &bytesNeeded); cmsSaveProfileToMem (hProfile, data, &bytesNeeded);
length = (int)bytesNeeded; length = (int)bytesNeeded;
} }
} }
@@ -618,9 +632,9 @@ cmsHPROFILE ICCStore::createFromMatrix (const double matrix[3][3], bool gamma, c
} }
// constructing profile header // constructing profile header
unsigned* oprof = new unsigned [phead[0] / sizeof(unsigned)]; unsigned* oprof = new unsigned [phead[0] / sizeof (unsigned)];
memset (oprof, 0, phead[0]); memset (oprof, 0, phead[0]);
memcpy (oprof, phead, sizeof(phead)); memcpy (oprof, phead, sizeof (phead));
oprof[0] = 132 + 12 * pbody[0]; oprof[0] = 132 + 12 * pbody[0];
@@ -633,14 +647,14 @@ cmsHPROFILE ICCStore::createFromMatrix (const double matrix[3][3], bool gamma, c
oprof[0] += (pbody[i * 3 + 3] + 3) & -4; oprof[0] += (pbody[i * 3 + 3] + 3) & -4;
} }
memcpy (oprof + 32, pbody, sizeof(pbody)); memcpy (oprof + 32, pbody, sizeof (pbody));
// wtpt // wtpt
memcpy ((char *)oprof + pbody[8] + 8, pwhite, sizeof(pwhite)); memcpy ((char *)oprof + pbody[8] + 8, pwhite, sizeof (pwhite));
// r/g/b TRC // r/g/b TRC
for (int i = 4; i < 7; i++) { for (int i = 4; i < 7; i++) {
memcpy ((char *)oprof + pbody[i * 3 + 2], pcurve, sizeof(pcurve)); memcpy ((char *)oprof + pbody[i * 3 + 2], pcurve, sizeof (pcurve));
} }
// r/g/b XYZ // r/g/b XYZ
@@ -654,7 +668,7 @@ cmsHPROFILE ICCStore::createFromMatrix (const double matrix[3][3], bool gamma, c
// convert to network byte order // convert to network byte order
for (unsigned int i = 0; i < phead[0] / 4; i++) { for (unsigned int i = 0; i < phead[0] / 4; i++) {
oprof[i] = htonl(oprof[i]); oprof[i] = htonl (oprof[i]);
} }
// cprt // cprt
@@ -665,7 +679,7 @@ cmsHPROFILE ICCStore::createFromMatrix (const double matrix[3][3], bool gamma, c
strcpy ((char *)oprof + pbody[5] + 12, name.c_str()); strcpy ((char *)oprof + pbody[5] + 12, name.c_str());
cmsHPROFILE p = cmsOpenProfileFromMem (oprof, ntohl(oprof[0])); cmsHPROFILE p = cmsOpenProfileFromMem (oprof, ntohl (oprof[0]));
delete [] oprof; delete [] oprof;
return p; return p;
} }

View File

@@ -45,7 +45,7 @@ void ImProcFunctions::lab2monitorRgb (LabImage* lab, Image8* image)
#pragma omp parallel firstprivate(lab, data, W, H) #pragma omp parallel firstprivate(lab, data, W, H)
#endif #endif
{ {
AlignedBuffer<float> pBuf(3 * lab->W); AlignedBuffer<float> pBuf (3 * lab->W);
float *buffer = pBuf.data; float *buffer = pBuf.data;
#ifdef _OPENMP #ifdef _OPENMP
@@ -70,7 +70,7 @@ void ImProcFunctions::lab2monitorRgb (LabImage* lab, Image8* image)
} }
if (!settings->HistogramWorking && output2monitorTransform && lab2outputTransform) { if (!settings->HistogramWorking && output2monitorTransform && lab2outputTransform) {
AlignedBuffer<float> buf(3 * W); AlignedBuffer<float> buf (3 * W);
cmsDoTransform (lab2outputTransform, buffer, buf.data, W); cmsDoTransform (lab2outputTransform, buffer, buf.data, W);
cmsDoTransform (output2monitorTransform, buf.data, data + ix, W); cmsDoTransform (output2monitorTransform, buf.data, data + ix, W);
} else { } else {
@@ -108,18 +108,18 @@ void ImProcFunctions::lab2monitorRgb (LabImage* lab, Image8* image)
fz = fy - (0.005 * rb[j]) / 327.68; fz = fy - (0.005 * rb[j]) / 327.68;
LL = rL[j] / 327.68; LL = rL[j] / 327.68;
x_ = 65535.0 * Color::f2xyz(fx) * Color::D50x; x_ = 65535.0 * Color::f2xyz (fx) * Color::D50x;
// y_ = 65535.0 * Color::f2xyz(fy); // y_ = 65535.0 * Color::f2xyz(fy);
z_ = 65535.0 * Color::f2xyz(fz) * Color::D50z; z_ = 65535.0 * Color::f2xyz (fz) * Color::D50z;
y_ = (LL > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * LL / Color::kappa; y_ = (LL > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * LL / Color::kappa;
Color::xyz2srgb(x_, y_, z_, R, G, B); Color::xyz2srgb (x_, y_, z_, R, G, B);
/* copy RGB */ /* copy RGB */
//int R1=((int)gamma2curve[(R)]) //int R1=((int)gamma2curve[(R)])
data[ix++] = ((int)Color::gamma2curve[CLIP(R)]) >> 8; data[ix++] = ((int)Color::gamma2curve[CLIP (R)]) >> 8;
data[ix++] = ((int)Color::gamma2curve[CLIP(G)]) >> 8; data[ix++] = ((int)Color::gamma2curve[CLIP (G)]) >> 8;
data[ix++] = ((int)Color::gamma2curve[CLIP(B)]) >> 8; data[ix++] = ((int)Color::gamma2curve[CLIP (B)]) >> 8;
} }
} }
} }
@@ -153,14 +153,14 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
cmsHPROFILE oprofG = oprof; cmsHPROFILE oprofG = oprof;
if (standard_gamma) { if (standard_gamma) {
oprofG = ICCStore::makeStdGammaProfile(oprof); oprofG = ICCStore::makeStdGammaProfile (oprof);
} }
lcmsMutex->lock (); lcmsMutex->lock ();
cmsHPROFILE hLab = cmsCreateLab4Profile(NULL); cmsHPROFILE hLab = cmsCreateLab4Profile (NULL);
cmsHTRANSFORM hTransform = cmsCreateTransform (hLab, TYPE_Lab_DBL, oprofG, TYPE_RGB_8, intent, cmsHTRANSFORM hTransform = cmsCreateTransform (hLab, TYPE_Lab_DBL, oprofG, TYPE_RGB_8, intent,
cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE ); // NOCACHE is important for thread safety cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE ); // NOCACHE is important for thread safety
cmsCloseProfile(hLab); cmsCloseProfile (hLab);
lcmsMutex->unlock (); lcmsMutex->unlock ();
unsigned char *data = image->data; unsigned char *data = image->data;
@@ -170,7 +170,7 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
#pragma omp parallel #pragma omp parallel
#endif #endif
{ {
AlignedBuffer<double> pBuf(3 * cw); AlignedBuffer<double> pBuf (3 * cw);
double *buffer = pBuf.data; double *buffer = pBuf.data;
int condition = cy + ch; int condition = cy + ch;
@@ -195,10 +195,10 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
} }
} // End of parallelization } // End of parallelization
cmsDeleteTransform(hTransform); cmsDeleteTransform (hTransform);
if (oprofG != oprof) { if (oprofG != oprof) {
cmsCloseProfile(oprofG); cmsCloseProfile (oprofG);
} }
} else { } else {
@@ -222,16 +222,16 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
float fz = fy - (0.005 * rb[j]) / 327.68; float fz = fy - (0.005 * rb[j]) / 327.68;
float LL = rL[j] / 327.68; float LL = rL[j] / 327.68;
float x_ = 65535.0 * Color::f2xyz(fx) * Color::D50x; float x_ = 65535.0 * Color::f2xyz (fx) * Color::D50x;
//float y_ = 65535.0 * Color::f2xyz(fy); //float y_ = 65535.0 * Color::f2xyz(fy);
float z_ = 65535.0 * Color::f2xyz(fz) * Color::D50z; float z_ = 65535.0 * Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * LL / Color::kappa; float y_ = (LL > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * LL / Color::kappa;
Color::xyz2rgb(x_, y_, z_, R, G, B, rgb_xyz); Color::xyz2rgb (x_, y_, z_, R, G, B, rgb_xyz);
image->data[ix++] = (int)Color::gamma2curve[CLIP(R)] >> 8; image->data[ix++] = (int)Color::gamma2curve[CLIP (R)] >> 8;
image->data[ix++] = (int)Color::gamma2curve[CLIP(G)] >> 8; image->data[ix++] = (int)Color::gamma2curve[CLIP (G)] >> 8;
image->data[ix++] = (int)Color::gamma2curve[CLIP(B)] >> 8; image->data[ix++] = (int)Color::gamma2curve[CLIP (B)] >> 8;
} }
} }
} }
@@ -272,9 +272,9 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
float* rL = lab->L[i]; float* rL = lab->L[i];
float* ra = lab->a[i]; float* ra = lab->a[i];
float* rb = lab->b[i]; float* rb = lab->b[i];
short* xa = (short*)image->r(i - cy); short* xa = (short*)image->r (i - cy);
short* ya = (short*)image->g(i - cy); short* ya = (short*)image->g (i - cy);
short* za = (short*)image->b(i - cy); short* za = (short*)image->b (i - cy);
for (int j = cx; j < cx + cw; j++) { for (int j = cx; j < cx + cw; j++) {
@@ -283,18 +283,18 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
float fz = fy - (0.005f * rb[j]) / 327.68f; float fz = fy - (0.005f * rb[j]) / 327.68f;
float LL = rL[j] / 327.68f; float LL = rL[j] / 327.68f;
float x_ = 65535.0f * (float) Color::f2xyz(fx) * Color::D50x; float x_ = 65535.0f * (float) Color::f2xyz (fx) * Color::D50x;
//float y_ = 65535.0 * Color::f2xyz(fy); //float y_ = 65535.0 * Color::f2xyz(fy);
float z_ = 65535.0f * (float) Color::f2xyz(fz) * Color::D50z; float z_ = 65535.0f * (float) Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? 65535.0f * fy * fy * fy : 65535.0f * LL / Color::kappa; float y_ = (LL > Color::epskap) ? 65535.0f * fy * fy * fy : 65535.0f * LL / Color::kappa;
xa[j - cx] = CLIP((int) round(x_)); xa[j - cx] = CLIP ((int) round (x_));
ya[j - cx] = CLIP((int) round(y_)); ya[j - cx] = CLIP ((int) round (y_));
za[j - cx] = CLIP((int) round(z_)); za[j - cx] = CLIP ((int) round (z_));
if(bw && y_ < 65535.f ) { //force Bw value and take highlight into account if (bw && y_ < 65535.f ) { //force Bw value and take highlight into account
xa[j - cx] = (int) round(y_ * Color::D50x ); xa[j - cx] = (int) round (y_ * Color::D50x );
za[j - cx] = (int) round(y_ * Color::D50z); za[j - cx] = (int) round (y_ * Color::D50z);
} }
} }
@@ -305,9 +305,9 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_RGB_16, oprof, TYPE_RGB_16, intent, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE); cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_RGB_16, oprof, TYPE_RGB_16, intent, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE);
lcmsMutex->unlock (); lcmsMutex->unlock ();
image->ExecCMSTransform(hTransform); image->ExecCMSTransform (hTransform);
cmsDeleteTransform(hTransform); cmsDeleteTransform (hTransform);
} else { } else {
#pragma omp parallel for if (multiThread) #pragma omp parallel for if (multiThread)
@@ -324,16 +324,16 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int
float fz = fy - (0.005f * rb[j]) / 327.68f; float fz = fy - (0.005f * rb[j]) / 327.68f;
float LL = rL[j] / 327.68f; float LL = rL[j] / 327.68f;
float x_ = 65535.0f * (float) Color::f2xyz(fx) * Color::D50x; float x_ = 65535.0f * (float) Color::f2xyz (fx) * Color::D50x;
//float y_ = 65535.0 * Color::f2xyz(fy); //float y_ = 65535.0 * Color::f2xyz(fy);
float z_ = 65535.0f * (float) Color::f2xyz(fz) * Color::D50z; float z_ = 65535.0f * (float) Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? (float) 65535.0f * fy * fy * fy : 65535.0f * LL / Color::kappa; float y_ = (LL > Color::epskap) ? (float) 65535.0f * fy * fy * fy : 65535.0f * LL / Color::kappa;
Color::xyz2srgb(x_, y_, z_, R, G, B); Color::xyz2srgb (x_, y_, z_, R, G, B);
image->r(i - cy, j - cx) = (int)Color::gamma2curve[CLIP(R)]; image->r (i - cy, j - cx) = (int)Color::gamma2curve[CLIP (R)];
image->g(i - cy, j - cx) = (int)Color::gamma2curve[CLIP(G)]; image->g (i - cy, j - cx) = (int)Color::gamma2curve[CLIP (G)];
image->b(i - cy, j - cx) = (int)Color::gamma2curve[CLIP(B)]; image->b (i - cy, j - cx) = (int)Color::gamma2curve[CLIP (B)];
} }
} }
} }
@@ -441,7 +441,7 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
if (!freegamma) {//if Free gamma not selected if (!freegamma) {//if Free gamma not selected
// gamma : ga0,ga1,ga2,ga3,ga4,ga5 by calcul // gamma : ga0,ga1,ga2,ga3,ga4,ga5 by calcul
if(gam == "BT709_g2.2_s4.5") { if (gam == "BT709_g2.2_s4.5") {
ga0 = 2.22; //BT709 2.2 4.5 - my prefered as D.Coffin ga0 = 2.22; //BT709 2.2 4.5 - my prefered as D.Coffin
ga1 = 0.909995; ga1 = 0.909995;
ga2 = 0.090005; ga2 = 0.090005;
@@ -492,11 +492,11 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
ga5 = 0.0; ga5 = 0.0;
} }
} else { //free gamma selected } else { //free gamma selected
if(slpos == 0) { if (slpos == 0) {
slpos = eps; slpos = eps;
} }
Color::calcGamma(pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // call to calcGamma with selected gamma and slope : return parameters for LCMS2 Color::calcGamma (pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // call to calcGamma with selected gamma and slope : return parameters for LCMS2
ga4 = g_a3 * ts; ga4 = g_a3 * ts;
//printf("g_a0=%f g_a1=%f g_a2=%f g_a3=%f g_a4=%f\n", g_a0,g_a1,g_a2,g_a3,g_a4); //printf("g_a0=%f g_a1=%f g_a2=%f g_a3=%f g_a4=%f\n", g_a0,g_a1,g_a2,g_a3,g_a4);
ga0 = gampos; ga0 = gampos;
@@ -508,7 +508,7 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
} }
if(select_temp == 1) { if (select_temp == 1) {
t50 = 5003; // for Widegamut, Prophoto Best, Beta D50 t50 = 5003; // for Widegamut, Prophoto Best, Beta D50
} else if (select_temp == 2) { } else if (select_temp == 2) {
t50 = 6504; // for sRGB, AdobeRGB, Bruce D65 t50 = 6504; // for sRGB, AdobeRGB, Bruce D65
@@ -529,11 +529,11 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
Parameters[5] = ga5; Parameters[5] = ga5;
Parameters[6] = ga6; Parameters[6] = ga6;
// 7 parameters for smoother curves // 7 parameters for smoother curves
cmsWhitePointFromTemp(&xyD, t50); cmsWhitePointFromTemp (&xyD, t50);
GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve(NULL, 5, Parameters);//5 = more smoother than 4 GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve (NULL, 5, Parameters); //5 = more smoother than 4
cmsHPROFILE oprofdef = cmsCreateRGBProfileTHR(NULL, &xyD, &Primaries, GammaTRC); //oprofdef become Outputprofile cmsHPROFILE oprofdef = cmsCreateRGBProfileTHR (NULL, &xyD, &Primaries, GammaTRC); //oprofdef become Outputprofile
cmsFreeToneCurve(GammaTRC[0]); cmsFreeToneCurve (GammaTRC[0]);
if (oprofdef) { if (oprofdef) {
@@ -543,9 +543,9 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
float* rL = lab->L[i]; float* rL = lab->L[i];
float* ra = lab->a[i]; float* ra = lab->a[i];
float* rb = lab->b[i]; float* rb = lab->b[i];
short* xa = (short*)image->r(i - cy); short* xa = (short*)image->r (i - cy);
short* ya = (short*)image->g(i - cy); short* ya = (short*)image->g (i - cy);
short* za = (short*)image->b(i - cy); short* za = (short*)image->b (i - cy);
for (int j = cx; j < cx + cw; j++) { for (int j = cx; j < cx + cw; j++) {
@@ -554,18 +554,18 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
float fz = fy - (0.005f * rb[j]) / 327.68f; float fz = fy - (0.005f * rb[j]) / 327.68f;
float LL = rL[j] / 327.68f; float LL = rL[j] / 327.68f;
float x_ = 65535.0f * (float)Color::f2xyz(fx) * Color::D50x; float x_ = 65535.0f * (float)Color::f2xyz (fx) * Color::D50x;
// float y_ = 65535.0 * Color::f2xyz(fy); // float y_ = 65535.0 * Color::f2xyz(fy);
float z_ = 65535.0f * (float)Color::f2xyz(fz) * Color::D50z; float z_ = 65535.0f * (float)Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? (float) 65535.0 * fy * fy * fy : 65535.0f * LL / Color::kappa; float y_ = (LL > Color::epskap) ? (float) 65535.0 * fy * fy * fy : 65535.0f * LL / Color::kappa;
xa[j - cx] = CLIP((int) round(x_)) ; xa[j - cx] = CLIP ((int) round (x_)) ;
ya[j - cx] = CLIP((int) round(y_)); ya[j - cx] = CLIP ((int) round (y_));
za[j - cx] = CLIP((int) round(z_)); za[j - cx] = CLIP ((int) round (z_));
if(bw && y_ < 65535.f) { //force Bw value and take highlight into account if (bw && y_ < 65535.f) { //force Bw value and take highlight into account
xa[j - cx] = (int) round(y_ * Color::D50x); xa[j - cx] = (int) round (y_ * Color::D50x);
za[j - cx] = (int) round(y_ * Color::D50z); za[j - cx] = (int) round (y_ * Color::D50z);
} }
} }
@@ -576,8 +576,8 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_RGB_16, oprofdef, TYPE_RGB_16, intent, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE); cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_RGB_16, oprofdef, TYPE_RGB_16, intent, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE);
lcmsMutex->unlock (); lcmsMutex->unlock ();
image->ExecCMSTransform(hTransform); image->ExecCMSTransform (hTransform);
cmsDeleteTransform(hTransform); cmsDeleteTransform (hTransform);
} else { } else {
// //
#pragma omp parallel for if (multiThread) #pragma omp parallel for if (multiThread)
@@ -594,16 +594,16 @@ Image16* ImProcFunctions::lab2rgb16b (LabImage* lab, int cx, int cy, int cw, int
float fz = fy - (0.005f * rb[j]) / 327.68f; float fz = fy - (0.005f * rb[j]) / 327.68f;
float LL = rL[j] / 327.68f; float LL = rL[j] / 327.68f;
float x_ = 65535.0f * (float) Color::f2xyz(fx) * Color::D50x; float x_ = 65535.0f * (float) Color::f2xyz (fx) * Color::D50x;
//float y_ = 65535.0 * Color::f2xyz(fy); //float y_ = 65535.0 * Color::f2xyz(fy);
float z_ = 65535.0f * (float) Color::f2xyz(fz) * Color::D50z; float z_ = 65535.0f * (float) Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? (float) 65535.0 * fy * fy * fy : 65535.0f * LL / Color::kappa; float y_ = (LL > Color::epskap) ? (float) 65535.0 * fy * fy * fy : 65535.0f * LL / Color::kappa;
Color::xyz2srgb(x_, y_, z_, R, G, B); Color::xyz2srgb (x_, y_, z_, R, G, B);
image->r(i - cy, j - cx) = (int)Color::gamma2curve[CLIP(R)]; image->r (i - cy, j - cx) = (int)Color::gamma2curve[CLIP (R)];
image->g(i - cy, j - cx) = (int)Color::gamma2curve[CLIP(G)]; image->g (i - cy, j - cx) = (int)Color::gamma2curve[CLIP (G)];
image->b(i - cy, j - cx) = (int)Color::gamma2curve[CLIP(B)]; image->b (i - cy, j - cx) = (int)Color::gamma2curve[CLIP (B)];
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -60,7 +60,7 @@ Options::Options ()
const char *DefaultLanguage = "English (US)"; const char *DefaultLanguage = "English (US)";
inline bool Options::checkProfilePath(Glib::ustring &path) inline bool Options::checkProfilePath (Glib::ustring &path)
{ {
if (path.empty()) { if (path.empty()) {
return false; return false;
@@ -81,13 +81,13 @@ inline bool Options::checkProfilePath(Glib::ustring &path)
} }
} }
bool Options::checkDirPath(Glib::ustring &path, Glib::ustring errString) bool Options::checkDirPath (Glib::ustring &path, Glib::ustring errString)
{ {
if (Glib::file_test (path, Glib::FILE_TEST_EXISTS) && Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) { if (Glib::file_test (path, Glib::FILE_TEST_EXISTS) && Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
return true; return true;
} else { } else {
if (!errString.empty()) { if (!errString.empty()) {
printf("%s\n", errString.c_str()); printf ("%s\n", errString.c_str());
} }
return false; return false;
@@ -102,22 +102,22 @@ void Options::updatePaths()
userProfilePath = ""; userProfilePath = "";
globalProfilePath = ""; globalProfilePath = "";
if (Glib::path_is_absolute(profilePath)) { if (Glib::path_is_absolute (profilePath)) {
// absolute path // absolute path
if (!checkDirPath (profilePath, "")) { if (!checkDirPath (profilePath, "")) {
g_mkdir_with_parents (profilePath.c_str (), 511); g_mkdir_with_parents (profilePath.c_str (), 511);
if (!checkDirPath (profilePath, "")) { // had problems with mkdir_with_parents return value on OS X, just check dir again if (!checkDirPath (profilePath, "")) { // had problems with mkdir_with_parents return value on OS X, just check dir again
printf("Error: user's profiles' directory \"%s\" creation failed\n", profilePath.c_str()); printf ("Error: user's profiles' directory \"%s\" creation failed\n", profilePath.c_str());
} }
} }
if (checkDirPath (profilePath, "Error: the specified user's profiles' path doesn't point to a directory or doesn't exist!\n")) { if (checkDirPath (profilePath, "Error: the specified user's profiles' path doesn't point to a directory or doesn't exist!\n")) {
if (multiUser) { if (multiUser) {
userProfilePath = profilePath; userProfilePath = profilePath;
tmpPath = Glib::build_filename(argv0, "profiles"); tmpPath = Glib::build_filename (argv0, "profiles");
if(checkDirPath (tmpPath, "Error: the global's profiles' path doesn't point to a directory or doesn't exist!\n")) { if (checkDirPath (tmpPath, "Error: the global's profiles' path doesn't point to a directory or doesn't exist!\n")) {
if (userProfilePath != tmpPath) { if (userProfilePath != tmpPath) {
globalProfilePath = tmpPath; globalProfilePath = tmpPath;
} }
@@ -126,40 +126,40 @@ void Options::updatePaths()
globalProfilePath = profilePath; globalProfilePath = profilePath;
} }
} else { } else {
tmpPath = Glib::build_filename(argv0, "profiles"); tmpPath = Glib::build_filename (argv0, "profiles");
if(checkDirPath (tmpPath, "Error: the global's profiles' path doesn't point to a directory or doesn't exist!\n")) { if (checkDirPath (tmpPath, "Error: the global's profiles' path doesn't point to a directory or doesn't exist!\n")) {
globalProfilePath = tmpPath; globalProfilePath = tmpPath;
} }
} }
} else { } else {
// relative paths // relative paths
if (multiUser) { if (multiUser) {
tmpPath = Glib::build_filename(rtdir, profilePath); tmpPath = Glib::build_filename (rtdir, profilePath);
if (!checkDirPath (tmpPath, "")) { if (!checkDirPath (tmpPath, "")) {
g_mkdir_with_parents (tmpPath.c_str (), 511); g_mkdir_with_parents (tmpPath.c_str (), 511);
if (!checkDirPath (tmpPath, "")) { if (!checkDirPath (tmpPath, "")) {
printf("Error: user's profiles' directory \"%s\" creation failed\n", tmpPath.c_str()); printf ("Error: user's profiles' directory \"%s\" creation failed\n", tmpPath.c_str());
} }
} }
if(checkDirPath (tmpPath, "Error: the specified user's profiles' path doesn't point to a directory!\n")) { if (checkDirPath (tmpPath, "Error: the specified user's profiles' path doesn't point to a directory!\n")) {
userProfilePath = tmpPath; userProfilePath = tmpPath;
} }
tmpPath = Glib::build_filename(argv0, "profiles"); tmpPath = Glib::build_filename (argv0, "profiles");
if(checkDirPath (tmpPath, "Error: the specified user's profiles' path doesn't point to a directory or doesn't exist!\n")) { if (checkDirPath (tmpPath, "Error: the specified user's profiles' path doesn't point to a directory or doesn't exist!\n")) {
globalProfilePath = tmpPath; globalProfilePath = tmpPath;
} }
} else { } else {
// common directory // common directory
// directory name set in options is ignored, we use the default directory name // directory name set in options is ignored, we use the default directory name
tmpPath = Glib::build_filename(argv0, "profiles"); tmpPath = Glib::build_filename (argv0, "profiles");
if(checkDirPath (tmpPath, "Error: no global profiles' directory found!\n")) { if (checkDirPath (tmpPath, "Error: no global profiles' directory found!\n")) {
globalProfilePath = tmpPath; globalProfilePath = tmpPath;
} }
} }
@@ -236,7 +236,7 @@ Glib::ustring Options::getPreferredProfilePath()
*@return Send back the absolute path of the given filename or "Neutral" if "Neutral" has been set to profName. Implementor will have *@return Send back the absolute path of the given filename or "Neutral" if "Neutral" has been set to profName. Implementor will have
* to test for this particular value. If the absolute path is invalid (e.g. the file doesn't exist), it will return an empty string. * to test for this particular value. If the absolute path is invalid (e.g. the file doesn't exist), it will return an empty string.
*/ */
Glib::ustring Options::findProfilePath(Glib::ustring &profName) Glib::ustring Options::findProfilePath (Glib::ustring &profName)
{ {
if (profName.empty()) { if (profName.empty()) {
return ""; return "";
@@ -246,41 +246,41 @@ Glib::ustring Options::findProfilePath(Glib::ustring &profName)
return profName; return profName;
} }
Glib::ustring p = profName.substr(0, 4); Glib::ustring p = profName.substr (0, 4);
if (p == "${U}") { if (p == "${U}") {
// the path starts by the User virtual path // the path starts by the User virtual path
p = getUserProfilePath(); p = getUserProfilePath();
Glib::ustring fullPath = Glib::build_filename(p, profName.substr(5) + paramFileExtension); Glib::ustring fullPath = Glib::build_filename (p, profName.substr (5) + paramFileExtension);
if (!p.empty() && Glib::file_test (fullPath, Glib::FILE_TEST_EXISTS)) { if (!p.empty() && Glib::file_test (fullPath, Glib::FILE_TEST_EXISTS)) {
return Glib::path_get_dirname(fullPath); return Glib::path_get_dirname (fullPath);
} }
} else if (p == "${G}") { } else if (p == "${G}") {
// the path starts by the User virtual path // the path starts by the User virtual path
p = getGlobalProfilePath(); p = getGlobalProfilePath();
Glib::ustring fullPath = Glib::build_filename(p, profName.substr(5) + paramFileExtension); Glib::ustring fullPath = Glib::build_filename (p, profName.substr (5) + paramFileExtension);
if (!p.empty() && Glib::file_test (fullPath, Glib::FILE_TEST_EXISTS)) { if (!p.empty() && Glib::file_test (fullPath, Glib::FILE_TEST_EXISTS)) {
return Glib::path_get_dirname(fullPath); return Glib::path_get_dirname (fullPath);
} }
} else { } else {
// compatibility case -> convert the path to the new format // compatibility case -> convert the path to the new format
p = getUserProfilePath(); p = getUserProfilePath();
Glib::ustring fullPath = Glib::build_filename(p, profName + paramFileExtension); Glib::ustring fullPath = Glib::build_filename (p, profName + paramFileExtension);
if (!p.empty() && Glib::file_test (fullPath, Glib::FILE_TEST_EXISTS)) { if (!p.empty() && Glib::file_test (fullPath, Glib::FILE_TEST_EXISTS)) {
// update the profile path // update the profile path
profName = Glib::build_filename("${U}", profName); profName = Glib::build_filename ("${U}", profName);
return Glib::path_get_dirname(fullPath); return Glib::path_get_dirname (fullPath);
} }
p = getGlobalProfilePath(); p = getGlobalProfilePath();
fullPath = Glib::build_filename(p, profName + paramFileExtension); fullPath = Glib::build_filename (p, profName + paramFileExtension);
if (!p.empty() && Glib::file_test (fullPath, Glib::FILE_TEST_EXISTS)) { if (!p.empty() && Glib::file_test (fullPath, Glib::FILE_TEST_EXISTS)) {
profName = Glib::build_filename("${G}", profName); profName = Glib::build_filename ("${G}", profName);
return Glib::path_get_dirname(fullPath); return Glib::path_get_dirname (fullPath);
} }
} }
@@ -609,10 +609,10 @@ void Options::setDefaults ()
rtSettings.darkFramesPath = ""; rtSettings.darkFramesPath = "";
rtSettings.flatFieldsPath = ""; rtSettings.flatFieldsPath = "";
#ifdef WIN32 #ifdef WIN32
const gchar* sysRoot = g_getenv("SystemRoot"); // Returns e.g. "c:\Windows" const gchar* sysRoot = g_getenv ("SystemRoot"); // Returns e.g. "c:\Windows"
if (sysRoot != NULL) { if (sysRoot != NULL) {
rtSettings.iccDirectory = Glib::ustring(sysRoot) + Glib::ustring("\\System32\\spool\\drivers\\color"); rtSettings.iccDirectory = Glib::ustring (sysRoot) + Glib::ustring ("\\System32\\spool\\drivers\\color");
} else { } else {
rtSettings.iccDirectory = "C:\\WINDOWS\\System32\\spool\\drivers\\color"; rtSettings.iccDirectory = "C:\\WINDOWS\\System32\\spool\\drivers\\color";
} }
@@ -715,17 +715,17 @@ void Options::filterOutParsedExtensions ()
for (unsigned int i = 0; i < parseExtensions.size(); i++) for (unsigned int i = 0; i < parseExtensions.size(); i++)
if (parseExtensionsEnabled[i]) { if (parseExtensionsEnabled[i]) {
parsedExtensions.push_back(parseExtensions[i].lowercase()); parsedExtensions.push_back (parseExtensions[i].lowercase());
} }
} }
int Options::readFromFile (Glib::ustring fname) int Options::readFromFile (Glib::ustring fname)
{ {
setlocale(LC_NUMERIC, "C"); // to set decimal point to "." setlocale (LC_NUMERIC, "C"); // to set decimal point to "."
Glib::KeyFile keyFile; Glib::KeyFile keyFile;
if( !Glib::file_test(fname, Glib::FILE_TEST_EXISTS)) { if ( !Glib::file_test (fname, Glib::FILE_TEST_EXISTS)) {
return 1; return 1;
} }
@@ -797,52 +797,52 @@ int Options::readFromFile (Glib::ustring fname)
useSystemTheme = keyFile.get_boolean ("General", "UseSystemTheme"); useSystemTheme = keyFile.get_boolean ("General", "UseSystemTheme");
} }
if( keyFile.has_key ("General", "DarkFramesPath")) { if ( keyFile.has_key ("General", "DarkFramesPath")) {
rtSettings.darkFramesPath = keyFile.get_string("General", "DarkFramesPath"); rtSettings.darkFramesPath = keyFile.get_string ("General", "DarkFramesPath");
} }
if( keyFile.has_key ("General", "FlatFieldsPath")) { if ( keyFile.has_key ("General", "FlatFieldsPath")) {
rtSettings.flatFieldsPath = keyFile.get_string("General", "FlatFieldsPath"); rtSettings.flatFieldsPath = keyFile.get_string ("General", "FlatFieldsPath");
} }
if( keyFile.has_key ("General", "Verbose")) { if ( keyFile.has_key ("General", "Verbose")) {
rtSettings.verbose = keyFile.get_boolean ( "General", "Verbose"); rtSettings.verbose = keyFile.get_boolean ( "General", "Verbose");
} }
if (keyFile.has_key ("General", "BotLeft")) { if (keyFile.has_key ("General", "BotLeft")) {
rtSettings.bot_left = keyFile.get_double("General", "BotLeft"); rtSettings.bot_left = keyFile.get_double ("General", "BotLeft");
} }
if (keyFile.has_key ("General", "TopLeft")) { if (keyFile.has_key ("General", "TopLeft")) {
rtSettings.top_left = keyFile.get_double("General", "TopLeft"); rtSettings.top_left = keyFile.get_double ("General", "TopLeft");
} }
if (keyFile.has_key ("General", "TopRight")) { if (keyFile.has_key ("General", "TopRight")) {
rtSettings.top_right = keyFile.get_double("General", "TopRight"); rtSettings.top_right = keyFile.get_double ("General", "TopRight");
} }
if (keyFile.has_key ("General", "BotRight")) { if (keyFile.has_key ("General", "BotRight")) {
rtSettings.bot_right = keyFile.get_double("General", "BotRight"); rtSettings.bot_right = keyFile.get_double ("General", "BotRight");
} }
if (keyFile.has_key ("General", "EDdetec")) { if (keyFile.has_key ("General", "EDdetec")) {
rtSettings.ed_detec = keyFile.get_double("General", "EDdetec"); rtSettings.ed_detec = keyFile.get_double ("General", "EDdetec");
} }
if (keyFile.has_key ("General", "EDdetecStr")) { if (keyFile.has_key ("General", "EDdetecStr")) {
rtSettings.ed_detecStr = keyFile.get_double("General", "EDdetecStr"); rtSettings.ed_detecStr = keyFile.get_double ("General", "EDdetecStr");
} }
if (keyFile.has_key ("General", "EDLow")) { if (keyFile.has_key ("General", "EDLow")) {
rtSettings.ed_low = keyFile.get_double("General", "EDLow"); rtSettings.ed_low = keyFile.get_double ("General", "EDLow");
} }
if (keyFile.has_key ("General", "EDLipinfl")) { if (keyFile.has_key ("General", "EDLipinfl")) {
rtSettings.ed_lipinfl = keyFile.get_double("General", "EDLipinfl"); rtSettings.ed_lipinfl = keyFile.get_double ("General", "EDLipinfl");
} }
if (keyFile.has_key ("General", "EDLipampl")) { if (keyFile.has_key ("General", "EDLipampl")) {
rtSettings.ed_lipampl = keyFile.get_double("General", "EDLipampl"); rtSettings.ed_lipampl = keyFile.get_double ("General", "EDLipampl");
} }
@@ -945,19 +945,19 @@ int Options::readFromFile (Glib::ustring fname)
} }
if (keyFile.has_key ("Output", "AutoSuffix")) { if (keyFile.has_key ("Output", "AutoSuffix")) {
autoSuffix = keyFile.get_boolean("Output", "AutoSuffix"); autoSuffix = keyFile.get_boolean ("Output", "AutoSuffix");
} }
if (keyFile.has_key ("Output", "ForceFormatOpts")) { if (keyFile.has_key ("Output", "ForceFormatOpts")) {
forceFormatOpts = keyFile.get_boolean("Output", "ForceFormatOpts"); forceFormatOpts = keyFile.get_boolean ("Output", "ForceFormatOpts");
} }
if (keyFile.has_key ("Output", "SaveMethodNum")) { if (keyFile.has_key ("Output", "SaveMethodNum")) {
saveMethodNum = keyFile.get_integer("Output", "SaveMethodNum"); saveMethodNum = keyFile.get_integer ("Output", "SaveMethodNum");
} }
if (keyFile.has_key ("Output", "UsePathTemplate")) { if (keyFile.has_key ("Output", "UsePathTemplate")) {
saveUsePathTemplate = keyFile.get_boolean("Output", "UsePathTemplate"); saveUsePathTemplate = keyFile.get_boolean ("Output", "UsePathTemplate");
} }
if (keyFile.has_key ("Output", "LastSaveAsPath")) { if (keyFile.has_key ("Output", "LastSaveAsPath")) {
@@ -965,11 +965,11 @@ int Options::readFromFile (Glib::ustring fname)
} }
if (keyFile.has_key ("Output", "OverwriteOutputFile")) { if (keyFile.has_key ("Output", "OverwriteOutputFile")) {
overwriteOutputFile = keyFile.get_boolean("Output", "OverwriteOutputFile"); overwriteOutputFile = keyFile.get_boolean ("Output", "OverwriteOutputFile");
} }
if (keyFile.has_key ("Output", "TunnelMetaData")) { if (keyFile.has_key ("Output", "TunnelMetaData")) {
tunnelMetaData = keyFile.get_boolean("Output", "TunnelMetaData"); tunnelMetaData = keyFile.get_boolean ("Output", "TunnelMetaData");
} }
} }
@@ -1148,7 +1148,7 @@ int Options::readFromFile (Glib::ustring fname)
maxRecentFolders = keyFile.get_integer ("File Browser", "MaxRecentFolders"); maxRecentFolders = keyFile.get_integer ("File Browser", "MaxRecentFolders");
} }
recentFolders.reserve(maxRecentFolders + 10); // reserve some more than maxRecentFolders, because at runtime it stores more than that recentFolders.reserve (maxRecentFolders + 10); // reserve some more than maxRecentFolders, because at runtime it stores more than that
if (keyFile.has_key ("File Browser", "RecentFolders")) { if (keyFile.has_key ("File Browser", "RecentFolders")) {
recentFolders = keyFile.get_string_list ("File Browser", "RecentFolders"); recentFolders = keyFile.get_string_list ("File Browser", "RecentFolders");
@@ -1174,23 +1174,23 @@ int Options::readFromFile (Glib::ustring fname)
rgbDenoiseThreadLimit = keyFile.get_integer ("Performance", "RgbDenoiseThreadLimit"); rgbDenoiseThreadLimit = keyFile.get_integer ("Performance", "RgbDenoiseThreadLimit");
} }
if( keyFile.has_key ("Performance", "NRauto")) { if ( keyFile.has_key ("Performance", "NRauto")) {
rtSettings.nrauto = keyFile.get_double ("Performance", "NRauto"); rtSettings.nrauto = keyFile.get_double ("Performance", "NRauto");
} }
if( keyFile.has_key ("Performance", "NRautomax")) { if ( keyFile.has_key ("Performance", "NRautomax")) {
rtSettings.nrautomax = keyFile.get_double ("Performance", "NRautomax"); rtSettings.nrautomax = keyFile.get_double ("Performance", "NRautomax");
} }
if( keyFile.has_key ("Performance", "NRhigh")) { if ( keyFile.has_key ("Performance", "NRhigh")) {
rtSettings.nrhigh = keyFile.get_double ("Performance", "NRhigh"); rtSettings.nrhigh = keyFile.get_double ("Performance", "NRhigh");
} }
if(rtSettings.nrhigh == 0.0) { //avoid crash by division by zero in noise reduction if (rtSettings.nrhigh == 0.0) { //avoid crash by division by zero in noise reduction
rtSettings.nrhigh = 0.45; rtSettings.nrhigh = 0.45;
} }
if( keyFile.has_key ("Performance", "NRWavlevel")) { if ( keyFile.has_key ("Performance", "NRWavlevel")) {
rtSettings.nrwavlevel = keyFile.get_integer ("Performance", "NRWavlevel"); rtSettings.nrwavlevel = keyFile.get_integer ("Performance", "NRWavlevel");
} }
@@ -1277,7 +1277,7 @@ int Options::readFromFile (Glib::ustring fname)
} }
if (keyFile.has_key ("GUI", "SortType")) { if (keyFile.has_key ("GUI", "SortType")) {
dirBrowserSortType = static_cast<Gtk::SortType>(keyFile.get_integer ("GUI", "SortType")); dirBrowserSortType = static_cast<Gtk::SortType> (keyFile.get_integer ("GUI", "SortType"));
} }
if (keyFile.has_key ("GUI", "PreferencesWidth")) { if (keyFile.has_key ("GUI", "PreferencesWidth")) {
@@ -1454,111 +1454,111 @@ int Options::readFromFile (Glib::ustring fname)
} }
if (keyFile.has_key ("Color Management", "Intent")) { if (keyFile.has_key ("Color Management", "Intent")) {
rtSettings.monitorIntent = static_cast<rtengine::RenderingIntent>(keyFile.get_integer("Color Management", "Intent")); rtSettings.monitorIntent = static_cast<rtengine::RenderingIntent> (keyFile.get_integer ("Color Management", "Intent"));
} }
if (keyFile.has_key ("Color Management", "CRI")) { if (keyFile.has_key ("Color Management", "CRI")) {
rtSettings.CRI_color = keyFile.get_integer("Color Management", "CRI"); rtSettings.CRI_color = keyFile.get_integer ("Color Management", "CRI");
} }
if (keyFile.has_key ("Color Management", "DenoiseLabgamma")) { if (keyFile.has_key ("Color Management", "DenoiseLabgamma")) {
rtSettings.denoiselabgamma = keyFile.get_integer("Color Management", "DenoiseLabgamma"); rtSettings.denoiselabgamma = keyFile.get_integer ("Color Management", "DenoiseLabgamma");
} }
if (keyFile.has_key ("Color Management", "view")) { if (keyFile.has_key ("Color Management", "view")) {
rtSettings.viewingdevice = keyFile.get_integer("Color Management", "view"); rtSettings.viewingdevice = keyFile.get_integer ("Color Management", "view");
} }
if (keyFile.has_key ("Color Management", "grey")) { if (keyFile.has_key ("Color Management", "grey")) {
rtSettings.viewingdevicegrey = keyFile.get_integer("Color Management", "grey"); rtSettings.viewingdevicegrey = keyFile.get_integer ("Color Management", "grey");
} }
if (keyFile.has_key ("Color Management", "greySc")) { if (keyFile.has_key ("Color Management", "greySc")) {
rtSettings.viewinggreySc = keyFile.get_integer("Color Management", "greySc"); rtSettings.viewinggreySc = keyFile.get_integer ("Color Management", "greySc");
} }
if (keyFile.has_key ("Color Management", "CBDLArtif")) { if (keyFile.has_key ("Color Management", "CBDLArtif")) {
rtSettings.artifact_cbdl = keyFile.get_double("Color Management", "CBDLArtif"); rtSettings.artifact_cbdl = keyFile.get_double ("Color Management", "CBDLArtif");
} }
if (keyFile.has_key ("Color Management", "CBDLlevel0")) { if (keyFile.has_key ("Color Management", "CBDLlevel0")) {
rtSettings.level0_cbdl = keyFile.get_double("Color Management", "CBDLlevel0"); rtSettings.level0_cbdl = keyFile.get_double ("Color Management", "CBDLlevel0");
} }
if (keyFile.has_key ("Color Management", "CBDLlevel123")) { if (keyFile.has_key ("Color Management", "CBDLlevel123")) {
rtSettings.level123_cbdl = keyFile.get_double("Color Management", "CBDLlevel123"); rtSettings.level123_cbdl = keyFile.get_double ("Color Management", "CBDLlevel123");
} }
// if (keyFile.has_key ("Color Management", "Colortoningab")) rtSettings.colortoningab = keyFile.get_double("Color Management", "Colortoningab"); // if (keyFile.has_key ("Color Management", "Colortoningab")) rtSettings.colortoningab = keyFile.get_double("Color Management", "Colortoningab");
// if (keyFile.has_key ("Color Management", "Decaction")) rtSettings.decaction = keyFile.get_double("Color Management", "Decaction"); // if (keyFile.has_key ("Color Management", "Decaction")) rtSettings.decaction = keyFile.get_double("Color Management", "Decaction");
if (keyFile.has_key ("Color Management", "WhiteBalanceSpotSize")) { if (keyFile.has_key ("Color Management", "WhiteBalanceSpotSize")) {
whiteBalanceSpotSize = keyFile.get_integer("Color Management", "WhiteBalanceSpotSize"); whiteBalanceSpotSize = keyFile.get_integer ("Color Management", "WhiteBalanceSpotSize");
} }
if( keyFile.has_key ("Color Management", "GamutICC")) { if ( keyFile.has_key ("Color Management", "GamutICC")) {
rtSettings.gamutICC = keyFile.get_boolean("Color Management", "GamutICC"); rtSettings.gamutICC = keyFile.get_boolean ("Color Management", "GamutICC");
} }
// if( keyFile.has_key ("Color Management", "BWcomplement")) rtSettings.bw_complementary = keyFile.get_boolean("Color Management", "BWcomplement"); // if( keyFile.has_key ("Color Management", "BWcomplement")) rtSettings.bw_complementary = keyFile.get_boolean("Color Management", "BWcomplement");
if( keyFile.has_key ("Color Management", "Ciecamfloat")) { if ( keyFile.has_key ("Color Management", "Ciecamfloat")) {
rtSettings.ciecamfloat = keyFile.get_boolean("Color Management", "Ciecamfloat"); rtSettings.ciecamfloat = keyFile.get_boolean ("Color Management", "Ciecamfloat");
} }
if( keyFile.has_key ("Color Management", "AdobeRGB")) { if ( keyFile.has_key ("Color Management", "AdobeRGB")) {
rtSettings.adobe = keyFile.get_string("Color Management", "AdobeRGB"); rtSettings.adobe = keyFile.get_string ("Color Management", "AdobeRGB");
} }
if( keyFile.has_key ("Color Management", "ProPhoto")) { if ( keyFile.has_key ("Color Management", "ProPhoto")) {
rtSettings.prophoto = keyFile.get_string("Color Management", "ProPhoto"); rtSettings.prophoto = keyFile.get_string ("Color Management", "ProPhoto");
} }
if( keyFile.has_key ("Color Management", "ProPhoto10")) { if ( keyFile.has_key ("Color Management", "ProPhoto10")) {
rtSettings.prophoto10 = keyFile.get_string("Color Management", "ProPhoto10"); rtSettings.prophoto10 = keyFile.get_string ("Color Management", "ProPhoto10");
} }
if( keyFile.has_key ("Color Management", "WideGamut")) { if ( keyFile.has_key ("Color Management", "WideGamut")) {
rtSettings.widegamut = keyFile.get_string("Color Management", "WideGamut"); rtSettings.widegamut = keyFile.get_string ("Color Management", "WideGamut");
} }
if( keyFile.has_key ("Color Management", "sRGB")) { if ( keyFile.has_key ("Color Management", "sRGB")) {
rtSettings.srgb = keyFile.get_string("Color Management", "sRGB"); rtSettings.srgb = keyFile.get_string ("Color Management", "sRGB");
} }
if( keyFile.has_key ("Color Management", "sRGB10")) { if ( keyFile.has_key ("Color Management", "sRGB10")) {
rtSettings.srgb10 = keyFile.get_string("Color Management", "sRGB10"); rtSettings.srgb10 = keyFile.get_string ("Color Management", "sRGB10");
} }
if( keyFile.has_key ("Color Management", "Beta")) { if ( keyFile.has_key ("Color Management", "Beta")) {
rtSettings.beta = keyFile.get_string("Color Management", "Beta"); rtSettings.beta = keyFile.get_string ("Color Management", "Beta");
} }
if( keyFile.has_key ("Color Management", "Best")) { if ( keyFile.has_key ("Color Management", "Best")) {
rtSettings.best = keyFile.get_string("Color Management", "Best"); rtSettings.best = keyFile.get_string ("Color Management", "Best");
} }
if( keyFile.has_key ("Color Management", "Bruce")) { if ( keyFile.has_key ("Color Management", "Bruce")) {
rtSettings.bruce = keyFile.get_string("Color Management", "Bruce"); rtSettings.bruce = keyFile.get_string ("Color Management", "Bruce");
} }
if( keyFile.has_key ("Color Management", "GamutLch")) { if ( keyFile.has_key ("Color Management", "GamutLch")) {
rtSettings.gamutLch = keyFile.get_boolean("Color Management", "GamutLch"); rtSettings.gamutLch = keyFile.get_boolean ("Color Management", "GamutLch");
} }
if( keyFile.has_key ("Color Management", "ProtectRed")) { if ( keyFile.has_key ("Color Management", "ProtectRed")) {
rtSettings.protectred = keyFile.get_integer("Color Management", "ProtectRed"); rtSettings.protectred = keyFile.get_integer ("Color Management", "ProtectRed");
} }
if( keyFile.has_key ("Color Management", "ProtectRedH")) { if ( keyFile.has_key ("Color Management", "ProtectRedH")) {
rtSettings.protectredh = keyFile.get_double("Color Management", "ProtectRedH"); rtSettings.protectredh = keyFile.get_double ("Color Management", "ProtectRedH");
} }
if( keyFile.has_key ("Color Management", "Amountchroma")) { if ( keyFile.has_key ("Color Management", "Amountchroma")) {
rtSettings.amchroma = keyFile.get_integer("Color Management", "Amountchroma"); rtSettings.amchroma = keyFile.get_integer ("Color Management", "Amountchroma");
} }
if( keyFile.has_key ("Color Management", "ClutsDirectory")) { if ( keyFile.has_key ("Color Management", "ClutsDirectory")) {
clutsDir = keyFile.get_string("Color Management", "ClutsDirectory"); clutsDir = keyFile.get_string ("Color Management", "ClutsDirectory");
} }
// if( keyFile.has_key ("Color Management", "Ciebadpixgauss")) rtSettings.ciebadpixgauss = keyFile.get_boolean("Color Management", "Ciebadpixgauss"); // if( keyFile.has_key ("Color Management", "Ciebadpixgauss")) rtSettings.ciebadpixgauss = keyFile.get_boolean("Color Management", "Ciebadpixgauss");
@@ -1706,7 +1706,7 @@ int Options::readFromFile (Glib::ustring fname)
} }
if (keyFile.has_key ("Fast Export", "fastexport_icm_output_intent" )) { if (keyFile.has_key ("Fast Export", "fastexport_icm_output_intent" )) {
fastexport_icm_outputIntent = static_cast<rtengine::RenderingIntent>(keyFile.get_integer ("Fast Export", "fastexport_icm_output_intent" )); fastexport_icm_outputIntent = static_cast<rtengine::RenderingIntent> (keyFile.get_integer ("Fast Export", "fastexport_icm_output_intent" ));
} }
if (keyFile.has_key ("Fast Export", "fastexport_icm_gamma" )) { if (keyFile.has_key ("Fast Export", "fastexport_icm_gamma" )) {
@@ -1743,21 +1743,21 @@ int Options::readFromFile (Glib::ustring fname)
} }
if (keyFile.has_group ("Dialogs")) { if (keyFile.has_group ("Dialogs")) {
safeDirGet(keyFile, "Dialogs", "LastIccDir", lastIccDir); safeDirGet (keyFile, "Dialogs", "LastIccDir", lastIccDir);
safeDirGet(keyFile, "Dialogs", "LastDarkframeDir", lastDarkframeDir); safeDirGet (keyFile, "Dialogs", "LastDarkframeDir", lastDarkframeDir);
safeDirGet(keyFile, "Dialogs", "LastFlatfieldDir", lastFlatfieldDir); safeDirGet (keyFile, "Dialogs", "LastFlatfieldDir", lastFlatfieldDir);
safeDirGet(keyFile, "Dialogs", "LastRgbCurvesDir", lastRgbCurvesDir); safeDirGet (keyFile, "Dialogs", "LastRgbCurvesDir", lastRgbCurvesDir);
safeDirGet(keyFile, "Dialogs", "LastLabCurvesDir", lastLabCurvesDir); safeDirGet (keyFile, "Dialogs", "LastLabCurvesDir", lastLabCurvesDir);
safeDirGet(keyFile, "Dialogs", "LastRetinexDir", lastRetinexDir); safeDirGet (keyFile, "Dialogs", "LastRetinexDir", lastRetinexDir);
safeDirGet(keyFile, "Dialogs", "LastDenoiseCurvesDir", lastDenoiseCurvesDir); safeDirGet (keyFile, "Dialogs", "LastDenoiseCurvesDir", lastDenoiseCurvesDir);
safeDirGet(keyFile, "Dialogs", "LastWaveletCurvesDir", lastWaveletCurvesDir); safeDirGet (keyFile, "Dialogs", "LastWaveletCurvesDir", lastWaveletCurvesDir);
safeDirGet(keyFile, "Dialogs", "LastPFCurvesDir", lastPFCurvesDir); safeDirGet (keyFile, "Dialogs", "LastPFCurvesDir", lastPFCurvesDir);
safeDirGet(keyFile, "Dialogs", "LastHsvCurvesDir", lastHsvCurvesDir); safeDirGet (keyFile, "Dialogs", "LastHsvCurvesDir", lastHsvCurvesDir);
safeDirGet(keyFile, "Dialogs", "LastBWCurvesDir", lastBWCurvesDir); safeDirGet (keyFile, "Dialogs", "LastBWCurvesDir", lastBWCurvesDir);
safeDirGet(keyFile, "Dialogs", "LastToneCurvesDir", lastToneCurvesDir); safeDirGet (keyFile, "Dialogs", "LastToneCurvesDir", lastToneCurvesDir);
safeDirGet(keyFile, "Dialogs", "LastVibranceCurvesDir", lastVibranceCurvesDir); safeDirGet (keyFile, "Dialogs", "LastVibranceCurvesDir", lastVibranceCurvesDir);
safeDirGet(keyFile, "Dialogs", "LastProfilingReferenceDir", lastProfilingReferenceDir); safeDirGet (keyFile, "Dialogs", "LastProfilingReferenceDir", lastProfilingReferenceDir);
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@@ -1769,13 +1769,15 @@ int Options::readFromFile (Glib::ustring fname)
} }
} catch (Glib::Error &err) { } catch (Glib::Error &err) {
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Options::readFromFile / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str()); printf ("Options::readFromFile / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str());
} }
setDefaults (); setDefaults ();
} catch (...) { } catch (...) {
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Options::readFromFile / Unknown exception while trying to load \"%s\"!\n", fname.c_str()); printf ("Options::readFromFile / Unknown exception while trying to load \"%s\"!\n", fname.c_str());
} }
setDefaults (); setDefaults ();
} }
@@ -1783,7 +1785,7 @@ int Options::readFromFile (Glib::ustring fname)
} }
bool Options::safeDirGet(const Glib::KeyFile& keyFile, const Glib::ustring& section, bool Options::safeDirGet (const Glib::KeyFile& keyFile, const Glib::ustring& section,
const Glib::ustring& entryName, Glib::ustring& destination) const Glib::ustring& entryName, Glib::ustring& destination)
{ {
try { try {
@@ -1793,7 +1795,7 @@ bool Options::safeDirGet(const Glib::KeyFile& keyFile, const Glib::ustring& sect
return true; return true;
} }
} catch(Glib::KeyFileError&) {} } catch (Glib::KeyFileError&) {}
return false; return false;
} }
@@ -1887,10 +1889,10 @@ int Options::saveToFile (Glib::ustring fname)
keyFile.set_integer ("File Browser", "MaxRecentFolders", maxRecentFolders); keyFile.set_integer ("File Browser", "MaxRecentFolders", maxRecentFolders);
{ {
std::vector<Glib::ustring> temp; std::vector<Glib::ustring> temp;
temp.reserve(maxRecentFolders); temp.reserve (maxRecentFolders);
for(unsigned int i = 0; i < std::min(recentFolders.size(), maxRecentFolders); i++) { for (unsigned int i = 0; i < std::min (recentFolders.size(), maxRecentFolders); i++) {
temp.push_back(recentFolders[i]); temp.push_back (recentFolders[i]);
} }
keyFile.set_string_list ("File Browser", "RecentFolders", temp); keyFile.set_string_list ("File Browser", "RecentFolders", temp);
@@ -2118,7 +2120,7 @@ int Options::saveToFile (Glib::ustring fname)
if (f == NULL) { if (f == NULL) {
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Options::saveToFile / Error: unable to open file \"%s\" with write access!\n", fname.c_str()); printf ("Options::saveToFile / Error: unable to open file \"%s\" with write access!\n", fname.c_str());
} }
return 1; return 1;
@@ -2137,12 +2139,12 @@ bool Options::load ()
const gchar* path; const gchar* path;
Glib::ustring dPath; Glib::ustring dPath;
path = g_getenv("RT_SETTINGS"); path = g_getenv ("RT_SETTINGS");
if (path != NULL) { if (path != NULL) {
rtdir = Glib::ustring(path); rtdir = Glib::ustring (path);
if (!Glib::path_is_absolute(rtdir)) { if (!Glib::path_is_absolute (rtdir)) {
return false; return false;
} }
} else { } else {
@@ -2150,42 +2152,42 @@ bool Options::load ()
WCHAR pathW[MAX_PATH] = {0}; WCHAR pathW[MAX_PATH] = {0};
char pathA[MAX_PATH]; char pathA[MAX_PATH];
if (SHGetSpecialFolderPathW(NULL, pathW, CSIDL_LOCAL_APPDATA, false)) { if (SHGetSpecialFolderPathW (NULL, pathW, CSIDL_LOCAL_APPDATA, false)) {
WideCharToMultiByte(CP_UTF8, 0, pathW, -1, pathA, MAX_PATH, 0, 0); WideCharToMultiByte (CP_UTF8, 0, pathW, -1, pathA, MAX_PATH, 0, 0);
rtdir = Glib::build_filename(Glib::ustring(pathA), Glib::ustring(CACHEFOLDERNAME)); rtdir = Glib::build_filename (Glib::ustring (pathA), Glib::ustring (CACHEFOLDERNAME));
} }
#else #else
rtdir = Glib::build_filename(Glib::ustring(g_get_user_config_dir ()), Glib::ustring(CACHEFOLDERNAME)); rtdir = Glib::build_filename (Glib::ustring (g_get_user_config_dir ()), Glib::ustring (CACHEFOLDERNAME));
#endif #endif
} }
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Settings directory (rtdir) = %s\n", rtdir.c_str()); printf ("Settings directory (rtdir) = %s\n", rtdir.c_str());
} }
// Set the cache folder in RT's base folder // Set the cache folder in RT's base folder
cacheBaseDir = Glib::build_filename(argv0, "cache"); cacheBaseDir = Glib::build_filename (argv0, "cache");
// Read the global option file (the one located in the application's base folder) // Read the global option file (the one located in the application's base folder)
options.readFromFile (Glib::build_filename(argv0, "options")); options.readFromFile (Glib::build_filename (argv0, "options"));
// Modify the path of the cache folder to the one provided in RT_CACHE environment variable // Modify the path of the cache folder to the one provided in RT_CACHE environment variable
path = g_getenv("RT_CACHE"); path = g_getenv ("RT_CACHE");
if (path != NULL) { if (path != NULL) {
cacheBaseDir = Glib::ustring(path); cacheBaseDir = Glib::ustring (path);
if (!Glib::path_is_absolute(cacheBaseDir)) { if (!Glib::path_is_absolute (cacheBaseDir)) {
return false; return false;
} }
} }
// No environment variable provided, so falling back to the multi user mode, is enabled // No environment variable provided, so falling back to the multi user mode, is enabled
else if (options.multiUser) { else if (options.multiUser) {
#ifdef WIN32 #ifdef WIN32
cacheBaseDir = Glib::build_filename(rtdir, "cache"); cacheBaseDir = Glib::build_filename (rtdir, "cache");
#else #else
cacheBaseDir = Glib::build_filename(Glib::ustring(g_get_user_cache_dir()), Glib::ustring(CACHEFOLDERNAME)); cacheBaseDir = Glib::build_filename (Glib::ustring (g_get_user_cache_dir()), Glib::ustring (CACHEFOLDERNAME));
#endif #endif
} }
@@ -2193,12 +2195,12 @@ bool Options::load ()
if (options.multiUser) { if (options.multiUser) {
// Read the user option file (the one located somewhere in the user's home folder) // Read the user option file (the one located somewhere in the user's home folder)
// Those values supersets those of the global option file // Those values supersets those of the global option file
int r = options.readFromFile (Glib::build_filename(rtdir, "options")); int r = options.readFromFile (Glib::build_filename (rtdir, "options"));
// If the local option file does not exist or is broken, and the local cache folder does not exist, recreate it // If the local option file does not exist or is broken, and the local cache folder does not exist, recreate it
if (r && !g_mkdir_with_parents (rtdir.c_str (), 511)) { if (r && !g_mkdir_with_parents (rtdir.c_str (), 511)) {
// Save the option file // Save the option file
options.saveToFile (Glib::build_filename(rtdir, "options")); options.saveToFile (Glib::build_filename (rtdir, "options"));
} }
#ifdef __APPLE__ #ifdef __APPLE__
@@ -2208,7 +2210,7 @@ bool Options::load ()
} }
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Cache directory (cacheBaseDir) = %s\n", cacheBaseDir.c_str()); printf ("Cache directory (cacheBaseDir) = %s\n", cacheBaseDir.c_str());
} }
// Update profile's path and recreate it if necessary // Update profile's path and recreate it if necessary
@@ -2218,15 +2220,15 @@ bool Options::load ()
if (options.defProfRaw.empty()) { if (options.defProfRaw.empty()) {
options.defProfRaw = DEFPROFILE_INTERNAL; options.defProfRaw = DEFPROFILE_INTERNAL;
} else { } else {
Glib::ustring tmpFName = options.findProfilePath(options.defProfRaw); Glib::ustring tmpFName = options.findProfilePath (options.defProfRaw);
if (!tmpFName.empty()) { if (!tmpFName.empty()) {
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Raws' default profile \"%s\" found\n", options.defProfRaw.c_str()); printf ("Raws' default profile \"%s\" found\n", options.defProfRaw.c_str());
} }
} else { } else {
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Raws' default profile \"%s\" not found or not set -> using Internal values\n", options.defProfRaw.c_str()); printf ("Raws' default profile \"%s\" not found or not set -> using Internal values\n", options.defProfRaw.c_str());
} }
options.defProfRaw = DEFPROFILE_INTERNAL; options.defProfRaw = DEFPROFILE_INTERNAL;
@@ -2237,15 +2239,15 @@ bool Options::load ()
if (options.defProfImg.empty()) { if (options.defProfImg.empty()) {
options.defProfImg = DEFPROFILE_INTERNAL; options.defProfImg = DEFPROFILE_INTERNAL;
} else { } else {
Glib::ustring tmpFName = options.findProfilePath(options.defProfImg); Glib::ustring tmpFName = options.findProfilePath (options.defProfImg);
if (!tmpFName.empty()) { if (!tmpFName.empty()) {
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Images' default profile \"%s\" found\n", options.defProfImg.c_str()); printf ("Images' default profile \"%s\" found\n", options.defProfImg.c_str());
} }
} else { } else {
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
printf("Images' default profile \"%s\" not found or not set -> using Internal values\n", options.defProfImg.c_str()); printf ("Images' default profile \"%s\" not found or not set -> using Internal values\n", options.defProfImg.c_str());
} }
options.defProfImg = DEFPROFILE_INTERNAL; options.defProfImg = DEFPROFILE_INTERNAL;
@@ -2277,10 +2279,10 @@ bool Options::load ()
} }
if (!options.language.empty()) { if (!options.language.empty()) {
std::vector<Glib::ustring> langPortions = Glib::Regex::split_simple(" ", options.language); std::vector<Glib::ustring> langPortions = Glib::Regex::split_simple (" ", options.language);
if (langPortions.size() >= 1) { if (langPortions.size() >= 1) {
languageTranslation = argv0 + "/languages/" + langPortions.at(0); languageTranslation = argv0 + "/languages/" + langPortions.at (0);
} }
if (langPortions.size() >= 2) { if (langPortions.size() >= 2) {
@@ -2288,7 +2290,7 @@ bool Options::load ()
} }
} }
langMgr.load(localeTranslation, new MultiLangMgr(languageTranslation, new MultiLangMgr(defaultTranslation))); langMgr.load (localeTranslation, new MultiLangMgr (languageTranslation, new MultiLangMgr (defaultTranslation)));
rtengine::init (&options.rtSettings, argv0, rtdir); rtengine::init (&options.rtSettings, argv0, rtdir);
@@ -2299,9 +2301,9 @@ void Options::save ()
{ {
if (options.multiUser == false) { if (options.multiUser == false) {
options.saveToFile (Glib::build_filename(argv0, "options")); options.saveToFile (Glib::build_filename (argv0, "options"));
} else { } else {
options.saveToFile (Glib::build_filename(rtdir, "options")); options.saveToFile (Glib::build_filename (rtdir, "options"));
} }
} }
@@ -2311,7 +2313,7 @@ void Options::save ()
bool Options::has_retained_extention (Glib::ustring fname) bool Options::has_retained_extention (Glib::ustring fname)
{ {
Glib::ustring ext = getExtension(fname).lowercase(); Glib::ustring ext = getExtension (fname).lowercase();
if (!ext.empty()) { if (!ext.empty()) {
// there is an extension to the filename // there is an extension to the filename