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