[gthumb] contact sheet: fixed painting of the scaled image



commit 32e2ff9c47cc7934f7a048845f3545d3feebd4fb
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Nov 26 18:34:44 2013 +0100

    contact sheet: fixed painting of the scaled image

 .../contact_sheet/gth-contact-sheet-creator.c      |   25 ++++++------
 gthumb/cairo-utils.c                               |   42 +++++++++----------
 2 files changed, 33 insertions(+), 34 deletions(-)
---
diff --git a/extensions/contact_sheet/gth-contact-sheet-creator.c 
b/extensions/contact_sheet/gth-contact-sheet-creator.c
index e5d7412..db7588f 100644
--- a/extensions/contact_sheet/gth-contact-sheet-creator.c
+++ b/extensions/contact_sheet/gth-contact-sheet-creator.c
@@ -880,7 +880,6 @@ static void
 load_current_image (GthContactSheetCreator *self)
 {
        ItemData *item_data;
-       int       requested_size;
 
        if (self->priv->current_file == NULL) {
                if (self->priv->sort_type->cmp_func != 0)
@@ -898,16 +897,9 @@ load_current_image (GthContactSheetCreator *self)
                           FALSE,
                           ((double) ++self->priv->n_loaded_files) / (self->priv->n_files + 1));
 
-       if (self->priv->squared_thumbnails)
-               /* the squared thumbnail requires the original size to avoid
-                * a thumbnail upscaling that degrades the image quality. */
-               requested_size = -1;
-       else
-               requested_size = MAX (self->priv->thumb_height, self->priv->thumb_width);
-
        gth_image_loader_load (self->priv->image_loader,
                               item_data->file_data,
-                              requested_size,
+                              -1,
                               G_PRIORITY_DEFAULT,
                               gth_task_get_cancellable (GTH_TASK (self)),
                               image_loader_ready_cb,
@@ -943,10 +935,19 @@ image_loader_ready_cb (GObject      *source_object,
        image_surface = gth_image_get_cairo_surface (image);
 
        item_data = self->priv->current_file->data;
-       if (self->priv->squared_thumbnails)
+       if (self->priv->squared_thumbnails) {
                item_data->thumbnail = _cairo_image_surface_scale_squared (image_surface, MIN 
(self->priv->thumb_height, self->priv->thumb_width), SCALE_FILTER_BEST, NULL);
-       else
-               item_data->thumbnail = cairo_surface_reference (image_surface);
+       }
+       else {
+               int width, height;
+
+               width = cairo_image_surface_get_width (image_surface);
+               height = cairo_image_surface_get_height (image_surface);
+               if (scale_keeping_ratio (&width, &height, self->priv->thumb_width, self->priv->thumb_height, 
FALSE))
+                       item_data->thumbnail = _cairo_image_surface_scale (image_surface, width, height, 
SCALE_FILTER_BEST, NULL);
+               else
+                       item_data->thumbnail = cairo_surface_reference (image_surface);
+       }
        item_data->original_width = original_width;
        item_data->original_height = original_height;
 
diff --git a/gthumb/cairo-utils.c b/gthumb/cairo-utils.c
index c18f1b1..304b336 100644
--- a/gthumb/cairo-utils.c
+++ b/gthumb/cairo-utils.c
@@ -875,23 +875,21 @@ _cairo_draw_slide (cairo_t  *cr,
                                         image_height);
                        cairo_fill (cr);
 
-                       image_x -= 1;
-                       image_y -= 1;
-                       image_x2 = image_x + image_width + 2;
-                       image_y2 = image_y + image_height + 2;
+                       image_x2 = image_x + image_width + 1;
+                       image_y2 = image_y + image_height + 1;
 
                        cairo_set_source_rgb (cr, dark_gray, dark_gray, dark_gray);
                        cairo_move_to (cr, image_x, image_y);
-                       cairo_line_to (cr, image_x2 - 1, image_y);
+                       cairo_line_to (cr, image_x2, image_y);
                        cairo_move_to (cr, image_x, image_y);
-                       cairo_line_to (cr, image_x, image_y2 - 1);
+                       cairo_line_to (cr, image_x, image_y2);
                        cairo_stroke (cr);
 
                        cairo_set_source_rgb (cr, mid_gray, mid_gray, mid_gray);
-                       cairo_move_to (cr, image_x2 - 1, image_y - 1);
-                       cairo_line_to (cr, image_x2 - 1, image_y2 - 1);
-                       cairo_move_to (cr, image_x, image_y2 - 1);
-                       cairo_line_to (cr, image_x2, image_y2 - 1);
+                       cairo_move_to (cr, image_x2, image_y);
+                       cairo_line_to (cr, image_x2, image_y2);
+                       cairo_move_to (cr, image_x, image_y2);
+                       cairo_line_to (cr, image_x2, image_y2);
                        cairo_stroke (cr);
                }
        }
@@ -899,31 +897,31 @@ _cairo_draw_slide (cairo_t  *cr,
        /* outer border. */
 
        cairo_set_source_rgb (cr, mid_gray, mid_gray, mid_gray);
-       cairo_move_to (cr, frame_x - 1, frame_y);
+       cairo_move_to (cr, frame_x, frame_y);
        cairo_line_to (cr, frame_x2, frame_y);
-       cairo_move_to (cr, frame_x, frame_y - 1);
+       cairo_move_to (cr, frame_x, frame_y);
        cairo_line_to (cr, frame_x, frame_y2);
        cairo_stroke (cr);
 
        cairo_set_source_rgb (cr, darker_gray, darker_gray, darker_gray);
-       cairo_move_to (cr, frame_x2, frame_y - 1);
+       cairo_move_to (cr, frame_x2, frame_y);
        cairo_line_to (cr, frame_x2, frame_y2);
-       cairo_move_to (cr, frame_x - 1, frame_y2);
+       cairo_move_to (cr, frame_x, frame_y2);
        cairo_line_to (cr, frame_x2, frame_y2);
        cairo_stroke (cr);
 
        cairo_set_source_rgb (cr, light_gray, light_gray, light_gray);
-       cairo_move_to (cr, frame_x, frame_y + 1);
-       cairo_line_to (cr, frame_x2 - 1, frame_y + 1);
-       cairo_move_to (cr, frame_x + 1, frame_y);
-       cairo_line_to (cr, frame_x + 1, frame_y2 - 1);
+       cairo_move_to (cr, frame_x, frame_y);
+       cairo_line_to (cr, frame_x2, frame_y);
+       cairo_move_to (cr, frame_x, frame_y);
+       cairo_line_to (cr, frame_x, frame_y2);
        cairo_stroke (cr);
 
        cairo_set_source_rgb (cr, dark_gray, dark_gray, dark_gray);
-       cairo_move_to (cr, frame_x2 - 1, frame_y);
-       cairo_line_to (cr, frame_x2 - 1, frame_y2 - 1);
-       cairo_move_to (cr, frame_x, frame_y2 - 1);
-       cairo_line_to (cr, frame_x2 - 1, frame_y2 - 1);
+       cairo_move_to (cr, frame_x2, frame_y);
+       cairo_line_to (cr, frame_x2, frame_y2);
+       cairo_move_to (cr, frame_x, frame_y2);
+       cairo_line_to (cr, frame_x2, frame_y2);
        cairo_stroke (cr);
 
        cairo_restore (cr);


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