]> git.pld-linux.org Git - packages/xsane.git/blame - xsane-0.999-lcms2.patch
keep fedora comments in .patch not .spec
[packages/xsane.git] / xsane-0.999-lcms2.patch
CommitLineData
94120488
ER
1# from Fedora
2# build against lcms 2.x
3# submitted to upstream (Oliver Rauch) via email, 2013-09-23
12d07cfb
AM
4From 30af0e2edbf061b71bed9536d826894449f0390d Mon Sep 17 00:00:00 2001
5From: Nils Philippsen <nils@redhat.com>
6Date: Mon, 23 Sep 2013 16:11:31 +0200
7Subject: [PATCH] patch: lcms2
8
9Squashed commit of the following:
10
11commit f975accf7e1a08438b63580ea848457d373200f5
12Author: Nils Philippsen <nils@redhat.com>
13Date: Mon Sep 23 14:53:45 2013 +0200
14
15 Add support for lcms 2.x.
16---
17 configure.in | 22 ++++++++++++++----
18 include/config.h.in | 8 ++++++-
19 src/xsane-preview.c | 6 +++--
20 src/xsane-save.c | 38 ++++++++++++++++++++++++++-----
21 src/xsane-viewer.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++---
22 src/xsane.h | 8 ++++++-
23 6 files changed, 130 insertions(+), 17 deletions(-)
24
25diff --git a/configure.in b/configure.in
26index df7b114..3659c97 100644
27--- a/configure.in
28+++ b/configure.in
29@@ -130,7 +130,17 @@ if test "${USE_TIFF}" = "yes"; then
30 fi
31
32 if test "${USE_LCMS}" = "yes"; then
33- AC_CHECK_LIB(lcms, cmsOpenProfileFromFile)
34+ AC_SEARCH_LIBS(cmsOpenProfileFromFile, [lcms2 lcms])
35+ if test "${ac_cv_search_cmsOpenProfileFromFile}" != "no"; then
36+ AC_DEFINE(HAVE_LIBLCMS, 1, [Define if LCMS is to be used.])
37+ fi
38+ if test "${ac_cv_search_cmsOpenProfileFromFile}" == "-llcms2"; then
39+ AC_DEFINE(HAVE_LIBLCMS2, 1, [Define if you have liblcms2.])
40+ else
41+ if test "${ac_cv_search_cmsOpenProfileFromFile}" == "-llcms"; then
42+ AC_DEFINE(HAVE_LIBLCMS1, 1, [Define if you have liblcms.])
43+ fi
44+ fi
45 fi
46
47 dnl Checks for library functions.
48@@ -294,10 +304,14 @@ else
49 echo "* - PNG support deactivated *"
50 fi
51
52-if test "${ac_cv_lib_lcms_cmsOpenProfileFromFile}" = "yes"; then
53- echo "* - LCMS (color management) support activated *"
54+if test "${ac_cv_search_cmsOpenProfileFromFile}" = "-llcms2"; then
55+ echo "* - LCMS (color management) support activated (lcms2) *"
56 else
57- echo "* - LCMS (color management) support deactivated *"
58+ if test "${ac_cv_search_cmsOpenProfileFromFile}" = "-llcms"; then
59+ echo "* - LCMS (color management) support activated (lcms) *"
60+ else
61+ echo "* - LCMS (color management) support deactivated *"
62+ fi
63 fi
64
65 echo "* *"
66diff --git a/include/config.h.in b/include/config.h.in
67index ecc9637..f9a3e40 100755
68--- a/include/config.h.in
69+++ b/include/config.h.in
70@@ -290,9 +290,15 @@
71 /* Define if you have libtiff. */
72 #undef HAVE_LIBTIFF
73
74-/* Define if you have liblcms. */
75+/* Define if LCMS is to be used. */
76 #undef HAVE_LIBLCMS
77
78+/* Define if you have liblcms. */
79+#undef HAVE_LIBLCMS1
80+
81+/* Define if you have liblcms2. */
82+#undef HAVE_LIBLCMS2
83+
84 #ifndef HAVE_STRNCASECMP
85 /* OS/2 needs this */
86 # define strncasecmp(a, b, c) strnicmp(a, b, c)
87diff --git a/src/xsane-preview.c b/src/xsane-preview.c
88index 6327ca7..6eaf687 100644
89--- a/src/xsane-preview.c
90+++ b/src/xsane-preview.c
91@@ -6346,8 +6346,8 @@ int preview_do_color_correction(Preview *p)
92 cmsHPROFILE hOutProfile = NULL;
93 cmsHPROFILE hProofProfile = NULL;
94 cmsHTRANSFORM hTransform = NULL;
95- DWORD input_format, output_format;
96- DWORD cms_flags = 0;
97+ cmsUInt32Number input_format, output_format;
98+ cmsUInt32Number cms_flags = 0;
99 int proof = 0;
100 char *cms_proof_icm_profile = NULL;
101 int linesize = 0;
102@@ -6355,7 +6355,9 @@ int preview_do_color_correction(Preview *p)
103
104 DBG(DBG_proc, "preview_do_color_correction\n");
105
106+#ifdef HAVE_LIBLCMS1
107 cmsErrorAction(LCMS_ERROR_SHOW);
108+#endif
109
110 if (preferences.cms_bpc)
111 {
112diff --git a/src/xsane-save.c b/src/xsane-save.c
113index 75e0a63..2d0e44b 100644
114--- a/src/xsane-save.c
115+++ b/src/xsane-save.c
116@@ -832,9 +832,9 @@ cmsHTRANSFORM xsane_create_cms_transform(Image_info *image_info, int cms_functio
117 cmsHPROFILE hInProfile = NULL;
118 cmsHPROFILE hOutProfile = NULL;
119 cmsHTRANSFORM hTransform = NULL;
120- DWORD cms_input_format;
121- DWORD cms_output_format;
122- DWORD cms_flags = 0;
123+ cmsUInt32Number cms_input_format;
124+ cmsUInt32Number cms_output_format;
125+ cmsUInt32Number cms_flags = 0;
126
127 if (cms_function == XSANE_CMS_FUNCTION_EMBED_SCANNER_ICM_PROFILE)
128 {
129@@ -843,7 +843,9 @@ cmsHTRANSFORM xsane_create_cms_transform(Image_info *image_info, int cms_functio
130
131 DBG(DBG_info, "Prepare CMS transform\n");
132
133+#ifdef HAVE_LIBLCMS1
134 cmsErrorAction(LCMS_ERROR_SHOW);
135+#endif
136
137 if (cms_bpc)
138 {
139@@ -890,10 +892,18 @@ cmsHTRANSFORM xsane_create_cms_transform(Image_info *image_info, int cms_functio
140 if (image_info->channels == 1) /* == 1 (grayscale) */
141 {
142 #if 1 /* xxx oli */
143+# ifdef HAVE_LIBLCMS2
144+ cmsToneCurve *Gamma = cmsBuildGamma(NULL, 2.2);
145+# else
146 LPGAMMATABLE Gamma = cmsBuildGamma(256, 2.2);
147+# endif
148
149 hOutProfile = cmsCreateGrayProfile(cmsD50_xyY(), Gamma);
150+# ifdef HAVE_LIBLCMS2
151+ cmsFreeToneCurve(Gamma);
152+# else
153 cmsFreeGamma(Gamma);
154+# endif
155 #endif
156 }
157 else
158@@ -2896,7 +2906,11 @@ static int xsane_write_CSA(FILE *outfile, char *input_profile, int intent)
159 return -1;
160 }
161
162+#ifdef HAVE_LIBLCMS2
163+ n = cmsGetPostScriptCSA(NULL, hProfile, intent, 0, NULL, 0);
164+#else
165 n = cmsGetPostScriptCSA(hProfile, intent, NULL, 0);
166+#endif
167 if (n == 0)
168 {
169 return -2;
170@@ -2908,7 +2922,11 @@ static int xsane_write_CSA(FILE *outfile, char *input_profile, int intent)
171 return -3;
172 }
173
174+#ifdef HAVE_LIBLCMS2
175+ cmsGetPostScriptCSA(NULL, hProfile, intent, 0, buffer, n);
176+#else
177 cmsGetPostScriptCSA(hProfile, intent, buffer, n);
178+#endif
179 buffer[n] = 0;
180
181 fprintf(outfile, "%s", buffer);
182@@ -2927,7 +2945,7 @@ static int xsane_write_CRD(FILE *outfile, char *output_profile, int intent, int
183 cmsHPROFILE hProfile;
184 size_t n;
185 char* buffer;
186- DWORD flags = cmsFLAGS_NODEFAULTRESOURCEDEF;
187+ cmsUInt32Number flags = cmsFLAGS_NODEFAULTRESOURCEDEF;
188
189 hProfile = cmsOpenProfileFromFile(output_profile, "r");
190 if (!hProfile)
191@@ -2940,7 +2958,11 @@ static int xsane_write_CRD(FILE *outfile, char *output_profile, int intent, int
192 flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
193 }
194
195+#ifdef HAVE_LIBLCMS2
196+ n = cmsGetPostScriptCRD(NULL, hProfile, intent, flags, NULL, 0);
197+#else
198 n = cmsGetPostScriptCRDEx(hProfile, intent, flags, NULL, 0);
199+#endif
200 if (n == 0)
201 {
202 return -2;
203@@ -2952,7 +2974,11 @@ static int xsane_write_CRD(FILE *outfile, char *output_profile, int intent, int
204 return -3;
205 }
206
207+#ifdef HAVE_LIBLCMS2
208+ cmsGetPostScriptCRD(NULL, hProfile, intent, flags, buffer, n);
209+#else
210 cmsGetPostScriptCRDEx(hProfile, intent, flags, buffer, n);
211+#endif
212 buffer[n] = 0;
213
214 fprintf(outfile, "%s", buffer);
215@@ -4349,7 +4375,7 @@ static void xsane_jpeg_embed_scanner_icm_profile(j_compress_ptr cinfo_ptr, const
216 {
217 FILE *icm_profile;
218 size_t size, embed_len;
219- LPBYTE embed_buffer;
220+ cmsUInt8Number *embed_buffer;
221
222 DBG(DBG_proc, "xsane_jpeg_embed_scanner_icm_profile(%s)\n", icm_filename);
223
224@@ -4363,7 +4389,7 @@ static void xsane_jpeg_embed_scanner_icm_profile(j_compress_ptr cinfo_ptr, const
225 size = ftell(icm_profile);
226 fseek(icm_profile, 0, SEEK_SET);
227
228- embed_buffer = (LPBYTE) malloc(size + 1);
229+ embed_buffer = (cmsUInt8Number *) malloc(size + 1);
230 if (embed_buffer)
231 {
232 embed_len = fread(embed_buffer, 1, size, icm_profile);
233diff --git a/src/xsane-viewer.c b/src/xsane-viewer.c
234index 69a444d..844c077 100644
235--- a/src/xsane-viewer.c
236+++ b/src/xsane-viewer.c
237@@ -1795,6 +1795,9 @@ static void xsane_viewer_set_cms_gamut_alarm_color_callback(GtkWidget *widget, g
238 {
239 Viewer *v = (Viewer *) data;
240 int val;
241+#ifdef HAVE_LIBLCMS2
242+ cmsUInt16Number alarm_codes[cmsMAXCHANNELS];
243+#endif
244
245 g_signal_handlers_block_by_func(GTK_OBJECT(v->cms_gamut_alarm_color_widget[0]), (GtkSignalFunc) xsane_viewer_set_cms_gamut_alarm_color_callback, v);
246 g_signal_handlers_block_by_func(GTK_OBJECT(v->cms_gamut_alarm_color_widget[1]), (GtkSignalFunc) xsane_viewer_set_cms_gamut_alarm_color_callback, v);
247@@ -1811,6 +1814,49 @@ static void xsane_viewer_set_cms_gamut_alarm_color_callback(GtkWidget *widget, g
248 v->cms_gamut_alarm_color = val;
249 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(v->cms_gamut_alarm_color_widget[v->cms_gamut_alarm_color]), TRUE);
250
251+#ifdef HAVE_LIBLCMS2
252+ switch(v->cms_gamut_alarm_color)
253+ {
254+ default:
255+ case 0: /* black */
256+ alarm_codes[0] = (cmsUInt16Number) 0;
257+ alarm_codes[1] = (cmsUInt16Number) 0;
258+ alarm_codes[2] = (cmsUInt16Number) 0;
259+ break;
260+
261+ case 1: /* gray */
262+ alarm_codes[0] = (cmsUInt16Number) 128;
263+ alarm_codes[1] = (cmsUInt16Number) 128;
264+ alarm_codes[2] = (cmsUInt16Number) 128;
265+ break;
266+
267+ case 2: /* white */
268+ alarm_codes[0] = (cmsUInt16Number) 255;
269+ alarm_codes[1] = (cmsUInt16Number) 255;
270+ alarm_codes[2] = (cmsUInt16Number) 255;
271+ break;
272+
273+ case 3: /* red */
274+ alarm_codes[0] = (cmsUInt16Number) 255;
275+ alarm_codes[1] = (cmsUInt16Number) 0;
276+ alarm_codes[2] = (cmsUInt16Number) 0;
277+ break;
278+
279+ case 4: /* green */
280+ alarm_codes[0] = (cmsUInt16Number) 0;
281+ alarm_codes[1] = (cmsUInt16Number) 255;
282+ alarm_codes[2] = (cmsUInt16Number) 0;
283+ break;
284+
285+ case 5: /* blue */
286+ alarm_codes[0] = (cmsUInt16Number) 0;
287+ alarm_codes[1] = (cmsUInt16Number) 0;
288+ alarm_codes[2] = (cmsUInt16Number) 255;
289+ break;
290+ }
291+
292+ cmsSetAlarmCodes(alarm_codes);
293+#else
294 switch(v->cms_gamut_alarm_color)
295 {
296 default:
297@@ -1838,6 +1884,7 @@ static void xsane_viewer_set_cms_gamut_alarm_color_callback(GtkWidget *widget, g
298 cmsSetAlarmCodes(0, 0, 255);
299 break;
300 }
301+#endif
302
303 g_signal_handlers_unblock_by_func(GTK_OBJECT(v->cms_gamut_alarm_color_widget[0]), (GtkSignalFunc) xsane_viewer_set_cms_gamut_alarm_color_callback, v);
304 g_signal_handlers_unblock_by_func(GTK_OBJECT(v->cms_gamut_alarm_color_widget[1]), (GtkSignalFunc) xsane_viewer_set_cms_gamut_alarm_color_callback, v);
305@@ -2172,9 +2219,9 @@ static int xsane_viewer_read_image(Viewer *v)
306 cmsHTRANSFORM hTransform = NULL;
307 int proof = 0;
308 char *cms_proof_icm_profile = NULL;
309- DWORD cms_input_format;
310- DWORD cms_output_format;
311- DWORD cms_flags = 0;
312+ cmsUInt32Number cms_input_format;
313+ cmsUInt32Number cms_output_format;
314+ cmsUInt32Number cms_flags = 0;
315 #endif
316
317 /* open imagefile */
318@@ -2203,7 +2250,9 @@ static int xsane_viewer_read_image(Viewer *v)
319
320 if ((v->enable_color_management) && (v->cms_enable))
321 {
322+#ifdef HAVE_LIBLCMS1
323 cmsErrorAction(LCMS_ERROR_SHOW);
324+#endif
325
326 if (v->cms_bpc)
327 {
328@@ -2801,6 +2850,9 @@ Viewer *xsane_viewer_new(char *filename, char *selection_filetype, int allow_red
329 GtkWidget *scrolled_window;
330 GtkWidget *zoom_option_menu, *zoom_menu, *zoom_menu_item;
331 int i, selection;
332+#ifdef HAVE_LIBLCMS2
333+ cmsUInt16Number alarm_codes[cmsMAXCHANNELS];
334+#endif
335
336 DBG(DBG_proc, "viewer_new(%s)\n", filename);
337
338@@ -2830,8 +2882,15 @@ Viewer *xsane_viewer_new(char *filename, char *selection_filetype, int allow_red
339 v->cms_proofing_intent = INTENT_ABSOLUTE_COLORIMETRIC;
340 v->cms_gamut_check = 0;
341 v->cms_gamut_alarm_color = 3; /* red */
342+#ifdef HAVE_LIBLCMS2
343+ alarm_codes[0] = (cmsUInt16Number) 255;
344+ alarm_codes[1] = (cmsUInt16Number) 0;
345+ alarm_codes[2] = (cmsUInt16Number) 0;
346+ cmsSetAlarmCodes(alarm_codes);
347+#else
348 cmsSetAlarmCodes(255, 0, 0);
349 #endif
350+#endif
351 if (selection_filetype)
352 {
353 v->selection_filetype = strdup(selection_filetype);
354diff --git a/src/xsane.h b/src/xsane.h
355index 4067d61..adcc0ed 100644
356--- a/src/xsane.h
357+++ b/src/xsane.h
358@@ -70,7 +70,13 @@
359 #include <gtk/gtk.h>
360
361 #ifdef HAVE_LIBLCMS
362-# include "lcms.h"
363+# ifdef HAVE_LIBLCMS2
364+# include "lcms2.h"
365+# else
366+# include "lcms.h"
367+typedef BYTE cmsUInt8Number;
368+typedef DWORD cmsUInt32Number;
369+# endif
370 #else
371 # define cmsHTRANSFORM void *
372 #endif
373--
3741.8.3.1
375
This page took 0.113305 seconds and 4 git commands to generate.