From 94214db85381f246290cfebb61de02aea2a441b3 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Thu, 26 Sep 2013 10:24:01 +0200 Subject: Migration to lcms2 Closes #25 https://github.com/mate-desktop/mate-image-viewer/issues/25 See https://git.gnome.org/browse/eog/commit/?id=3c3a835 --- configure.ac | 4 ++-- src/eom-image.c | 6 +++--- src/eom-image.h | 2 +- src/eom-metadata-reader-jpg.c | 8 +++----- src/eom-metadata-reader-png.c | 8 +++----- src/eom-metadata-reader.h | 2 +- src/eom-window.c | 11 +---------- 7 files changed, 14 insertions(+), 27 deletions(-) diff --git a/configure.ac b/configure.ac index b88105a..7857154 100644 --- a/configure.ac +++ b/configure.ac @@ -150,11 +150,11 @@ AM_CONDITIONAL([HAVE_EXIF], [test "x$have_exif" = "xyes"]) AC_ARG_WITH([cms], AC_HELP_STRING([--without-cms], [disable colour management support])) have_lcms=no if test x$with_cms != xno; then - PKG_CHECK_MODULES(LCMS, lcms, have_lcms=yes, have_lcms=no) + PKG_CHECK_MODULES(LCMS, lcms2, have_lcms=yes, have_lcms=no) fi if test "x$have_lcms" = "xyes"; then AC_DEFINE(HAVE_LCMS, 1, [Little CMS Support.]) - EOM_MODULES="$EOM_MODULES lcms" + EOM_MODULES="$EOM_MODULES lcms2" fi AM_CONDITIONAL([HAVE_LCMS], [test "x$have_lcms" = "xyes"]) diff --git a/src/eom-image.c b/src/eom-image.c index e3f1c23..989f365 100644 --- a/src/eom-image.c +++ b/src/eom-image.c @@ -58,7 +58,7 @@ #endif #ifdef HAVE_LCMS -#include +#include #ifndef EXIF_TAG_GAMMA #define EXIF_TAG_GAMMA 0xa500 #endif @@ -681,8 +681,8 @@ eom_image_apply_display_profile (EomImage *img, cmsHPROFILE screen) if (screen == NULL || priv->profile == NULL) return; /* TODO: support other colorspaces than RGB */ - if (cmsGetColorSpace (priv->profile) != icSigRgbData || - cmsGetColorSpace (screen) != icSigRgbData) { + if (cmsGetColorSpace (priv->profile) != cmsSigRgbData || + cmsGetColorSpace (screen) != cmsSigRgbData) { eom_debug_message (DEBUG_LCMS, "One or both ICC profiles not in RGB colorspace; not correcting"); return; } diff --git a/src/eom-image.h b/src/eom-image.h index 0640762..5e3fe84 100644 --- a/src/eom-image.h +++ b/src/eom-image.h @@ -37,7 +37,7 @@ #endif #ifdef HAVE_LCMS -#include +#include #endif #ifdef HAVE_EXEMPI diff --git a/src/eom-metadata-reader-jpg.c b/src/eom-metadata-reader-jpg.c index 5d6a79c..9fc79b7 100644 --- a/src/eom-metadata-reader-jpg.c +++ b/src/eom-metadata-reader-jpg.c @@ -513,8 +513,6 @@ eom_metadata_reader_jpg_get_icc_profile (EomMetadataReaderJpg *emr) priv = emr->priv; if (priv->icc_chunk) { - cmsErrorAction (LCMS_ERROR_SHOW); - profile = cmsOpenProfileFromMem(priv->icc_chunk + 14, priv->icc_len - 14); if (profile) { @@ -562,7 +560,7 @@ eom_metadata_reader_jpg_get_icc_profile (EomMetadataReaderJpg *emr) { cmsCIExyY whitepoint; cmsCIExyYTRIPLE primaries; - LPGAMMATABLE gamma[3]; + cmsToneCurve *gamma[3]; double gammaValue; ExifRational r; @@ -619,11 +617,11 @@ eom_metadata_reader_jpg_get_icc_profile (EomMetadataReaderJpg *emr) gammaValue = 2.2; } - gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma (256, gammaValue); + gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma (NULL, gammaValue); profile = cmsCreateRGBProfile (&whitepoint, &primaries, gamma); - cmsFreeGamma(gamma[0]); + cmsFreeToneCurve(gamma[0]); eom_debug_message (DEBUG_LCMS, "JPEG is calibrated"); diff --git a/src/eom-metadata-reader-png.c b/src/eom-metadata-reader-png.c index 242e52a..c475e06 100644 --- a/src/eom-metadata-reader-png.c +++ b/src/eom-metadata-reader-png.c @@ -563,8 +563,6 @@ eom_metadata_reader_png_get_icc_profile (EomMetadataReaderPng *emr) return NULL; } - cmsErrorAction (LCMS_ERROR_SHOW); - profile = cmsOpenProfileFromMem(outbuf, zstr.total_out); inflateEnd (&zstr); g_free (outbuf); @@ -583,7 +581,7 @@ eom_metadata_reader_png_get_icc_profile (EomMetadataReaderPng *emr) if (!profile && priv->cHRM_chunk) { cmsCIExyY whitepoint; cmsCIExyYTRIPLE primaries; - LPGAMMATABLE gamma[3]; + cmsToneCurve *gamma[3]; double gammaValue = 2.2; // 2.2 should be a sane default gamma /* This uglyness extracts the chromacity and whitepoint values @@ -611,11 +609,11 @@ eom_metadata_reader_png_get_icc_profile (EomMetadataReaderPng *emr) if (priv->gAMA_chunk) gammaValue = (double) 1.0/EXTRACT_DOUBLE_UINT_BLOCK_OFFSET (priv->gAMA_chunk, 0, 100000); - gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma (256, gammaValue); + gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma (NULL, gammaValue); profile = cmsCreateRGBProfile (&whitepoint, &primaries, gamma); - cmsFreeGamma(gamma[0]); + cmsFreeToneCurve(gamma[0]); } return profile; diff --git a/src/eom-metadata-reader.h b/src/eom-metadata-reader.h index 5d719a1..ce5dc0c 100644 --- a/src/eom-metadata-reader.h +++ b/src/eom-metadata-reader.h @@ -30,7 +30,7 @@ #include #endif #if HAVE_LCMS -#include +#include #endif G_BEGIN_DECLS diff --git a/src/eom-window.c b/src/eom-window.c index 1c67eff..3ba7259 100644 --- a/src/eom-window.c +++ b/src/eom-window.c @@ -72,7 +72,7 @@ #ifdef GDK_WINDOWING_X11 #include #endif -#include +#include #endif #define EOM_WINDOW_GET_PRIVATE(object) \ @@ -652,17 +652,8 @@ eom_window_get_display_profile (GdkScreen *screen) return NULL; } - /* Make lcms errors non-fatal here, as it is possible - * to load invalid profiles with XICC. - * We don't want lcms to abort EOM in that case. - */ - lcms_error_action = cmsErrorAction (LCMS_ERROR_IGNORE); - profile = cmsOpenProfileFromMem (str, length); - // Restore the previous error setting - cmsErrorAction (lcms_error_action); - if (G_UNLIKELY (profile == NULL)) { eom_debug_message (DEBUG_LCMS, "Invalid display profile, " -- cgit v1.2.1