Permalink
Browse files

Migration to lcms2

  • Loading branch information...
stefano-k committed Sep 26, 2013
1 parent 144066a commit 94214db85381f246290cfebb61de02aea2a441b3
Showing with 14 additions and 27 deletions.
  1. +2 −2 configure.ac
  2. +3 −3 src/eom-image.c
  3. +1 −1 src/eom-image.h
  4. +3 −5 src/eom-metadata-reader-jpg.c
  5. +3 −5 src/eom-metadata-reader-png.c
  6. +1 −1 src/eom-metadata-reader.h
  7. +1 −10 src/eom-window.c
View
@@ -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"])
View
@@ -58,7 +58,7 @@
#endif
#ifdef HAVE_LCMS
#include <lcms.h>
#include <lcms2.h>
#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;
}
View
@@ -37,7 +37,7 @@
#endif
#ifdef HAVE_LCMS
#include <lcms.h>
#include <lcms2.h>
#endif
#ifdef HAVE_EXEMPI
@@ -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");
@@ -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;
@@ -30,7 +30,7 @@
#include <exempi/xmp.h>
#endif
#if HAVE_LCMS
#include <lcms.h>
#include <lcms2.h>
#endif
G_BEGIN_DECLS
View
@@ -72,7 +72,7 @@
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include <lcms.h>
#include <lcms2.h>
#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, "

1 comment on commit 94214db

@flexiondotorg

This comment has been minimized.

Show comment
Hide comment
@flexiondotorg

flexiondotorg Sep 26, 2013

Member

Nice one Stefano!

Member

flexiondotorg commented on 94214db Sep 26, 2013

Nice one Stefano!

Please sign in to comment.