[gthumb] adjust colors: minor optimization



commit 5e28de3e2dcfcfff68aced07178949c5fb5634be
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Jan 7 13:03:21 2015 +0100

    adjust colors: minor optimization

 .../file_tools/gth-file-tool-adjust-colors.c       |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/extensions/file_tools/gth-file-tool-adjust-colors.c 
b/extensions/file_tools/gth-file-tool-adjust-colors.c
index 4ff5901..3ec7b15 100644
--- a/extensions/file_tools/gth-file-tool-adjust-colors.c
+++ b/extensions/file_tools/gth-file-tool-adjust-colors.c
@@ -119,8 +119,14 @@ adjust_colors_exec (GthAsyncTask *task,
        unsigned char    values[4];
        int              channel;
        unsigned char    value;
+       double           saturation;
        cairo_surface_t *destination;
 
+       if (adjust_data->saturation < 0)
+               saturation = tan (adjust_data->saturation * G_PI_2);
+       else
+               saturation = adjust_data->saturation;
+
        source = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
        format = cairo_image_surface_get_format (source);
        width = cairo_image_surface_get_width (source);
@@ -152,7 +158,8 @@ adjust_colors_exec (GthAsyncTask *task,
                                if (! pixbuf_cache_get (adjust_data->cache, channel + 1, &value)) {
                                        int tmp;
 
-                                       value = gamma_correction (value, adjust_data->gamma);
+                                       if (adjust_data->gamma != 0.0)
+                                               value = gamma_correction (value, adjust_data->gamma);
 
                                        if (adjust_data->brightness > 0)
                                                tmp = interpolate_value (value, 0, adjust_data->brightness);
@@ -179,18 +186,12 @@ adjust_colors_exec (GthAsyncTask *task,
 
                        if (adjust_data->saturation != 0.0) {
                                guchar min, max, lightness;
-                               double saturation;
                                int    tmp;
 
                                max = MAX (MAX (values[0], values[1]), values[2]);
                                min = MIN (MIN (values[0], values[1]), values[2]);
                                lightness = (max + min) / 2;
 
-                               if (adjust_data->saturation < 0)
-                                       saturation = tan (adjust_data->saturation * G_PI_2);
-                               else
-                                       saturation = adjust_data->saturation;
-
                                tmp = interpolate_value (values[0], lightness, saturation);
                                values[0] = CLAMP (tmp, 0, 255);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]