summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2014-11-25 15:32:40 +0100
committerOndrej Holy <oholy@redhat.com>2014-11-25 16:24:41 +0100
commit1fd46c2e633e426945fd3b6437ccc5b37f49ff1d (patch)
treea81c912207f3932b04e3b2080025d38cdb53acec
parentab2084a3eaa0fda7760bdc70ca4c3f12e71f4a3e (diff)
Refactor crop area scaling code
Recently committed patch f9d576e was modified before applying it into the g-c-c to be more readable. This patch reflect those changes in cheese. https://bugzilla.gnome.org/show_bug.cgi?id=739870
-rw-r--r--libcheese/um-crop-area.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libcheese/um-crop-area.c b/libcheese/um-crop-area.c
index 1c076a13..531408c9 100644
--- a/libcheese/um-crop-area.c
+++ b/libcheese/um-crop-area.c
@@ -183,13 +183,15 @@ update_pixbufs (UmCropArea *area)
shift_colors (priv->color_shifted, -32, -32, -32, 0);
if (priv->scale == 0.0) {
- gdouble crop_scale;
+ gdouble scale_to_80, scale_to_image, crop_scale;
/* 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));
+ scale_to_80 = MIN ((gdouble)gdk_pixbuf_get_width (priv->pixbuf) * 0.8 / priv->base_width,
+ (gdouble)gdk_pixbuf_get_height (priv->pixbuf) * 0.8 / priv->base_height);
+ scale_to_image = MIN ((gdouble)dest_width / priv->base_width,
+ (gdouble)dest_height / priv->base_height);
+ crop_scale = MIN (scale_to_80, scale_to_image);
+
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;