Mercurial > geeqie
comparison src/image.c @ 1548:b5608391f479
support X11 screen profile
http://freedesktop.org/wiki/ICC_Profiles_in_X_Specification_0.3
author | nadvornik |
---|---|
date | Mon, 13 Apr 2009 10:55:49 +0000 |
parents | 5f49f305a6b6 |
children | 7302ff300a52 |
comparison
equal
deleted
inserted
replaced
1547:2a3efbdf73b0 | 1548:b5608391f479 |
---|---|
186 /* | 186 /* |
187 *------------------------------------------------------------------- | 187 *------------------------------------------------------------------- |
188 * rotation, flip, etc. | 188 * rotation, flip, etc. |
189 *------------------------------------------------------------------- | 189 *------------------------------------------------------------------- |
190 */ | 190 */ |
191 static gboolean image_get_x11_screen_profile(ImageWindow *imd, guchar **screen_profile, gint *screen_profile_len) | |
192 { | |
193 GdkScreen *screen = gtk_widget_get_screen(imd->widget);; | |
194 GdkAtom type = GDK_NONE; | |
195 gint format = 0; | |
196 | |
197 return (gdk_property_get(gdk_screen_get_root_window(screen), | |
198 gdk_atom_intern ("_ICC_PROFILE", FALSE), | |
199 GDK_NONE, | |
200 0, 64 * 1024 * 1024, FALSE, | |
201 &type, &format, screen_profile_len, screen_profile) && *screen_profile_len > 0); | |
202 } | |
191 | 203 |
192 static gboolean image_post_process_color(ImageWindow *imd, gint start_row, gboolean run_in_bg) | 204 static gboolean image_post_process_color(ImageWindow *imd, gint start_row, gboolean run_in_bg) |
193 { | 205 { |
194 ColorMan *cm; | 206 ColorMan *cm; |
195 ColorManProfileType input_type; | 207 ColorManProfileType input_type; |
196 ColorManProfileType screen_type; | 208 ColorManProfileType screen_type; |
197 const gchar *input_file; | 209 const gchar *input_file = NULL; |
198 const gchar *screen_file; | 210 const gchar *screen_file = NULL; |
199 guchar *profile = NULL; | 211 guchar *profile = NULL; |
200 guint profile_len; | 212 guint profile_len; |
213 guchar *screen_profile = NULL; | |
214 gint screen_profile_len; | |
201 ExifData *exif; | 215 ExifData *exif; |
202 | 216 |
203 if (imd->cm) return FALSE; | 217 if (imd->cm) return FALSE; |
204 | 218 |
205 if (imd->color_profile_input >= COLOR_PROFILE_FILE && | 219 if (imd->color_profile_input >= COLOR_PROFILE_FILE && |
221 else | 235 else |
222 { | 236 { |
223 return FALSE; | 237 return FALSE; |
224 } | 238 } |
225 | 239 |
226 if (imd->color_profile_screen == 1 && | 240 if (options->color_profile.use_x11_screen_profile && |
241 image_get_x11_screen_profile(imd, &screen_profile, &screen_profile_len)) | |
242 { | |
243 screen_type = COLOR_PROFILE_MEM; | |
244 DEBUG_1("Using X11 screen profile, length: %d", screen_profile_len); | |
245 } | |
246 if (options->color_profile.screen_file && | |
227 is_readable_file(options->color_profile.screen_file)) | 247 is_readable_file(options->color_profile.screen_file)) |
228 { | 248 { |
229 screen_type = COLOR_PROFILE_FILE; | 249 screen_type = COLOR_PROFILE_FILE; |
230 screen_file = options->color_profile.screen_file; | 250 screen_file = options->color_profile.screen_file; |
231 } | 251 } |
232 else if (imd->color_profile_screen == 0) | 252 else |
233 { | 253 { |
234 screen_type = COLOR_PROFILE_SRGB; | 254 screen_type = COLOR_PROFILE_SRGB; |
235 screen_file = NULL; | 255 screen_file = NULL; |
236 } | |
237 else | |
238 { | |
239 return FALSE; | |
240 } | 256 } |
241 | 257 |
242 | 258 |
243 imd->color_profile_from_image = COLOR_PROFILE_NONE; | 259 imd->color_profile_from_image = COLOR_PROFILE_NONE; |
244 | 260 |
308 | 324 |
309 if (profile) | 325 if (profile) |
310 { | 326 { |
311 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL, | 327 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL, |
312 profile, profile_len, | 328 profile, profile_len, |
313 screen_type, screen_file); | 329 screen_type, screen_file, screen_profile, screen_profile_len); |
314 g_free(profile); | 330 g_free(profile); |
315 } | 331 } |
316 else | 332 else |
317 { | 333 { |
318 cm = color_man_new(run_in_bg ? imd : NULL, NULL, | 334 cm = color_man_new(run_in_bg ? imd : NULL, NULL, |
319 input_type, input_file, | 335 input_type, input_file, |
320 screen_type, screen_file); | 336 screen_type, screen_file, screen_profile, screen_profile_len); |
321 } | 337 } |
322 | 338 |
323 if (cm) | 339 if (cm) |
324 { | 340 { |
325 if (start_row > 0) | 341 if (start_row > 0) |
1168 source->delay_alter_type = ALTER_NONE; | 1184 source->delay_alter_type = ALTER_NONE; |
1169 } | 1185 } |
1170 | 1186 |
1171 imd->color_profile_enable = source->color_profile_enable; | 1187 imd->color_profile_enable = source->color_profile_enable; |
1172 imd->color_profile_input = source->color_profile_input; | 1188 imd->color_profile_input = source->color_profile_input; |
1173 imd->color_profile_screen = source->color_profile_screen; | |
1174 imd->color_profile_use_image = source->color_profile_use_image; | 1189 imd->color_profile_use_image = source->color_profile_use_image; |
1175 color_man_free((ColorMan *)imd->cm); | 1190 color_man_free((ColorMan *)imd->cm); |
1176 imd->cm = NULL; | 1191 imd->cm = NULL; |
1177 if (source->cm) | 1192 if (source->cm) |
1178 { | 1193 { |
1421 { | 1436 { |
1422 pixbuf_renderer_set_color((PixbufRenderer *)imd->pr, color); | 1437 pixbuf_renderer_set_color((PixbufRenderer *)imd->pr, color); |
1423 } | 1438 } |
1424 | 1439 |
1425 void image_color_profile_set(ImageWindow *imd, | 1440 void image_color_profile_set(ImageWindow *imd, |
1426 gint input_type, gint screen_type, | 1441 gint input_type, |
1427 gboolean use_image) | 1442 gboolean use_image) |
1428 { | 1443 { |
1429 if (!imd) return; | 1444 if (!imd) return; |
1430 | 1445 |
1431 if (input_type < 0 || input_type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS || | 1446 if (input_type < 0 || input_type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) |
1432 screen_type < 0 || screen_type > 1) | |
1433 { | 1447 { |
1434 return; | 1448 return; |
1435 } | 1449 } |
1436 | 1450 |
1437 imd->color_profile_input = input_type; | 1451 imd->color_profile_input = input_type; |
1438 imd->color_profile_screen = screen_type; | |
1439 imd->color_profile_use_image = use_image; | 1452 imd->color_profile_use_image = use_image; |
1440 } | 1453 } |
1441 | 1454 |
1442 gboolean image_color_profile_get(ImageWindow *imd, | 1455 gboolean image_color_profile_get(ImageWindow *imd, |
1443 gint *input_type, gint *screen_type, | 1456 gint *input_type, |
1444 gboolean *use_image) | 1457 gboolean *use_image) |
1445 { | 1458 { |
1446 if (!imd) return FALSE; | 1459 if (!imd) return FALSE; |
1447 | 1460 |
1448 if (input_type) *input_type = imd->color_profile_input; | 1461 if (input_type) *input_type = imd->color_profile_input; |
1449 if (screen_type) *screen_type = imd->color_profile_screen; | |
1450 if (use_image) *use_image = imd->color_profile_use_image; | 1462 if (use_image) *use_image = imd->color_profile_use_image; |
1451 | 1463 |
1452 return TRUE; | 1464 return TRUE; |
1453 } | 1465 } |
1454 | 1466 |