[Xfce4-commits] <ristretto:master> Rotate the thumbnails
Stephan Arts
noreply at xfce.org
Tue Oct 18 20:50:01 CEST 2011
Updating branch refs/heads/master
to 1930b6b1d451e823e4e3b5919453ba57f559992d (commit)
from ee7b5c7960301465e33e89a319e9751c6ad5a6e1 (commit)
commit 1930b6b1d451e823e4e3b5919453ba57f559992d
Author: Stephan Arts <stephan at xfce.org>
Date: Tue Oct 18 20:46:40 2011 +0200
Rotate the thumbnails
src/thumbnail.c | 35 +++++++++++++++++++++++++++++++----
1 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/src/thumbnail.c b/src/thumbnail.c
index 649181b..f51af27 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -184,6 +184,7 @@ rstto_thumbnail_expose(GtkWidget *widget, GdkEventExpose *event)
{
RsttoThumbnail *thumb = RSTTO_THUMBNAIL(widget);
GdkPixbuf *thumb_pixbuf = NULL;
+ GdkPixbuf *tmp_pixbuf = NULL;
if (GTK_WIDGET_REALIZED (widget))
{
@@ -209,18 +210,44 @@ rstto_thumbnail_expose(GtkWidget *widget, GdkEventExpose *event)
gint width = gdk_pixbuf_get_width (thumb->priv->pixbuf) - 10;
GdkPixbuf *dst_thumb_pixbuf = NULL;
- if (gdk_pixbuf_get_width (thumb_pixbuf) > gdk_pixbuf_get_height (thumb_pixbuf))
+ switch (rstto_file_get_orientation (thumb->priv->file))
{
- height = (gint)(((gdouble)gdk_pixbuf_get_height (thumb_pixbuf) / (gdouble)gdk_pixbuf_get_width (thumb_pixbuf)) * width);
+ case RSTTO_IMAGE_ORIENT_90:
+ tmp_pixbuf = gdk_pixbuf_rotate_simple (
+ thumb_pixbuf,
+ GDK_PIXBUF_ROTATE_CLOCKWISE);
+ break;
+ case RSTTO_IMAGE_ORIENT_180:
+ tmp_pixbuf = gdk_pixbuf_rotate_simple (
+ thumb_pixbuf,
+ GDK_PIXBUF_ROTATE_UPSIDEDOWN);
+ break;
+ case RSTTO_IMAGE_ORIENT_270:
+ tmp_pixbuf = gdk_pixbuf_rotate_simple (
+ thumb_pixbuf,
+ GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE);
+ break;
+ default:
+ tmp_pixbuf = thumb_pixbuf;
+ g_object_ref (tmp_pixbuf);
+ break;
+ }
+
+ if (gdk_pixbuf_get_width (tmp_pixbuf) > gdk_pixbuf_get_height (tmp_pixbuf))
+ {
+ height = (gint)(((gdouble)gdk_pixbuf_get_height (tmp_pixbuf) / (gdouble)gdk_pixbuf_get_width (tmp_pixbuf)) * width);
}
else
{
- width = (gint)(((gdouble)gdk_pixbuf_get_width (thumb_pixbuf) / (gdouble)gdk_pixbuf_get_height (thumb_pixbuf)) * height);
+ width = (gint)(((gdouble)gdk_pixbuf_get_width (tmp_pixbuf) / (gdouble)gdk_pixbuf_get_height (tmp_pixbuf)) * height);
}
gdk_pixbuf_fill (thumb->priv->pixbuf, 0x00000000);
- dst_thumb_pixbuf = gdk_pixbuf_scale_simple (thumb_pixbuf, width, height, GDK_INTERP_BILINEAR);
+ dst_thumb_pixbuf = gdk_pixbuf_scale_simple (tmp_pixbuf, width, height, GDK_INTERP_BILINEAR);
+
+ g_object_unref (tmp_pixbuf);
+ tmp_pixbuf = NULL;
gdk_pixbuf_copy_area (dst_thumb_pixbuf,
0, 0,
More information about the Xfce4-commits
mailing list