comparison src/image.c @ 1566:3d9f5c078521

separated Orientation and Grayscale functions moved Grayscale to Color management menu
author nadvornik
date Sat, 25 Apr 2009 22:08:09 +0000
parents ffc44762e706
children c776b1310ca6
comparison
equal deleted inserted replaced
1565:54bb40066b35 1566:3d9f5c078521
361 if (imd->cm) color_man_correct_region(imd->cm, *pixbuf, x, y, w, h); 361 if (imd->cm) color_man_correct_region(imd->cm, *pixbuf, x, y, w, h);
362 if (imd->desaturate) pixbuf_desaturate_rect(*pixbuf, x, y, w, h); 362 if (imd->desaturate) pixbuf_desaturate_rect(*pixbuf, x, y, w, h);
363 363
364 } 364 }
365 365
366 void image_alter(ImageWindow *imd, AlterType type) 366 void image_alter_orientation(ImageWindow *imd, AlterType type)
367 { 367 {
368 static const gint rotate_90[] = {1, 6, 7, 8, 5, 2, 3, 4, 1}; 368 static const gint rotate_90[] = {1, 6, 7, 8, 5, 2, 3, 4, 1};
369 static const gint rotate_90_cc[] = {1, 8, 5, 6, 7, 4, 1, 2, 3}; 369 static const gint rotate_90_cc[] = {1, 8, 5, 6, 7, 4, 1, 2, 3};
370 static const gint rotate_180[] = {1, 3, 4, 1, 2, 7, 8, 5, 6}; 370 static const gint rotate_180[] = {1, 3, 4, 1, 2, 7, 8, 5, 6};
371 static const gint mirror[] = {1, 2, 1, 4, 3, 6, 5, 8, 7}; 371 static const gint mirror[] = {1, 2, 1, 4, 3, 6, 5, 8, 7};
391 imd->orientation = mirror[imd->orientation]; 391 imd->orientation = mirror[imd->orientation];
392 break; 392 break;
393 case ALTER_FLIP: 393 case ALTER_FLIP:
394 imd->orientation = flip[imd->orientation]; 394 imd->orientation = flip[imd->orientation];
395 break; 395 break;
396 case ALTER_DESATURATE:
397 imd->desaturate = !imd->desaturate;
398 break;
399 case ALTER_NONE: 396 case ALTER_NONE:
400 imd->orientation = imd->image_fd->exif_orientation ? imd->image_fd->exif_orientation : 1; 397 imd->orientation = imd->image_fd->exif_orientation ? imd->image_fd->exif_orientation : 1;
401 imd->desaturate = FALSE;
402 break; 398 break;
403 default: 399 default:
404 return; 400 return;
405 break; 401 break;
406 } 402 }
407 403
408 if (type != ALTER_NONE && type != ALTER_DESATURATE) 404 if (type != ALTER_NONE)
409 { 405 {
410 if (imd->image_fd->user_orientation == 0) file_data_ref(imd->image_fd); 406 if (imd->image_fd->user_orientation == 0) file_data_ref(imd->image_fd);
411 imd->image_fd->user_orientation = imd->orientation; 407 imd->image_fd->user_orientation = imd->orientation;
412 } 408 }
413 else 409 else
415 if (imd->image_fd->user_orientation != 0) file_data_unref(imd->image_fd); 411 if (imd->image_fd->user_orientation != 0) file_data_unref(imd->image_fd);
416 imd->image_fd->user_orientation = 0; 412 imd->image_fd->user_orientation = 0;
417 } 413 }
418 414
419 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); 415 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation);
416 }
417
418 void image_set_desaturate(ImageWindow *imd, gboolean desaturate)
419 {
420 imd->desaturate = desaturate;
420 if (imd->cm || imd->desaturate) 421 if (imd->cm || imd->desaturate)
421 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) ); 422 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) );
422 else 423 else
423 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, TRUE); 424 pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, TRUE);
424 } 425 pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation);
425 426 }
427
428 gboolean image_get_desaturate(ImageWindow *imd)
429 {
430 return imd->desaturate;
431 }
426 432
427 /* 433 /*
428 *------------------------------------------------------------------- 434 *-------------------------------------------------------------------
429 * read ahead (prebuffer) 435 * read ahead (prebuffer)
430 *------------------------------------------------------------------- 436 *-------------------------------------------------------------------