OCaml 4.14.0 rebuild
[arch-packages.git] / xsane / trunk / 0165-xsane-0.999-lcms2.patch
blob028cfc9dadbb54c16da591a6f6562b6c087f0002
1 From 30af0e2edbf061b71bed9536d826894449f0390d Mon Sep 17 00:00:00 2001
2 From: Nils Philippsen <nils@redhat.com>
3 Date: Mon, 23 Sep 2013 16:11:31 +0200
4 Subject: [PATCH] patch: lcms2
6 Squashed commit of the following:
8 commit f975accf7e1a08438b63580ea848457d373200f5
9 Author: Nils Philippsen <nils@redhat.com>
10 Date: Mon Sep 23 14:53:45 2013 +0200
12 Add support for lcms 2.x.
13 ---
14 configure.in | 22 ++++++++++++++----
15 include/config.h.in | 8 ++++++-
16 src/xsane-preview.c | 6 +++--
17 src/xsane-save.c | 38 ++++++++++++++++++++++++++-----
18 src/xsane-viewer.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++---
19 src/xsane.h | 8 ++++++-
20 6 files changed, 130 insertions(+), 17 deletions(-)
22 Index: trunk/configure.in
23 ===================================================================
24 --- trunk.orig/configure.in
25 +++ trunk/configure.in
26 @@ -130,7 +130,17 @@ if test "${USE_TIFF}" = "yes"; then
29 if test "${USE_LCMS}" = "yes"; then
30 - AC_CHECK_LIB(lcms, cmsOpenProfileFromFile)
31 + AC_SEARCH_LIBS(cmsOpenProfileFromFile, [lcms2 lcms])
32 + if test "${ac_cv_search_cmsOpenProfileFromFile}" != "no"; then
33 + AC_DEFINE(HAVE_LIBLCMS, 1, [Define if LCMS is to be used.])
34 + fi
35 + if test "${ac_cv_search_cmsOpenProfileFromFile}" == "-llcms2"; then
36 + AC_DEFINE(HAVE_LIBLCMS2, 1, [Define if you have liblcms2.])
37 + else
38 + if test "${ac_cv_search_cmsOpenProfileFromFile}" == "-llcms"; then
39 + AC_DEFINE(HAVE_LIBLCMS1, 1, [Define if you have liblcms.])
40 + fi
41 + fi
44 dnl Checks for library functions.
45 @@ -294,10 +304,14 @@ else
46 echo "* - PNG support deactivated *"
49 -if test "${ac_cv_lib_lcms_cmsOpenProfileFromFile}" = "yes"; then
50 - echo "* - LCMS (color management) support activated *"
51 +if test "${ac_cv_search_cmsOpenProfileFromFile}" = "-llcms2"; then
52 + echo "* - LCMS (color management) support activated (lcms2) *"
53 else
54 - echo "* - LCMS (color management) support deactivated *"
55 + if test "${ac_cv_search_cmsOpenProfileFromFile}" = "-llcms"; then
56 + echo "* - LCMS (color management) support activated (lcms) *"
57 + else
58 + echo "* - LCMS (color management) support deactivated *"
59 + fi
62 echo "* *"
63 Index: trunk/include/config.h.in
64 ===================================================================
65 --- trunk.orig/include/config.h.in
66 +++ trunk/include/config.h.in
67 @@ -290,9 +290,15 @@
68 /* Define if you have libtiff. */
69 #undef HAVE_LIBTIFF
71 -/* Define if you have liblcms. */
72 +/* Define if LCMS is to be used. */
73 #undef HAVE_LIBLCMS
75 +/* Define if you have liblcms. */
76 +#undef HAVE_LIBLCMS1
78 +/* Define if you have liblcms2. */
79 +#undef HAVE_LIBLCMS2
81 #ifndef HAVE_STRNCASECMP
82 /* OS/2 needs this */
83 # define strncasecmp(a, b, c) strnicmp(a, b, c)
84 Index: trunk/src/xsane-preview.c
85 ===================================================================
86 --- trunk.orig/src/xsane-preview.c
87 +++ trunk/src/xsane-preview.c
88 @@ -6346,8 +6346,8 @@ int preview_do_color_correction(Preview
89 cmsHPROFILE hOutProfile = NULL;
90 cmsHPROFILE hProofProfile = NULL;
91 cmsHTRANSFORM hTransform = NULL;
92 - DWORD input_format, output_format;
93 - DWORD cms_flags = 0;
94 + cmsUInt32Number input_format, output_format;
95 + cmsUInt32Number cms_flags = 0;
96 int proof = 0;
97 char *cms_proof_icm_profile = NULL;
98 int linesize = 0;
99 @@ -6355,7 +6355,9 @@ int preview_do_color_correction(Preview
101 DBG(DBG_proc, "preview_do_color_correction\n");
103 +#ifdef HAVE_LIBLCMS1
104 cmsErrorAction(LCMS_ERROR_SHOW);
105 +#endif
107 if (preferences.cms_bpc)
109 Index: trunk/src/xsane-save.c
110 ===================================================================
111 --- trunk.orig/src/xsane-save.c
112 +++ trunk/src/xsane-save.c
113 @@ -832,9 +832,9 @@ cmsHTRANSFORM xsane_create_cms_transform
114 cmsHPROFILE hInProfile = NULL;
115 cmsHPROFILE hOutProfile = NULL;
116 cmsHTRANSFORM hTransform = NULL;
117 - DWORD cms_input_format;
118 - DWORD cms_output_format;
119 - DWORD cms_flags = 0;
120 + cmsUInt32Number cms_input_format;
121 + cmsUInt32Number cms_output_format;
122 + cmsUInt32Number cms_flags = 0;
124 if (cms_function == XSANE_CMS_FUNCTION_EMBED_SCANNER_ICM_PROFILE)
126 @@ -843,7 +843,9 @@ cmsHTRANSFORM xsane_create_cms_transform
128 DBG(DBG_info, "Prepare CMS transform\n");
130 +#ifdef HAVE_LIBLCMS1
131 cmsErrorAction(LCMS_ERROR_SHOW);
132 +#endif
134 if (cms_bpc)
136 @@ -890,10 +892,18 @@ cmsHTRANSFORM xsane_create_cms_transform
137 if (image_info->channels == 1) /* == 1 (grayscale) */
139 #if 1 /* xxx oli */
140 +# ifdef HAVE_LIBLCMS2
141 + cmsToneCurve *Gamma = cmsBuildGamma(NULL, 2.2);
142 +# else
143 LPGAMMATABLE Gamma = cmsBuildGamma(256, 2.2);
144 +# endif
146 hOutProfile = cmsCreateGrayProfile(cmsD50_xyY(), Gamma);
147 +# ifdef HAVE_LIBLCMS2
148 + cmsFreeToneCurve(Gamma);
149 +# else
150 cmsFreeGamma(Gamma);
151 +# endif
152 #endif
154 else
155 @@ -2904,7 +2914,11 @@ static int xsane_write_CSA(FILE *outfile
156 return -1;
159 +#ifdef HAVE_LIBLCMS2
160 + n = cmsGetPostScriptCSA(NULL, hProfile, intent, 0, NULL, 0);
161 +#else
162 n = cmsGetPostScriptCSA(hProfile, intent, NULL, 0);
163 +#endif
164 if (n == 0)
166 return -2;
167 @@ -2916,7 +2930,11 @@ static int xsane_write_CSA(FILE *outfile
168 return -3;
171 +#ifdef HAVE_LIBLCMS2
172 + cmsGetPostScriptCSA(NULL, hProfile, intent, 0, buffer, n);
173 +#else
174 cmsGetPostScriptCSA(hProfile, intent, buffer, n);
175 +#endif
176 buffer[n] = 0;
178 fprintf(outfile, "%s", buffer);
179 @@ -2935,7 +2953,7 @@ static int xsane_write_CRD(FILE *outfile
180 cmsHPROFILE hProfile;
181 size_t n;
182 char* buffer;
183 - DWORD flags = cmsFLAGS_NODEFAULTRESOURCEDEF;
184 + cmsUInt32Number flags = cmsFLAGS_NODEFAULTRESOURCEDEF;
186 hProfile = cmsOpenProfileFromFile(output_profile, "r");
187 if (!hProfile)
188 @@ -2948,7 +2966,11 @@ static int xsane_write_CRD(FILE *outfile
189 flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
192 +#ifdef HAVE_LIBLCMS2
193 + n = cmsGetPostScriptCRD(NULL, hProfile, intent, flags, NULL, 0);
194 +#else
195 n = cmsGetPostScriptCRDEx(hProfile, intent, flags, NULL, 0);
196 +#endif
197 if (n == 0)
199 return -2;
200 @@ -2960,7 +2982,11 @@ static int xsane_write_CRD(FILE *outfile
201 return -3;
204 +#ifdef HAVE_LIBLCMS2
205 + cmsGetPostScriptCRD(NULL, hProfile, intent, flags, buffer, n);
206 +#else
207 cmsGetPostScriptCRDEx(hProfile, intent, flags, buffer, n);
208 +#endif
209 buffer[n] = 0;
211 fprintf(outfile, "%s", buffer);
212 @@ -4352,7 +4378,7 @@ static void xsane_jpeg_embed_scanner_icm
214 FILE *icm_profile;
215 size_t size, embed_len;
216 - LPBYTE embed_buffer;
217 + cmsUInt8Number *embed_buffer;
219 DBG(DBG_proc, "xsane_jpeg_embed_scanner_icm_profile(%s)\n", icm_filename);
221 @@ -4366,7 +4392,7 @@ static void xsane_jpeg_embed_scanner_icm
222 size = ftell(icm_profile);
223 fseek(icm_profile, 0, SEEK_SET);
225 - embed_buffer = (LPBYTE) malloc(size + 1);
226 + embed_buffer = (cmsUInt8Number *) malloc(size + 1);
227 if (embed_buffer)
229 embed_len = fread(embed_buffer, 1, size, icm_profile);
230 Index: trunk/src/xsane-viewer.c
231 ===================================================================
232 --- trunk.orig/src/xsane-viewer.c
233 +++ trunk/src/xsane-viewer.c
234 @@ -1795,6 +1795,9 @@ static void xsane_viewer_set_cms_gamut_a
236 Viewer *v = (Viewer *) data;
237 int val;
238 +#ifdef HAVE_LIBLCMS2
239 + cmsUInt16Number alarm_codes[cmsMAXCHANNELS];
240 +#endif
242 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);
243 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);
244 @@ -1811,6 +1814,49 @@ static void xsane_viewer_set_cms_gamut_a
245 v->cms_gamut_alarm_color = val;
246 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(v->cms_gamut_alarm_color_widget[v->cms_gamut_alarm_color]), TRUE);
248 +#ifdef HAVE_LIBLCMS2
249 + switch(v->cms_gamut_alarm_color)
251 + default:
252 + case 0: /* black */
253 + alarm_codes[0] = (cmsUInt16Number) 0;
254 + alarm_codes[1] = (cmsUInt16Number) 0;
255 + alarm_codes[2] = (cmsUInt16Number) 0;
256 + break;
258 + case 1: /* gray */
259 + alarm_codes[0] = (cmsUInt16Number) 128;
260 + alarm_codes[1] = (cmsUInt16Number) 128;
261 + alarm_codes[2] = (cmsUInt16Number) 128;
262 + break;
264 + case 2: /* white */
265 + alarm_codes[0] = (cmsUInt16Number) 255;
266 + alarm_codes[1] = (cmsUInt16Number) 255;
267 + alarm_codes[2] = (cmsUInt16Number) 255;
268 + break;
270 + case 3: /* red */
271 + alarm_codes[0] = (cmsUInt16Number) 255;
272 + alarm_codes[1] = (cmsUInt16Number) 0;
273 + alarm_codes[2] = (cmsUInt16Number) 0;
274 + break;
276 + case 4: /* green */
277 + alarm_codes[0] = (cmsUInt16Number) 0;
278 + alarm_codes[1] = (cmsUInt16Number) 255;
279 + alarm_codes[2] = (cmsUInt16Number) 0;
280 + break;
282 + case 5: /* blue */
283 + alarm_codes[0] = (cmsUInt16Number) 0;
284 + alarm_codes[1] = (cmsUInt16Number) 0;
285 + alarm_codes[2] = (cmsUInt16Number) 255;
286 + break;
289 + cmsSetAlarmCodes(alarm_codes);
290 +#else
291 switch(v->cms_gamut_alarm_color)
293 default:
294 @@ -1838,6 +1884,7 @@ static void xsane_viewer_set_cms_gamut_a
295 cmsSetAlarmCodes(0, 0, 255);
296 break;
298 +#endif
300 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);
301 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);
302 @@ -2172,9 +2219,9 @@ static int xsane_viewer_read_image(Viewe
303 cmsHTRANSFORM hTransform = NULL;
304 int proof = 0;
305 char *cms_proof_icm_profile = NULL;
306 - DWORD cms_input_format;
307 - DWORD cms_output_format;
308 - DWORD cms_flags = 0;
309 + cmsUInt32Number cms_input_format;
310 + cmsUInt32Number cms_output_format;
311 + cmsUInt32Number cms_flags = 0;
312 #endif
314 /* open imagefile */
315 @@ -2203,7 +2250,9 @@ static int xsane_viewer_read_image(Viewe
317 if ((v->enable_color_management) && (v->cms_enable))
319 +#ifdef HAVE_LIBLCMS1
320 cmsErrorAction(LCMS_ERROR_SHOW);
321 +#endif
323 if (v->cms_bpc)
325 @@ -2801,6 +2850,9 @@ Viewer *xsane_viewer_new(char *filename,
326 GtkWidget *scrolled_window;
327 GtkWidget *zoom_option_menu, *zoom_menu, *zoom_menu_item;
328 int i, selection;
329 +#ifdef HAVE_LIBLCMS2
330 + cmsUInt16Number alarm_codes[cmsMAXCHANNELS];
331 +#endif
333 DBG(DBG_proc, "viewer_new(%s)\n", filename);
335 @@ -2830,8 +2882,15 @@ Viewer *xsane_viewer_new(char *filename,
336 v->cms_proofing_intent = INTENT_ABSOLUTE_COLORIMETRIC;
337 v->cms_gamut_check = 0;
338 v->cms_gamut_alarm_color = 3; /* red */
339 +#ifdef HAVE_LIBLCMS2
340 + alarm_codes[0] = (cmsUInt16Number) 255;
341 + alarm_codes[1] = (cmsUInt16Number) 0;
342 + alarm_codes[2] = (cmsUInt16Number) 0;
343 + cmsSetAlarmCodes(alarm_codes);
344 +#else
345 cmsSetAlarmCodes(255, 0, 0);
346 #endif
347 +#endif
348 if (selection_filetype)
350 v->selection_filetype = strdup(selection_filetype);
351 Index: trunk/src/xsane.h
352 ===================================================================
353 --- trunk.orig/src/xsane.h
354 +++ trunk/src/xsane.h
355 @@ -70,7 +70,13 @@
356 #include <gtk/gtk.h>
358 #ifdef HAVE_LIBLCMS
359 -# include "lcms.h"
360 +# ifdef HAVE_LIBLCMS2
361 +# include "lcms2.h"
362 +# else
363 +# include "lcms.h"
364 +typedef BYTE cmsUInt8Number;
365 +typedef DWORD cmsUInt32Number;
366 +# endif
367 #else
368 # define cmsHTRANSFORM void *
369 #endif