Recovered automatic monitor profile selection

This commit is contained in:
Oliver Duis
2011-04-08 20:09:38 +02:00
parent 323f36b8e0
commit 07110875a1
4 changed files with 45 additions and 3 deletions

View File

@@ -25,6 +25,7 @@
#include <iccmatrices.h>
#include <glib/gstdio.h>
#include <safegtk.h>
#include <options.h>
namespace rtengine {
@@ -50,8 +51,14 @@ std::vector<std::string> ICCStore::getOutputProfiles () {
Glib::Mutex::Lock lock(mutex_);
std::vector<std::string> res;
for (std::map<std::string, cmsHPROFILE>::iterator i=fileProfiles.begin(); i!=fileProfiles.end(); i++)
res.push_back (i->first);
for (std::map<std::string, cmsHPROFILE>::iterator i=fileProfiles.begin(); i!=fileProfiles.end(); i++){
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;
}
@@ -206,6 +213,32 @@ std::vector<std::string> ICCStore::parseDir (Glib::ustring pdir) {
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) {
data = NULL;

View File

@@ -63,6 +63,9 @@ class ICCStore {
static ICCStore* getInstance(void);
Glib::ustring defaultMonitorProfile; // Main monitors standard profile name, from OS
void findDefaultMonitorProfile();
int numOfWProfiles ();
cmsHPROFILE createFromMatrix (const double matrix[3][3], bool gamma=false, Glib::ustring name="");
cmsHPROFILE workingSpace (Glib::ustring name);

View File

@@ -156,7 +156,11 @@ void ImProcFunctions::firstAnalysis (Imagefloat* original, const ProcParams* par
if (monitorTransform)
cmsDeleteTransform (monitorTransform);
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) {
cmsHPROFILE iprof = iccStore->getXYZProfile ();
lcmsMutex->lock ();

View File

@@ -36,6 +36,8 @@ int init (const Settings* s) {
settings = s;
iccStore->parseDir (s->iccDirectory);
iccStore->findDefaultMonitorProfile();
CurveFactory::init ();
ImProcFunctions::initCache ();
Thumbnail::initGamma ();