Recovered automatic monitor profile selection
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <iccmatrices.h>
|
#include <iccmatrices.h>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include <safegtk.h>
|
#include <safegtk.h>
|
||||||
|
#include <options.h>
|
||||||
|
|
||||||
namespace rtengine {
|
namespace rtengine {
|
||||||
|
|
||||||
@@ -50,8 +51,14 @@ std::vector<std::string> ICCStore::getOutputProfiles () {
|
|||||||
Glib::Mutex::Lock lock(mutex_);
|
Glib::Mutex::Lock lock(mutex_);
|
||||||
|
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
for (std::map<std::string, cmsHPROFILE>::iterator i=fileProfiles.begin(); i!=fileProfiles.end(); i++)
|
for (std::map<std::string, cmsHPROFILE>::iterator i=fileProfiles.begin(); i!=fileProfiles.end(); i++){
|
||||||
res.push_back (i->first);
|
std::string name(i->first);
|
||||||
|
std::string::size_type i = name.find_last_of('/');
|
||||||
|
if( i == std::string::npos )
|
||||||
|
i = name.find_last_of('\\');
|
||||||
|
if( i == std::string::npos )
|
||||||
|
res.push_back ( name ); // list only profiles inside selected profiles directory
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +213,32 @@ std::vector<std::string> ICCStore::parseDir (Glib::ustring pdir) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine the first monitor default profile of operating system, if selected
|
||||||
|
void ICCStore::findDefaultMonitorProfile() {
|
||||||
|
defaultMonitorProfile="";
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
// 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
|
||||||
|
HDC hDC=GetDC(NULL);
|
||||||
|
|
||||||
|
if (hDC!=NULL) {
|
||||||
|
if (SetICMMode(hDC, ICM_ON)) {
|
||||||
|
char profileName[MAX_PATH+1]; DWORD profileLength=MAX_PATH;
|
||||||
|
if (GetICMProfileA(hDC,&profileLength,profileName)) defaultMonitorProfile=Glib::ustring(profileName);
|
||||||
|
// might fail if e.g. the monitor has no profile
|
||||||
|
}
|
||||||
|
|
||||||
|
ReleaseDC(NULL,hDC);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// TODO: Add other OS specific code here
|
||||||
|
printf("Automatic Monitor Profile Detection not supported on your OS\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (options.rtSettings.verbose) printf("Default monitor profile is: %s\n", defaultMonitorProfile.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
ProfileContent::ProfileContent (Glib::ustring fileName) {
|
ProfileContent::ProfileContent (Glib::ustring fileName) {
|
||||||
|
|
||||||
data = NULL;
|
data = NULL;
|
||||||
|
@@ -63,6 +63,9 @@ class ICCStore {
|
|||||||
|
|
||||||
static ICCStore* getInstance(void);
|
static ICCStore* getInstance(void);
|
||||||
|
|
||||||
|
Glib::ustring defaultMonitorProfile; // Main monitors standard profile name, from OS
|
||||||
|
void findDefaultMonitorProfile();
|
||||||
|
|
||||||
int numOfWProfiles ();
|
int numOfWProfiles ();
|
||||||
cmsHPROFILE createFromMatrix (const double matrix[3][3], bool gamma=false, Glib::ustring name="");
|
cmsHPROFILE createFromMatrix (const double matrix[3][3], bool gamma=false, Glib::ustring name="");
|
||||||
cmsHPROFILE workingSpace (Glib::ustring name);
|
cmsHPROFILE workingSpace (Glib::ustring name);
|
||||||
|
@@ -156,7 +156,11 @@ void ImProcFunctions::firstAnalysis (Imagefloat* original, const ProcParams* par
|
|||||||
if (monitorTransform)
|
if (monitorTransform)
|
||||||
cmsDeleteTransform (monitorTransform);
|
cmsDeleteTransform (monitorTransform);
|
||||||
monitorTransform = NULL;
|
monitorTransform = NULL;
|
||||||
cmsHPROFILE monitor = iccStore->getProfile ("file:"+settings->monitorProfile);
|
|
||||||
|
Glib::ustring monitorProfile=settings->monitorProfile;
|
||||||
|
if (settings->autoMonitorProfile) monitorProfile=iccStore->defaultMonitorProfile;
|
||||||
|
|
||||||
|
cmsHPROFILE monitor = iccStore->getProfile ("file:"+monitorProfile);
|
||||||
if (monitor) {
|
if (monitor) {
|
||||||
cmsHPROFILE iprof = iccStore->getXYZProfile ();
|
cmsHPROFILE iprof = iccStore->getXYZProfile ();
|
||||||
lcmsMutex->lock ();
|
lcmsMutex->lock ();
|
||||||
|
@@ -36,6 +36,8 @@ int init (const Settings* s) {
|
|||||||
|
|
||||||
settings = s;
|
settings = s;
|
||||||
iccStore->parseDir (s->iccDirectory);
|
iccStore->parseDir (s->iccDirectory);
|
||||||
|
iccStore->findDefaultMonitorProfile();
|
||||||
|
|
||||||
CurveFactory::init ();
|
CurveFactory::init ();
|
||||||
ImProcFunctions::initCache ();
|
ImProcFunctions::initCache ();
|
||||||
Thumbnail::initGamma ();
|
Thumbnail::initGamma ();
|
||||||
|
Reference in New Issue
Block a user