0e4306
From 789b763bff1701ef31bd077ae49671dfe1c82a51 Mon Sep 17 00:00:00 2001
0e4306
From: Nils Philippsen <nils@redhat.com>
0e4306
Date: Wed, 4 Sep 2013 17:13:49 +0200
0e4306
Subject: [PATCH] Add support for LCMS version 2.x.
0e4306
0e4306
---
0e4306
 dcraw.c | 21 ++++++++++++++++++++-
0e4306
 1 file changed, 20 insertions(+), 1 deletion(-)
0e4306
0e4306
diff --git a/dcraw.c b/dcraw.c
0e4306
index 96e3d1f..4b280b5 100644
0e4306
--- a/dcraw.c
0e4306
+++ b/dcraw.c
0e4306
@@ -80,7 +80,13 @@ typedef unsigned long long UINT64;
0e4306
 #include <jpeglib.h>		/* Decode compressed Kodak DC120 photos */
0e4306
 #endif				/* and Adobe Lossy DNGs */
0e4306
 #ifndef NO_LCMS
0e4306
-#include <lcms.h>		/* Support color profiles */
0e4306
+#ifdef USE_LCMS2
0e4306
+#include <lcms2.h>		/* Support color profiles */
0e4306
+#else
0e4306
+#undef USE_LCMS1
0e4306
+#define USE_LCMS1
0e4306
+#include <lcms.h>
0e4306
+#endif
0e4306
 #endif
0e4306
 #ifdef LOCALEDIR
0e4306
 #include <libintl.h>
0e4306
@@ -8581,6 +8587,15 @@ notraw:
0e4306
 }
0e4306
 
0e4306
 #ifndef NO_LCMS
0e4306
+#ifdef USE_LCMS2
0e4306
+static void lcms2_error_show_handler (cmsContext ContextID,
0e4306
+                                      cmsUInt32Number ErrorCode,
0e4306
+                                      const char *Text)
0e4306
+{
0e4306
+  fprintf (stderr, "lcms2: Error #%d; %s\n", ErrorCode, Text);
0e4306
+}
0e4306
+#endif
0e4306
+
0e4306
 void CLASS apply_profile (const char *input, const char *output)
0e4306
 {
0e4306
   char *prof;
0e4306
@@ -8589,7 +8604,11 @@ void CLASS apply_profile (const char *input, const char *output)
0e4306
   FILE *fp;
0e4306
   unsigned size;
0e4306
 
0e4306
+#ifdef USE_LCMS2
0e4306
+  cmsSetLogErrorHandler (lcms2_error_show_handler);
0e4306
+#else
0e4306
   cmsErrorAction (LCMS_ERROR_SHOW);
0e4306
+#endif
0e4306
   if (strcmp (input, "embed"))
0e4306
     hInProfile = cmsOpenProfileFromFile (input, "r");
0e4306
   else if (profile_length) {
0e4306
-- 
0e4306
1.8.3.1
0e4306