Add support for LCMS2
authorMichal Čihař <mcihar@suse.cz>
Tue, 21 Aug 2012 09:40:19 +0000 (11:40 +0200)
committerMichal Čihař <mcihar@suse.cz>
Tue, 21 Aug 2012 09:40:19 +0000 (11:40 +0200)
Both LCMS1 and LCMS2 are supported.

configure.in
src/color-man.c
src/exif-common.c

index e4512f2..59f88a1 100644 (file)
@@ -290,14 +290,22 @@ AC_ARG_ENABLE([lcms],
     [liblcms=$enableval], [liblcms=auto])
 
 if test "x${liblcms}" != "xno"; then
-  PKG_CHECK_MODULES(LCMS, [lcms >= 1.14],
+  PKG_CHECK_MODULES(LCMS, [lcms2 >= 2.0],
     [
       HAVE_LCMS=yes
       AC_DEFINE(HAVE_LCMS, 1, [define to enable use of color profiles with lcms])
+      AC_DEFINE(HAVE_LCMS2, 1, [lcms2 is used])
     ],
     [
-      HAVE_LCMS=no
-      AC_MSG_WARN([$LCMS_PKG_ERRORS])
+    PKG_CHECK_MODULES(LCMS, [lcms >= 1.14],
+      [
+        HAVE_LCMS=yes
+        AC_DEFINE(HAVE_LCMS, 1, [define to enable use of color profiles with lcms])
+      ],
+      [
+        HAVE_LCMS=no
+        AC_MSG_WARN([$LCMS_PKG_ERRORS])
+      ])
     ])
 else
   HAVE_LCMS=disabled
index be37a2a..1a7118c 100644 (file)
 #ifdef HAVE_LCMS
 /*** color support enabled ***/
 
+#ifdef HAVE_LCMS2
+#include <lcms2.h>
+#else
 #include <lcms.h>
+#endif
 
 
 typedef struct _ColorManCache ColorManCache;
@@ -52,7 +56,9 @@ static void color_man_lib_init(void)
        if (init_done) return;
        init_done = TRUE;
 
+#ifndef HAVE_LCMS2
        cmsErrorAction(LCMS_ERROR_IGNORE);
+#endif
 }
 
 static cmsHPROFILE color_man_create_adobe_comp(void)
@@ -425,7 +431,14 @@ static gchar *color_man_get_profile_name(ColorManProfileType type, cmsHPROFILE p
                case COLOR_PROFILE_FILE:
                        if (profile)
                                {
+#ifdef HAVE_LCMS2
+                               cmsUInt8Number profileID[17];
+                               profileID[16] = '\0';
+                               cmsGetHeaderProfileID(profile, profileID);
+                               return g_strdup(profileID);
+#else
                                return g_strdup(cmsTakeProductName(profile));
+#endif
                                }
                        return g_strdup(_("Custom profile"));
                        break;
index 3b453a7..99d38be 100644 (file)
 #ifdef HAVE_LCMS
 /*** color support enabled ***/
 
-#ifdef HAVE_LCMS_LCMS_H
-  #include <lcms/lcms.h>
+#ifdef HAVE_LCMS2
+#include <lcms2.h>
 #else
-  #include <lcms.h>
+#include <lcms.h>
 #endif
 #endif
 
@@ -413,6 +413,9 @@ static gchar *exif_build_formatted_Resolution(ExifData *exif)
 
 static gchar *exif_build_formatted_ColorProfile(ExifData *exif)
 {
+#ifdef HAVE_LCMS2
+       cmsUInt8Number profileID[17];
+#endif
        const gchar *name = "";
        const gchar *source = "";
        guchar *profile_data;
@@ -452,7 +455,13 @@ static gchar *exif_build_formatted_ColorProfile(ExifData *exif)
                        profile = cmsOpenProfileFromMem(profile_data, profile_len);
                        if (profile)
                                {
+#ifdef HAVE_LCMS2
+                               profileID[16] = '\0';
+                               cmsGetHeaderProfileID(profile, profileID);
+                               name = profileID;
+#else
                                name = cmsTakeProductName(profile);
+#endif
                                cmsCloseProfile(profile);
                                }
                        g_free(profile_data);