eog: switch to Python 2.7
[unleashed-userland.git] / components / image / eog / patches / eog-04-lcms2.patch
blob155e00e55ac7545b29627c21902ab0fb7b9c881b
2 Switch to lcms2 for color management
4 Version 2 is listed as "official" external dependency for GNOME and is
5 said to be faster in some cases.
7 configure.ac | 4 ++--
8 src/eog-image.c | 6 +++---
9 src/eog-image.h | 2 +-
10 src/eog-metadata-reader-jpg.c | 8 +++-----
11 src/eog-metadata-reader-png.c | 8 +++-----
12 src/eog-metadata-reader.h | 2 +-
13 src/eog-window.c | 12 +-----------
14 7 files changed, 14 insertions(+), 28 deletions(-)
15 ---
16 diff --git a/configure.ac b/configure.ac
17 index d5a096c..1038ee6 100644
18 --- a/configure.ac
19 +++ b/configure.ac
20 @@ -162,11 +162,11 @@ AM_CONDITIONAL([HAVE_EXIF], [test "x$have_exif" = "xyes"])
21 AC_ARG_WITH([cms], AC_HELP_STRING([--without-cms], [disable colour management support]))
22 have_lcms=no
23 if test x$with_cms != xno; then
24 - PKG_CHECK_MODULES(LCMS, lcms, have_lcms=yes, have_lcms=no)
25 + PKG_CHECK_MODULES(LCMS, lcms2, have_lcms=yes, have_lcms=no)
27 if test "x$have_lcms" = "xyes"; then
28 AC_DEFINE(HAVE_LCMS, 1, [Little CMS Support.])
29 - EOG_MODULES="$EOG_MODULES lcms"
30 + EOG_MODULES="$EOG_MODULES lcms2"
33 AM_CONDITIONAL([HAVE_LCMS], [test "x$have_lcms" = "xyes"])
34 diff --git a/src/eog-image.c b/src/eog-image.c
35 index a4e1bb9..de5b105 100644
36 --- a/src/eog-image.c
37 +++ b/src/eog-image.c
38 @@ -59,7 +59,7 @@
39 #endif
41 #ifdef HAVE_LCMS
42 -#include <lcms.h>
43 +#include <lcms2.h>
44 #ifndef EXIF_TAG_GAMMA
45 #define EXIF_TAG_GAMMA 0xa500
46 #endif
47 @@ -683,8 +683,8 @@ eog_image_apply_display_profile (EogImage *img, cmsHPROFILE screen)
48 if (screen == NULL || priv->profile == NULL) return;
50 /* TODO: support other colorspaces than RGB */
51 - if (cmsGetColorSpace (priv->profile) != icSigRgbData ||
52 - cmsGetColorSpace (screen) != icSigRgbData) {
53 + if (cmsGetColorSpace (priv->profile) != cmsSigRgbData ||
54 + cmsGetColorSpace (screen) != cmsSigRgbData) {
55 eog_debug_message (DEBUG_LCMS, "One or both ICC profiles not in RGB colorspace; not correcting");
56 return;
58 diff --git a/src/eog-image.h b/src/eog-image.h
59 index 4cfef95..092f2dd 100644
60 --- a/src/eog-image.h
61 +++ b/src/eog-image.h
62 @@ -38,7 +38,7 @@
63 #endif
65 #ifdef HAVE_LCMS
66 -#include <lcms.h>
67 +#include <lcms2.h>
68 #endif
70 #ifdef HAVE_EXEMPI
71 diff --git a/src/eog-metadata-reader-jpg.c b/src/eog-metadata-reader-jpg.c
72 index 7df3a56..9598f67 100644
73 --- a/src/eog-metadata-reader-jpg.c
74 +++ b/src/eog-metadata-reader-jpg.c
75 @@ -513,8 +513,6 @@ eog_metadata_reader_jpg_get_icc_profile (EogMetadataReaderJpg *emr)
76 priv = emr->priv;
78 if (priv->icc_chunk) {
79 - cmsErrorAction (LCMS_ERROR_SHOW);
81 profile = cmsOpenProfileFromMem(priv->icc_chunk + 14, priv->icc_len - 14);
83 if (profile) {
84 @@ -562,7 +560,7 @@ eog_metadata_reader_jpg_get_icc_profile (EogMetadataReaderJpg *emr)
86 cmsCIExyY whitepoint;
87 cmsCIExyYTRIPLE primaries;
88 - LPGAMMATABLE gamma[3];
89 + cmsToneCurve *gamma[3];
90 double gammaValue;
91 ExifRational r;
93 @@ -619,11 +617,11 @@ eog_metadata_reader_jpg_get_icc_profile (EogMetadataReaderJpg *emr)
94 gammaValue = 2.2;
97 - gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma (256, gammaValue);
98 + gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma (NULL, gammaValue);
100 profile = cmsCreateRGBProfile (&whitepoint, &primaries, gamma);
102 - cmsFreeGamma(gamma[0]);
103 + cmsFreeToneCurve(gamma[0]);
105 eog_debug_message (DEBUG_LCMS, "JPEG is calibrated");
107 diff --git a/src/eog-metadata-reader-png.c b/src/eog-metadata-reader-png.c
108 index 257462f..ec5994d 100644
109 --- a/src/eog-metadata-reader-png.c
110 +++ b/src/eog-metadata-reader-png.c
111 @@ -563,8 +563,6 @@ eog_metadata_reader_png_get_icc_profile (EogMetadataReaderPng *emr)
112 return NULL;
115 - cmsErrorAction (LCMS_ERROR_SHOW);
117 profile = cmsOpenProfileFromMem(outbuf, zstr.total_out);
118 inflateEnd (&zstr);
119 g_free (outbuf);
120 @@ -583,7 +581,7 @@ eog_metadata_reader_png_get_icc_profile (EogMetadataReaderPng *emr)
121 if (!profile && priv->cHRM_chunk) {
122 cmsCIExyY whitepoint;
123 cmsCIExyYTRIPLE primaries;
124 - LPGAMMATABLE gamma[3];
125 + cmsToneCurve *gamma[3];
126 double gammaValue = 2.2; // 2.2 should be a sane default gamma
128 /* This uglyness extracts the chromacity and whitepoint values
129 @@ -611,11 +609,11 @@ eog_metadata_reader_png_get_icc_profile (EogMetadataReaderPng *emr)
130 if (priv->gAMA_chunk)
131 gammaValue = (double) 1.0/EXTRACT_DOUBLE_UINT_BLOCK_OFFSET (priv->gAMA_chunk, 0, 100000);
133 - gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma (256, gammaValue);
134 + gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma (NULL, gammaValue);
136 profile = cmsCreateRGBProfile (&whitepoint, &primaries, gamma);
138 - cmsFreeGamma(gamma[0]);
139 + cmsFreeToneCurve(gamma[0]);
142 return profile;
143 diff --git a/src/eog-metadata-reader.h b/src/eog-metadata-reader.h
144 index 86652be..81e976b 100644
145 --- a/src/eog-metadata-reader.h
146 +++ b/src/eog-metadata-reader.h
147 @@ -30,7 +30,7 @@
148 #include <exempi/xmp.h>
149 #endif
150 #if HAVE_LCMS
151 -#include <lcms.h>
152 +#include <lcms2.h>
153 #endif
155 G_BEGIN_DECLS
156 diff --git a/src/eog-window.c b/src/eog-window.c
157 index 8815fba..d407cd8 100644
158 --- a/src/eog-window.c
159 +++ b/src/eog-window.c
160 @@ -78,7 +78,7 @@
161 #ifdef GDK_WINDOWING_X11
162 #include <gdk/gdkx.h>
163 #endif
164 -#include <lcms.h>
165 +#include <lcms2.h>
166 #endif
168 #define EOG_WINDOW_GET_PRIVATE(object) \
169 @@ -399,7 +399,6 @@ eog_window_get_display_profile (GdkScreen *screen)
170 int result;
171 cmsHPROFILE *profile;
172 char *atom_name;
173 - int lcms_error_action;
175 dpy = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
177 @@ -446,17 +445,8 @@ eog_window_get_display_profile (GdkScreen *screen)
178 return NULL;
181 - /* Make lcms errors non-fatal here, as it is possible
182 - * to load invalid profiles with XICC.
183 - * We don't want lcms to abort EOG in that case.
184 - */
185 - lcms_error_action = cmsErrorAction (LCMS_ERROR_IGNORE);
187 profile = cmsOpenProfileFromMem (str, length);
189 - // Restore the previous error setting
190 - cmsErrorAction (lcms_error_action);
192 if (G_UNLIKELY (profile == NULL)) {
193 eog_debug_message (DEBUG_LCMS,
194 "Invalid display profile, "