[Sugar-devel] [PATCH sugar-toolkit-gtk3] Avoid stretching the preview image.

Manuel Quiñones manuq at laptop.org
Mon Feb 13 13:12:37 EST 2012


El día 13 de febrero de 2012 11:16,  <godiard at sugarlabs.org> escribió:
> From: Gonzalo Odiard <godiard at gmail.com>
>
> This patch apply over "Do the preview in the activity using cairo intead of GdkPixbuf -v2"

Yes!  No more stretched thumbnails, I like it!

Later, maybe we can modify the outline in the Journal detail view so
it fits the current thumbnail size.

> Signed-off-by: Gonzalo Odiard <gonzalo at laptop.org>

Tested-by: Manuel Quiñones <manuq at laptop.org>
Reviewed-by: Manuel Quiñones <manuq at laptop.org>

> ---
>  src/sugar3/activity/activity.py |   15 ++++++++++++++-
>  1 files changed, 14 insertions(+), 1 deletions(-)
>
> diff --git a/src/sugar3/activity/activity.py b/src/sugar3/activity/activity.py
> index 8c1200c..7b0693b 100644
> --- a/src/sugar3/activity/activity.py
> +++ b/src/sugar3/activity/activity.py
> @@ -664,7 +664,20 @@ class Activity(Window, Gtk.Container):
>         cairo_context = cairo.Context(preview_surface)
>         preview_scale_w = preview_width * 1.0 / width
>         preview_scale_h = preview_height * 1.0 / height
> -        cairo_context.scale(preview_scale_w, preview_scale_h)
> +        scale = min(preview_scale_w, preview_scale_h)
> +
> +        margin_x = int((preview_width - (width * scale)) / 2)
> +        margin_y = int((preview_height - (height * scale)) / 2)
> +
> +        cairo_context.rectangle(0, 0, preview_width, preview_height)
> +        cairo_context.set_source_rgb(1, 1, 1)
> +        cairo_context.fill()
> +
> +        cairo_context.rectangle(margin_x, margin_y, preview_width,
> +                preview_height)
> +        cairo_context.clip()
> +        cairo_context.translate(margin_x, margin_y)
> +        cairo_context.scale(scale, scale)
>         Gdk.cairo_set_source_window(cairo_context, window, -x, -y)
>         cairo_context.paint()
>
> --
> 1.7.7.6
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel



-- 
.. manuq ..


More information about the Sugar-devel mailing list