[cheese/gnome-3-14] Limit default size for avatar cropping



commit f9406b6b927344fd2f49e07f3bd6d0fa4ff4cf34
Author: Ondrej Holy <oholy redhat com>
Date:   Mon Nov 10 09:04:59 2014 +0100

    Limit default size for avatar cropping
    
    Commit c605ad3578ff66452bd7b01d257f31c64e7905ef enlarged default size
    for cropping avatars thus crop rectangle could be easily bigger then
    image. The crop rectagle can't be modified and cc_crop_area_get_picture
    causes errors if the rectangle is bigger, because it has negative
    coordinates. Limit the default size to fit the image also.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=739870

 libcheese/um-crop-area.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/libcheese/um-crop-area.c b/libcheese/um-crop-area.c
index 7a9c064..2fdfdfe 100644
--- a/libcheese/um-crop-area.c
+++ b/libcheese/um-crop-area.c
@@ -185,8 +185,11 @@ update_pixbufs (UmCropArea *area)
                 if (priv->scale == 0.0) {
                         gdouble crop_scale;
 
-                        crop_scale = MIN (gdk_pixbuf_get_width (priv->pixbuf) / priv->base_width * 0.8,
-                                          gdk_pixbuf_get_height (priv->pixbuf) / priv->base_height * 0.8);
+                        /* Scale the crop rectangle to 80% of the area, or less to fit the image */
+                        crop_scale = MIN (MIN ((gdouble)gdk_pixbuf_get_width (priv->pixbuf) / 
priv->base_width * 0.8,
+                                               (gdouble)dest_width / priv->base_width),
+                                          MIN ((gdouble)gdk_pixbuf_get_height (priv->pixbuf) / 
priv->base_height * 0.8,
+                                               (gdouble)dest_height / priv->base_height));
                         priv->crop.width = crop_scale * priv->base_width / scale;
                         priv->crop.height = crop_scale * priv->base_height / scale;
                         priv->crop.x = (gdk_pixbuf_get_width (priv->browse_pixbuf) - priv->crop.width) / 2;


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