comparison src/image.c @ 1586:c3416996fd97

Backed out changeset b5608391f479
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 01 May 2009 15:49:46 +0900
parents b5608391f479
children 5b59ccf95b2b
comparison
equal deleted inserted replaced
1548:b5608391f479 1586:c3416996fd97
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 }
203 191
204 static gboolean image_post_process_color(ImageWindow *imd, gint start_row, gboolean run_in_bg) 192 static gboolean image_post_process_color(ImageWindow *imd, gint start_row, gboolean run_in_bg)
205 { 193 {
206 ColorMan *cm; 194 ColorMan *cm;
207 ColorManProfileType input_type; 195 ColorManProfileType input_type;
208 ColorManProfileType screen_type; 196 ColorManProfileType screen_type;
209 const gchar *input_file = NULL; 197 const gchar *input_file;
210 const gchar *screen_file = NULL; 198 const gchar *screen_file;
211 guchar *profile = NULL; 199 guchar *profile = NULL;
212 guint profile_len; 200 guint profile_len;
213 guchar *screen_profile = NULL;
214 gint screen_profile_len;
215 ExifData *exif; 201 ExifData *exif;
216 202
217 if (imd->cm) return FALSE; 203 if (imd->cm) return FALSE;
218 204
219 if (imd->color_profile_input >= COLOR_PROFILE_FILE && 205 if (imd->color_profile_input >= COLOR_PROFILE_FILE &&
235 else 221 else
236 { 222 {
237 return FALSE; 223 return FALSE;
238 } 224 }
239 225
240 if (options->color_profile.use_x11_screen_profile && 226 if (imd->color_profile_screen == 1 &&
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 &&
247 is_readable_file(options->color_profile.screen_file)) 227 is_readable_file(options->color_profile.screen_file))
248 { 228 {
249 screen_type = COLOR_PROFILE_FILE; 229 screen_type = COLOR_PROFILE_FILE;
250 screen_file = options->color_profile.screen_file; 230 screen_file = options->color_profile.screen_file;
251 } 231 }
252 else 232 else if (imd->color_profile_screen == 0)
253 { 233 {
254 screen_type = COLOR_PROFILE_SRGB; 234 screen_type = COLOR_PROFILE_SRGB;
255 screen_file = NULL; 235 screen_file = NULL;
236 }
237 else
238 {
239 return FALSE;
256 } 240 }
257 241
258 242
259 imd->color_profile_from_image = COLOR_PROFILE_NONE; 243 imd->color_profile_from_image = COLOR_PROFILE_NONE;
260 244
324 308
325 if (profile) 309 if (profile)
326 { 310 {
327 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL, 311 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL,
328 profile, profile_len, 312 profile, profile_len,
329 screen_type, screen_file, screen_profile, screen_profile_len); 313 screen_type, screen_file);
330 g_free(profile); 314 g_free(profile);
331 } 315 }
332 else 316 else
333 { 317 {
334 cm = color_man_new(run_in_bg ? imd : NULL, NULL, 318 cm = color_man_new(run_in_bg ? imd : NULL, NULL,
335 input_type, input_file, 319 input_type, input_file,
336 screen_type, screen_file, screen_profile, screen_profile_len); 320 screen_type, screen_file);
337 } 321 }
338 322
339 if (cm) 323 if (cm)
340 { 324 {
341 if (start_row > 0) 325 if (start_row > 0)
1184 source->delay_alter_type = ALTER_NONE; 1168 source->delay_alter_type = ALTER_NONE;
1185 } 1169 }
1186 1170
1187 imd->color_profile_enable = source->color_profile_enable; 1171 imd->color_profile_enable = source->color_profile_enable;
1188 imd->color_profile_input = source->color_profile_input; 1172 imd->color_profile_input = source->color_profile_input;
1173 imd->color_profile_screen = source->color_profile_screen;
1189 imd->color_profile_use_image = source->color_profile_use_image; 1174 imd->color_profile_use_image = source->color_profile_use_image;
1190 color_man_free((ColorMan *)imd->cm); 1175 color_man_free((ColorMan *)imd->cm);
1191 imd->cm = NULL; 1176 imd->cm = NULL;
1192 if (source->cm) 1177 if (source->cm)
1193 { 1178 {
1436 { 1421 {
1437 pixbuf_renderer_set_color((PixbufRenderer *)imd->pr, color); 1422 pixbuf_renderer_set_color((PixbufRenderer *)imd->pr, color);
1438 } 1423 }
1439 1424
1440 void image_color_profile_set(ImageWindow *imd, 1425 void image_color_profile_set(ImageWindow *imd,
1441 gint input_type, 1426 gint input_type, gint screen_type,
1442 gboolean use_image) 1427 gboolean use_image)
1443 { 1428 {
1444 if (!imd) return; 1429 if (!imd) return;
1445 1430
1446 if (input_type < 0 || input_type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) 1431 if (input_type < 0 || input_type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS ||
1432 screen_type < 0 || screen_type > 1)
1447 { 1433 {
1448 return; 1434 return;
1449 } 1435 }
1450 1436
1451 imd->color_profile_input = input_type; 1437 imd->color_profile_input = input_type;
1438 imd->color_profile_screen = screen_type;
1452 imd->color_profile_use_image = use_image; 1439 imd->color_profile_use_image = use_image;
1453 } 1440 }
1454 1441
1455 gboolean image_color_profile_get(ImageWindow *imd, 1442 gboolean image_color_profile_get(ImageWindow *imd,
1456 gint *input_type, 1443 gint *input_type, gint *screen_type,
1457 gboolean *use_image) 1444 gboolean *use_image)
1458 { 1445 {
1459 if (!imd) return FALSE; 1446 if (!imd) return FALSE;
1460 1447
1461 if (input_type) *input_type = imd->color_profile_input; 1448 if (input_type) *input_type = imd->color_profile_input;
1449 if (screen_type) *screen_type = imd->color_profile_screen;
1462 if (use_image) *use_image = imd->color_profile_use_image; 1450 if (use_image) *use_image = imd->color_profile_use_image;
1463 1451
1464 return TRUE; 1452 return TRUE;
1465 } 1453 }
1466 1454