summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2014-11-10 09:04:59 +0100
committerDavid King <amigadave@amigadave.com>2014-11-10 18:22:36 +0000
commitf9d576e6420720d8a1f8c4cf77fa892e8ec8a76f (patch)
tree3925021ad84f935301d8b3034d86ea592d2afb03
parentc3ec46c4d22d400ffa0ff692ab6aac888bea5eee (diff)
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
-rw-r--r--libcheese/um-crop-area.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libcheese/um-crop-area.c b/libcheese/um-crop-area.c
index c25fff8c..1c076a13 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;