Mercurial > geeqie.yaz
annotate src/color-man.c @ 1593:2b2aa3326763
enabled XDG directory layout
author | nadvornik |
---|---|
date | Thu, 07 May 2009 19:34:33 +0000 |
parents | 69f7270b3b27 |
children |
rev | line source |
---|---|
113 | 1 /* |
196 | 2 * Geeqie |
113 | 3 * (C) 2006 John Ellis |
1284 | 4 * Copyright (C) 2008 - 2009 The Geeqie Team |
113 | 5 * |
6 * Author: John Ellis | |
7 * | |
8 * This software is released under the GNU General Public License (GNU GPL). | |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
11 */ | |
12 | |
13 | |
281 | 14 #include "main.h" |
113 | 15 #include "color-man.h" |
16 | |
17 #include "image.h" | |
18 #include "ui_fileops.h" | |
19 | |
20 | |
21 #ifdef HAVE_LCMS | |
22 /*** color support enabled ***/ | |
23 | |
686 | 24 #include <lcms.h> |
113 | 25 |
26 | |
27 typedef struct _ColorManCache ColorManCache; | |
28 struct _ColorManCache { | |
29 cmsHPROFILE profile_in; | |
30 cmsHPROFILE profile_out; | |
31 cmsHTRANSFORM transform; | |
32 | |
33 ColorManProfileType profile_in_type; | |
34 gchar *profile_in_file; | |
35 | |
36 ColorManProfileType profile_out_type; | |
37 gchar *profile_out_file; | |
38 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1284
diff
changeset
|
39 gboolean has_alpha; |
113 | 40 |
41 gint refcount; | |
42 }; | |
43 | |
44 /* pixels to transform per idle call */ | |
45 #define COLOR_MAN_CHUNK_SIZE 81900 | |
46 | |
47 | |
48 static void color_man_lib_init(void) | |
49 { | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1284
diff
changeset
|
50 static gboolean init_done = FALSE; |
113 | 51 |
52 if (init_done) return; | |
53 init_done = TRUE; | |
54 | |
55 cmsErrorAction(LCMS_ERROR_IGNORE); | |
56 } | |
57 | |
609
b690cecbf5b8
Use function(void) instead of function() for declaring functions which
zas_
parents:
507
diff
changeset
|
58 static cmsHPROFILE color_man_create_adobe_comp(void) |
424 | 59 { |
60 /* ClayRGB1998 is AdobeRGB compatible */ | |
61 #include "ClayRGB1998_icc.h" | |
62 return cmsOpenProfileFromMem(ClayRGB1998_icc, ClayRGB1998_icc_len); | |
63 } | |
113 | 64 |
65 /* | |
66 *------------------------------------------------------------------- | |
67 * color transform cache | |
68 *------------------------------------------------------------------- | |
69 */ | |
70 | |
71 static GList *cm_cache_list = NULL; | |
72 | |
73 | |
74 static void color_man_cache_ref(ColorManCache *cc) | |
75 { | |
76 if (!cc) return; | |
77 | |
78 cc->refcount++; | |
79 } | |
80 | |
81 static void color_man_cache_unref(ColorManCache *cc) | |
82 { | |
83 if (!cc) return; | |
84 | |
85 cc->refcount--; | |
86 if (cc->refcount < 1) | |
87 { | |
88 if (cc->transform) cmsDeleteTransform(cc->transform); | |
89 if (cc->profile_in) cmsCloseProfile(cc->profile_in); | |
90 if (cc->profile_out) cmsCloseProfile(cc->profile_out); | |
91 | |
92 g_free(cc->profile_in_file); | |
93 g_free(cc->profile_out_file); | |
94 | |
95 g_free(cc); | |
96 } | |
97 } | |
98 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
99 static cmsHPROFILE color_man_cache_load_profile(ColorManProfileType type, const gchar *file, |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
686
diff
changeset
|
100 guchar *data, guint data_len) |
113 | 101 { |
102 cmsHPROFILE profile = NULL; | |
103 | |
104 switch (type) | |
105 { | |
106 case COLOR_PROFILE_FILE: | |
107 if (file) | |
108 { | |
109 gchar *pathl; | |
110 | |
111 pathl = path_from_utf8(file); | |
112 profile = cmsOpenProfileFromFile(pathl, "r"); | |
113 g_free(pathl); | |
114 } | |
115 break; | |
116 case COLOR_PROFILE_SRGB: | |
117 profile = cmsCreate_sRGBProfile(); | |
118 break; | |
424 | 119 case COLOR_PROFILE_ADOBERGB: |
120 profile = color_man_create_adobe_comp(); | |
121 break; | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
122 case COLOR_PROFILE_MEM: |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
123 if (data) |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
124 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
125 profile = cmsOpenProfileFromMem(data, data_len); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
126 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
127 break; |
113 | 128 case COLOR_PROFILE_NONE: |
129 default: | |
130 break; | |
131 } | |
132 | |
133 return profile; | |
134 } | |
135 | |
136 static ColorManCache *color_man_cache_new(ColorManProfileType in_type, const gchar *in_file, | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
686
diff
changeset
|
137 guchar *in_data, guint in_data_len, |
113 | 138 ColorManProfileType out_type, const gchar *out_file, |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1284
diff
changeset
|
139 gboolean has_alpha) |
113 | 140 { |
141 ColorManCache *cc; | |
142 | |
143 color_man_lib_init(); | |
144 | |
145 cc = g_new0(ColorManCache, 1); | |
146 cc->refcount = 1; | |
147 | |
148 cc->profile_in_type = in_type; | |
149 cc->profile_in_file = g_strdup(in_file); | |
150 | |
151 cc->profile_out_type = out_type; | |
152 cc->profile_out_file = g_strdup(out_file); | |
153 | |
154 cc->has_alpha = has_alpha; | |
155 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
156 cc->profile_in = color_man_cache_load_profile(cc->profile_in_type, cc->profile_in_file, |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
157 in_data, in_data_len); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
158 cc->profile_out = color_man_cache_load_profile(cc->profile_out_type, cc->profile_out_file, |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
159 NULL, 0); |
113 | 160 |
161 if (!cc->profile_in || !cc->profile_out) | |
162 { | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
163 DEBUG_1("failed to load color profile for %s: %d %s", |
113 | 164 (!cc->profile_in) ? "input" : "screen", |
165 (!cc->profile_in) ? cc->profile_in_type : cc->profile_out_type, | |
166 (!cc->profile_in) ? cc->profile_in_file : cc->profile_out_file); | |
167 | |
168 color_man_cache_unref(cc); | |
169 return NULL; | |
170 } | |
171 | |
172 cc->transform = cmsCreateTransform(cc->profile_in, | |
173 (has_alpha) ? TYPE_RGBA_8 : TYPE_RGB_8, | |
174 cc->profile_out, | |
175 (has_alpha) ? TYPE_RGBA_8 : TYPE_RGB_8, | |
176 INTENT_PERCEPTUAL, 0); | |
177 | |
178 if (!cc->transform) | |
179 { | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
180 DEBUG_1("failed to create color profile transform"); |
113 | 181 |
182 color_man_cache_unref(cc); | |
183 return NULL; | |
184 } | |
185 | |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
186 if (cc->profile_in_type != COLOR_PROFILE_MEM) |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
187 { |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
188 cm_cache_list = g_list_append(cm_cache_list, cc); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
189 color_man_cache_ref(cc); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
190 } |
113 | 191 |
192 return cc; | |
193 } | |
194 | |
195 static void color_man_cache_free(ColorManCache *cc) | |
196 { | |
197 if (!cc) return; | |
198 | |
199 cm_cache_list = g_list_remove(cm_cache_list, cc); | |
200 color_man_cache_unref(cc); | |
201 } | |
202 | |
203 static void color_man_cache_reset(void) | |
204 { | |
205 while (cm_cache_list) | |
206 { | |
207 ColorManCache *cc; | |
208 | |
209 cc = cm_cache_list->data; | |
210 color_man_cache_free(cc); | |
211 } | |
212 } | |
213 | |
214 static ColorManCache *color_man_cache_find(ColorManProfileType in_type, const gchar *in_file, | |
215 ColorManProfileType out_type, const gchar *out_file, | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1284
diff
changeset
|
216 gboolean has_alpha) |
113 | 217 { |
218 GList *work; | |
219 | |
220 work = cm_cache_list; | |
221 while (work) | |
222 { | |
223 ColorManCache *cc; | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1284
diff
changeset
|
224 gboolean match = FALSE; |
113 | 225 |
226 cc = work->data; | |
227 work = work->next; | |
228 | |
229 if (cc->profile_in_type == in_type && | |
230 cc->profile_out_type == out_type && | |
231 cc->has_alpha == has_alpha) | |
232 { | |
233 match = TRUE; | |
234 } | |
235 | |
236 if (match && cc->profile_in_type == COLOR_PROFILE_FILE) | |
237 { | |
238 match = (cc->profile_in_file && in_file && | |
239 strcmp(cc->profile_in_file, in_file) == 0); | |
240 } | |
241 if (match && cc->profile_out_type == COLOR_PROFILE_FILE) | |
242 { | |
243 match = (cc->profile_out_file && out_file && | |
244 strcmp(cc->profile_out_file, out_file) == 0); | |
245 } | |
246 | |
247 if (match) return cc; | |
248 } | |
249 | |
250 return NULL; | |
251 } | |
252 | |
253 static ColorManCache *color_man_cache_get(ColorManProfileType in_type, const gchar *in_file, | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
686
diff
changeset
|
254 guchar *in_data, guint in_data_len, |
113 | 255 ColorManProfileType out_type, const gchar *out_file, |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1284
diff
changeset
|
256 gboolean has_alpha) |
113 | 257 { |
258 ColorManCache *cc; | |
259 | |
260 cc = color_man_cache_find(in_type, in_file, out_type, out_file, has_alpha); | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
261 if (cc) |
113 | 262 { |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
263 color_man_cache_ref(cc); |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
264 return cc; |
113 | 265 } |
266 | |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
267 return color_man_cache_new(in_type, in_file, in_data, in_data_len, |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
268 out_type, out_file, has_alpha); |
113 | 269 } |
270 | |
271 | |
272 /* | |
273 *------------------------------------------------------------------- | |
274 * color manager | |
275 *------------------------------------------------------------------- | |
276 */ | |
277 | |
278 static void color_man_done(ColorMan *cm, ColorManReturnType type) | |
279 { | |
280 if (cm->func_done) | |
281 { | |
282 cm->func_done(cm, type, cm->func_done_data); | |
283 } | |
284 } | |
285 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
286 void color_man_correct_region(ColorMan *cm, GdkPixbuf *pixbuf, gint x, gint y, gint w, gint h) |
113 | 287 { |
288 ColorManCache *cc; | |
289 guchar *pix; | |
290 gint rs; | |
291 gint i; | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
292 gint pixbuf_width, pixbuf_height; |
442 | 293 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
294 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
295 pixbuf_width = gdk_pixbuf_get_width(pixbuf); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
296 pixbuf_height = gdk_pixbuf_get_height(pixbuf); |
113 | 297 |
298 cc = cm->profile; | |
299 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
300 pix = gdk_pixbuf_get_pixels(pixbuf); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
301 rs = gdk_pixbuf_get_rowstride(pixbuf); |
113 | 302 |
303 w = MIN(w, pixbuf_width - x); | |
304 h = MIN(h, pixbuf_height - y); | |
305 | |
306 pix += x * ((cc->has_alpha) ? 4 : 3); | |
307 for (i = 0; i < h; i++) | |
308 { | |
309 guchar *pbuf; | |
310 | |
311 pbuf = pix + ((y + i) * rs); | |
442 | 312 |
113 | 313 cmsDoTransform(cc->transform, pbuf, pbuf, w); |
314 } | |
315 | |
316 } | |
317 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1284
diff
changeset
|
318 static gboolean color_man_idle_cb(gpointer data) |
113 | 319 { |
320 ColorMan *cm = data; | |
321 gint width, height; | |
322 gint rh; | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1284
diff
changeset
|
323 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
324 if (!cm->pixbuf) return FALSE; |
113 | 325 |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
326 if (cm->imd && |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
327 cm->pixbuf != image_get_pixbuf(cm->imd)) |
113 | 328 { |
1523 | 329 cm->idle_id = 0; |
113 | 330 color_man_done(cm, COLOR_RETURN_IMAGE_CHANGED); |
331 return FALSE; | |
332 } | |
333 | |
334 width = gdk_pixbuf_get_width(cm->pixbuf); | |
335 height = gdk_pixbuf_get_height(cm->pixbuf); | |
336 | |
337 if (cm->row > height) | |
338 { | |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
339 if (!cm->incremental_sync && cm->imd) |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
340 { |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
341 image_area_changed(cm->imd, 0, 0, width, height); |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
342 } |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
343 |
1523 | 344 cm->idle_id = 0; |
113 | 345 color_man_done(cm, COLOR_RETURN_SUCCESS); |
346 return FALSE; | |
347 } | |
348 | |
349 rh = COLOR_MAN_CHUNK_SIZE / width + 1; | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
350 color_man_correct_region(cm, cm->pixbuf, 0, cm->row, width, rh); |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
351 if (cm->incremental_sync && cm->imd) image_area_changed(cm->imd, 0, cm->row, width, rh); |
113 | 352 cm->row += rh; |
353 | |
354 return TRUE; | |
355 } | |
356 | |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
357 static ColorMan *color_man_new_real(ImageWindow *imd, GdkPixbuf *pixbuf, |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
358 ColorManProfileType input_type, const gchar *input_file, |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
686
diff
changeset
|
359 guchar *input_data, guint input_data_len, |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
360 ColorManProfileType screen_type, const gchar *screen_file) |
113 | 361 { |
362 ColorMan *cm; | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1284
diff
changeset
|
363 gboolean has_alpha; |
113 | 364 |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
365 if (imd) pixbuf = image_get_pixbuf(imd); |
113 | 366 |
367 cm = g_new0(ColorMan, 1); | |
368 cm->imd = imd; | |
369 cm->pixbuf = pixbuf; | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
370 if (cm->pixbuf) g_object_ref(cm->pixbuf); |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
371 |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
372 has_alpha = pixbuf ? gdk_pixbuf_get_has_alpha(pixbuf) : FALSE; |
113 | 373 |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
374 cm->profile = color_man_cache_get(input_type, input_file, input_data, input_data_len, |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
375 screen_type, screen_file, has_alpha); |
113 | 376 if (!cm->profile) |
377 { | |
378 color_man_free(cm); | |
379 return NULL; | |
380 } | |
381 | |
382 return cm; | |
383 } | |
384 | |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
385 ColorMan *color_man_new(ImageWindow *imd, GdkPixbuf *pixbuf, |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
386 ColorManProfileType input_type, const gchar *input_file, |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
387 ColorManProfileType screen_type, const gchar *screen_file) |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
388 { |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
389 return color_man_new_real(imd, pixbuf, |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
390 input_type, input_file, NULL, 0, |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
391 screen_type, screen_file); |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
392 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
393 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
394 void color_man_start_bg(ColorMan *cm, ColorManDoneFunc done_func, gpointer done_data) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
395 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
396 cm->func_done = done_func; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
397 cm->func_done_data = done_data; |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
398 cm->idle_id = g_idle_add(color_man_idle_cb, cm); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
399 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
400 |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
401 ColorMan *color_man_new_embedded(ImageWindow *imd, GdkPixbuf *pixbuf, |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
686
diff
changeset
|
402 guchar *input_data, guint input_data_len, |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
403 ColorManProfileType screen_type, const gchar *screen_file) |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
404 { |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
405 return color_man_new_real(imd, pixbuf, |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
406 COLOR_PROFILE_MEM, NULL, input_data, input_data_len, |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
407 screen_type, screen_file); |
114
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
408 } |
50fc73e08550
Mon Nov 27 01:23:23 2006 John Ellis <johne@verizon.net>
gqview
parents:
113
diff
changeset
|
409 |
1590
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
410 static gchar *color_man_get_profile_name(ColorManProfileType type, cmsHPROFILE profile) |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
411 { |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
412 switch (type) |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
413 { |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
414 case COLOR_PROFILE_SRGB: |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
415 return g_strdup(_("sRGB")); |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
416 case COLOR_PROFILE_ADOBERGB: |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
417 return g_strdup(_("Adobe RGB compatible")); |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
418 break; |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
419 case COLOR_PROFILE_MEM: |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
420 case COLOR_PROFILE_FILE: |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
421 if (profile) |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
422 { |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
423 return g_strdup(cmsTakeProductName(profile)); |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
424 } |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
425 return g_strdup(_("Custom profile")); |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
426 break; |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
427 case COLOR_PROFILE_NONE: |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
428 default: |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
429 return g_strdup(""); |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
430 } |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
431 } |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
432 |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
433 gboolean color_man_get_status(ColorMan *cm, gchar **image_profile, gchar **screen_profile) |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
434 { |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
435 ColorManCache *cc; |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
436 if (!cm) return FALSE; |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
437 |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
438 cc = cm->profile; |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
439 |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
440 if (image_profile) *image_profile = color_man_get_profile_name(cc->profile_in_type, cc->profile_in); |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
441 if (screen_profile) *screen_profile = color_man_get_profile_name(cc->profile_out_type, cc->profile_out); |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
442 return TRUE; |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
443 } |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
444 |
113 | 445 void color_man_free(ColorMan *cm) |
446 { | |
447 if (!cm) return; | |
448 | |
1523 | 449 if (cm->idle_id) g_source_remove(cm->idle_id); |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
450 if (cm->pixbuf) g_object_unref(cm->pixbuf); |
113 | 451 |
452 color_man_cache_unref(cm->profile); | |
453 | |
454 g_free(cm); | |
455 } | |
456 | |
457 void color_man_update(void) | |
458 { | |
459 color_man_cache_reset(); | |
460 } | |
461 | |
686 | 462 #else /* define HAVE_LCMS */ |
113 | 463 /*** color support not enabled ***/ |
464 | |
465 | |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
466 ColorMan *color_man_new(ImageWindow *imd, GdkPixbuf *pixbuf, |
113 | 467 ColorManProfileType input_type, const gchar *input_file, |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
468 ColorManProfileType screen_type, const gchar *screen_file) |
113 | 469 { |
470 /* no op */ | |
471 return NULL; | |
472 } | |
473 | |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
474 ColorMan *color_man_new_embedded(ImageWindow *imd, GdkPixbuf *pixbuf, |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
686
diff
changeset
|
475 guchar *input_data, guint input_data_len, |
1586
c3416996fd97
Backed out changeset b5608391f479
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1548
diff
changeset
|
476 ColorManProfileType screen_type, const gchar *screen_file) |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
477 { |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
478 /* no op */ |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
479 return NULL; |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
480 } |
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
114
diff
changeset
|
481 |
1590
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
482 gboolean color_man_get_status(ColorMan *cm, gchar **image_profile, gchar **screen_profile) |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
483 { |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
484 return FALSE; |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
485 } |
69f7270b3b27
improved color management button:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1587
diff
changeset
|
486 |
113 | 487 void color_man_free(ColorMan *cm) |
488 { | |
489 /* no op */ | |
490 } | |
491 | |
492 void color_man_update(void) | |
493 { | |
494 /* no op */ | |
495 } | |
496 | |
398
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
497 void color_man_correct_region(ColorMan *cm, GdkPixbuf *pixbuf, gint x, gint y, gint w, gint h) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
498 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
499 /* no op */ |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
500 } |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
501 |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
502 void color_man_start_bg(ColorMan *cm, ColorManDoneFunc done_func, gpointer done_data) |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
503 { |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
504 /* no op */ |
c4080362d619
image post-processing (rotation and color management) moved to
nadvornik
parents:
281
diff
changeset
|
505 } |
113 | 506 |
686 | 507 #endif /* define HAVE_LCMS */ |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1000
diff
changeset
|
508 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |