[Xfce4-commits] <ristretto:master> Implement hack to check if the image has been rotated

Stephan Arts stephan at xfce.org
Wed Aug 12 12:20:16 CEST 2009


Updating branch refs/heads/master
         to 20f7ffbc978263b6dff3a6ac5040909a38f9b402 (commit)
       from 41f49ce624d31417b35e1f8b171148fda8ca5269 (commit)

commit 20f7ffbc978263b6dff3a6ac5040909a38f9b402
Author: Stephan Arts <stephan at xfce.org>
Date:   Thu Apr 30 23:30:32 2009 +0200

    Implement hack to check if the image has been rotated

 ChangeLog            |    6 ++++
 src/picture_viewer.c |   65 +++++++++++++++++++++++++++++++++-----------------
 2 files changed, 49 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e690db2..b8c1401 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-04-30  Stephan Arts <stephan at xfce.org>
 
+	* src/picture_viewer.c: Implement a hack to check if the pixbuf has
+	been rotated.
+
+
+2009-04-30  Stephan Arts <stephan at xfce.org>
+
 	* src/main_window.c
 	  src/main_window_ui.xml: Add Sticky button to the fullscreen-toolbar.
 
diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index 85c5eb8..59b6f30 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -972,31 +972,52 @@ cb_rstto_picture_viewer_queued_repaint (RsttoPictureViewer *viewer)
         image_width = (gdouble)rstto_image_get_width (viewer->priv->image);
         image_height = (gdouble)rstto_image_get_height (viewer->priv->image);
 
-        p_src_pixbuf = rstto_image_get_pixbuf (viewer->priv->image);
-        if (p_src_pixbuf)
+        switch (viewer->priv->state)
         {
-            pixbuf_width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
-            pixbuf_height = (gdouble)gdk_pixbuf_get_height (p_src_pixbuf);
-
-            image_scale = pixbuf_width / image_width;
-        }
-        if (viewer->priv->state != RSTTO_PICTURE_VIEWER_STATE_NORMAL)
-        {
-            switch (viewer->priv->state)
-            {
-                case RSTTO_PICTURE_VIEWER_STATE_PREVIEW:
-                    p_src_pixbuf = rstto_image_get_thumbnail (viewer->priv->image);
-                    if (p_src_pixbuf)
+            case RSTTO_PICTURE_VIEWER_STATE_NORMAL:
+                p_src_pixbuf = rstto_image_get_pixbuf (viewer->priv->image);
+                if (p_src_pixbuf)
+                {
+                    pixbuf_width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
+                    pixbuf_height = (gdouble)gdk_pixbuf_get_height (p_src_pixbuf);
+
+                    /** HACK HACK HACK
+                      * Because the image-dimensions do not get modified when the image is rotated,
+                      * we have to check here... and fix it ourselves
+                      */
+                    if ((((pixbuf_width / pixbuf_height) > 1) && ((image_width / image_height < 1))) ||
+                        (((pixbuf_width / pixbuf_height) < 1) && ((image_width / image_height > 1))))
                     {
-                        thumb_width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
-                        thumb_scale = (thumb_width / image_width);
+                        gdouble tmp_width = image_width;
+                        image_width = image_height;
+                        image_height = tmp_width;
                     }
-                    else
-                        return;
-                    break;
-                default:
-                    break;
-            }
+                    image_scale = pixbuf_width / image_width;
+                }
+                break;
+            case RSTTO_PICTURE_VIEWER_STATE_PREVIEW:
+                p_src_pixbuf = rstto_image_get_thumbnail (viewer->priv->image);
+                if (p_src_pixbuf)
+                {
+                    thumb_width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
+                    /** HACK HACK HACK
+                      * Because the image-dimensions do not get modified when the image is rotated,
+                      * we have to check here... and fix it ourselves
+                      */
+                    if ((((pixbuf_width / pixbuf_height) > 1) && ((image_width / image_height < 1))) ||
+                        (((pixbuf_width / pixbuf_height) < 1) && ((image_width / image_height > 1))))
+                    {
+                        gdouble tmp_width = image_width;
+                        image_width = image_height;
+                        image_height = tmp_width;
+                    }
+                    thumb_scale = (thumb_width / image_width);
+                }
+                else
+                    return;
+                break;
+            default:
+                break;
         }
 
         p_scale = g_object_get_data (G_OBJECT (viewer->priv->image), "viewer-scale");



More information about the Xfce4-commits mailing list