Hi Niklas,

Am Mittwoch, 4. Mai 2016 19:50:41 UTC+2 schrieb Niklas Mischkulnig:
>
> Thank you for your help!
>

Now that it works, one problem remains: currently the active monitor 
profile is only loaded on Windows and Linux, but not on Mac.
To retrieve the monitor profile we need platform specific code. Especially 
for Mac I have not found a good description. 
Nevertheless by combining different pieces I wrote now a first draft for 
the Mac. But I could not test it. It may not even compile (typos, missing 
includes or so).
Could you please test it? (Please update your repository before. I 
committed a first general change (changeset 8deb93c66d5f). The patch is 
build on top of this changeset.)

Thomas

-- 
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
--- 
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/bac16642-6888-4f90-af62-8c6256e51955%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/hugin1/base_wx/wxcms.cpp b/src/hugin1/base_wx/wxcms.cpp
--- a/src/hugin1/base_wx/wxcms.cpp
+++ b/src/hugin1/base_wx/wxcms.cpp
@@ -28,6 +28,12 @@
 #include <X11/Xlib.h>
 #include "hugin_utils/utils.h"
 #endif
+#ifdef __WXMAC__
+#include <ApplicationServices/ApplicationServices.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include "wx/osx/core/cfstring.h"
+#include <wx/osx/private.h>
+#endif
 
 namespace HuginBase
 {
@@ -107,6 +113,83 @@
                     XCloseDisplay(disp);
                 };
             };
+#elif defined __WXMAC__
+            // retrieve monitor profile for Mac
+            typedef struct {
+                CFUUIDRef dispuuid;
+                CFURLRef url;
+            } ColorsyncIteratorData;
+
+            static bool ColorSyncIterateCallback(CFDictionaryRef dict, void *data)
+            {
+                ColorsyncIteratorData *iterData = (ColorsyncIteratorData *)data;
+                CFStringRef str;
+                CFUUIDRef uuid;
+                CFBooleanRef iscur;
+
+                if (!CFDictionaryGetValueIfPresent(dict, kColorSyncDeviceClass, &str))
+                {
+                    std::cout << "wxCMS: kColorSyncDeviceClass failed" << std::endl;
+                    return true;
+                }
+                if (!CFEqual(str, kColorSyncDisplayDeviceClass))
+                {
+                    return true;
+                }
+                if (!CFDictionaryGetValueIfPresent(dict, kColorSyncDeviceID, &uuid))
+                {
+                    std::cout << "wxCMS: kColorSyncDeviceID failed" << std::endl;
+                    return true;
+                }
+                if (!CFEqual(uuid, iterData->dispuuid))
+                {
+                    return true;
+                }
+                if (!CFDictionaryGetValueIfPresent(dict, kColorSyncDeviceProfileIsCurrent, &iscur))
+                {
+                    std::cout << "wxCMS: kColorSyncDeviceProfileIsCurrent failed" << std::endl;
+                    return true;
+                }
+                if (!CFBooleanGetValue(iscur))
+                {
+                    return true;
+                }
+                if (!CFDictionaryGetValueIfPresent(dict, kColorSyncDeviceProfileURL, &(iterData->url)))
+                {
+                    std::cout << "wxCMS: Could not get current profile URL" << std::endl;
+                    return true;
+                }
+                CFRetain(iterData->url);
+                return false;
+            }
+
+            void GetMonitorProfile(wxString& profileName, cmsHPROFILE& profile)
+            {
+                ColorsyncIteratorData data;
+                data.dispuuid = CGDisplayCreateUUIDFromDisplayID(CGMainDisplayID());
+                if (data.dispuuid == NULL)
+                {
+                    std::cout << "wxCMS: CGDisplayCreateUUIDFromDisplayID() failed." << std::endl;
+                    return;
+                }
+                data.url = NULL;
+                ColorSyncIterateDeviceProfiles(ColorSyncIterateCallback, (void *)&data);
+                CFRelease(data.dispuuid);
+
+                CFStringRef urlstr = CFURLCopyFileSystemPath(data.url, kCFURLPOSIXPathStyle);
+                CFRelease(data.url);
+                if (urlstr == NULL)
+                {
+                    std::cout << "wxCMS: Failed to get URL in CFString" << std::endl;
+                }
+                else
+                {
+                    CFRetain(urlstr);
+                    profileName = wxCFStringRef(urlstr).AsString(wxLocale::GetSystemEncoding());
+                    profile = cmsOpenProfileFromFile(profileName.c_str(), "r");
+                    std::cout << "wxCMS: Found profile: " << profileName.c_str() << std::endl;
+                }
+            };
 #else
             // general case, does nothing
             void GetMonitorProfile(wxString& profileName, cmsHPROFILE& profile)

Reply via email to