[Xfce4-commits] [apps/xfce4-screenshooter] 01/01: Improve thumbnail size clamping
noreply at xfce.org
noreply at xfce.org
Tue Feb 13 00:56:50 CET 2018
This is an automated email from the git hooks/post-receive script.
a n d r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-screenshooter.
commit f3277e8f4e95a0ba6c174a842becb3bdc11b9f50
Author: Andre Miranda <andreldm at xfce.org>
Date: Mon Feb 12 20:52:53 2018 -0300
Improve thumbnail size clamping
---
lib/screenshooter-dialogs.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
diff --git a/lib/screenshooter-dialogs.c b/lib/screenshooter-dialogs.c
index 5123ebf..e643fae 100644
--- a/lib/screenshooter-dialogs.c
+++ b/lib/screenshooter-dialogs.c
@@ -440,26 +440,17 @@ static void set_default_item (GtkWidget *combobox, ScreenshotData *sd)
static GdkPixbuf
*screenshot_get_thumbnail (GdkPixbuf *screenshot)
{
- gint width, height, i;
- GdkPixbuf *thumbnail;
-
- width = gdk_pixbuf_get_width (screenshot);
- height = gdk_pixbuf_get_height (screenshot);
+ gint w = gdk_pixbuf_get_width (screenshot);
+ gint h = gdk_pixbuf_get_height (screenshot);
+ gint width = THUMB_X_SIZE;
+ gint height = THUMB_Y_SIZE;
- if (width > height)
- i = width / THUMB_X_SIZE;
+ if (G_LIKELY (w >= h))
+ height = width * h / w;
else
- i = height / THUMB_Y_SIZE;
-
- if (i == 0)
- return gdk_pixbuf_copy (screenshot);
-
- thumbnail = gdk_pixbuf_scale_simple (screenshot,
- width/i,
- height/i,
- GDK_INTERP_BILINEAR);
+ width = height * w / h;
- return thumbnail;
+ return gdk_pixbuf_scale_simple (screenshot, width, height, GDK_INTERP_BILINEAR);
}
@@ -1194,14 +1185,11 @@ gchar
/* Create the preview and the thumbnail */
preview_ebox = gtk_event_box_new ();
preview = gtk_image_new ();
+ gtk_widget_set_margin_end (preview, 12);
gtk_container_add (GTK_CONTAINER (preview_ebox), preview);
gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (chooser), preview_ebox);
- thumbnail =
- gdk_pixbuf_scale_simple (screenshot,
- gdk_pixbuf_get_width(screenshot)/5,
- gdk_pixbuf_get_height(screenshot)/5,
- GDK_INTERP_BILINEAR);
+ thumbnail = screenshot_get_thumbnail (screenshot);
gtk_image_set_from_pixbuf (GTK_IMAGE (preview), thumbnail);
g_object_unref (thumbnail);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list