[gimp] Bug 754221 - Possible preview widget bug



commit e491bf8e09f0acfe787ed655193595e03285ee31
Author: Michael Natterer <mitch gimp org>
Date:   Sun Sep 6 17:22:16 2015 +0200

    Bug 754221 - Possible preview widget bug
    
    gimp_drawable_get_sub_preview(): both the preview buffer's scale
    factor and the src coordinates in the drawable were calculated
    wrongly. Found by Massimo.

 app/core/gimpdrawable-preview.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/app/core/gimpdrawable-preview.c b/app/core/gimpdrawable-preview.c
index 35b26d0..c4647c8 100644
--- a/app/core/gimpdrawable-preview.c
+++ b/app/core/gimpdrawable-preview.c
@@ -97,6 +97,8 @@ gimp_drawable_get_sub_preview (GimpDrawable *drawable,
   GeglBuffer  *buffer;
   GimpTempBuf *preview;
   gdouble      scale;
+  gint         scaled_x;
+  gint         scaled_y;
 
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
   g_return_val_if_fail (src_x >= 0, NULL);
@@ -121,11 +123,14 @@ gimp_drawable_get_sub_preview (GimpDrawable *drawable,
   preview = gimp_temp_buf_new (dest_width, dest_height,
                                gimp_drawable_get_preview_format (drawable));
 
-  scale = MIN ((gdouble) dest_width  / (gdouble) gegl_buffer_get_width  (buffer),
-               (gdouble) dest_height / (gdouble) gegl_buffer_get_height (buffer));
+  scale = MIN ((gdouble) dest_width  / (gdouble) src_width,
+               (gdouble) dest_height / (gdouble) src_height);
+
+  scaled_x = RINT ((gdouble) src_x * scale);
+  scaled_y = RINT ((gdouble) src_y * scale);
 
   gegl_buffer_get (buffer,
-                   GEGL_RECTANGLE (src_x, src_y, dest_width, dest_height),
+                   GEGL_RECTANGLE (scaled_x, scaled_y, dest_width, dest_height),
                    scale,
                    gimp_temp_buf_get_format (preview),
                    gimp_temp_buf_get_data (preview),


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