[f-spot/rubenv-gsoc-2009: 17/86] Fix orientation of embedded JPEG.



commit bfa168d9e2feb24244cc5cedbaea905b1496b4a1
Author: Ruben Vermeersch <ruben savanne be>
Date:   Mon Jul 20 18:12:26 2009 +0200

    Fix orientation of embedded JPEG.

 lib/libfspotraw/fspot-librawloader.cpp |    3 ++-
 lib/libfspotraw/fspot-librawloader.h   |    2 +-
 src/Loaders/LibrawImageLoader.cs       |   26 ++++++++++++++++++++++++--
 3 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/lib/libfspotraw/fspot-librawloader.cpp b/lib/libfspotraw/fspot-librawloader.cpp
index b18dd85..7132c39 100644
--- a/lib/libfspotraw/fspot-librawloader.cpp
+++ b/lib/libfspotraw/fspot-librawloader.cpp
@@ -192,7 +192,7 @@ fspot_librawloader_finalize (GObject *object)
 }
 
 GdkPixbuf *
-fspot_librawloader_load_thumbnail (FSpotLibrawLoader *self)
+fspot_librawloader_load_thumbnail (FSpotLibrawLoader *self, int *orientation)
 {
 	int result;
 	libraw_processed_image_t *image = NULL;
@@ -213,6 +213,7 @@ fspot_librawloader_load_thumbnail (FSpotLibrawLoader *self)
 	g_assert (error == NULL);
 
 	pixbuf = gdk_pixbuf_copy (gdk_pixbuf_loader_get_pixbuf (loader));
+	*orientation = self->priv->raw_proc->imgdata.sizes.flip;
 
 	return pixbuf;
 }
diff --git a/lib/libfspotraw/fspot-librawloader.h b/lib/libfspotraw/fspot-librawloader.h
index e978a81..5e25484 100644
--- a/lib/libfspotraw/fspot-librawloader.h
+++ b/lib/libfspotraw/fspot-librawloader.h
@@ -42,7 +42,7 @@ struct _FSpotLibrawLoaderClass
 };
 
 GType fspot_librawloader_get_type (void);
-GdkPixbuf * fspot_librawloader_load_thumbnail (FSpotLibrawLoader *self);
+GdkPixbuf * fspot_librawloader_load_thumbnail (FSpotLibrawLoader *self, int *orientation);
 GdkPixbuf * fspot_librawloader_load_full (FSpotLibrawLoader *self);
 FSpotLibrawLoader * fspot_librawloader_new (const gchar *filename);
 gboolean fspot_librawloader_get_aborted (FSpotLibrawLoader *self);
diff --git a/src/Loaders/LibrawImageLoader.cs b/src/Loaders/LibrawImageLoader.cs
index b900958..b2dd9eb 100644
--- a/src/Loaders/LibrawImageLoader.cs
+++ b/src/Loaders/LibrawImageLoader.cs
@@ -40,8 +40,30 @@ namespace FSpot.Loaders {
 
 		void LoadThumbnail ()
 		{
-			thumb = loader.LoadThumbnail ();
-			PixbufOrientation = PixbufOrientation.TopLeft;
+			int orientation;
+			thumb = loader.LoadThumbnail (out orientation);
+
+			switch (orientation) {
+				case 0:
+					PixbufOrientation = PixbufOrientation.TopLeft;
+					break;
+
+				case 3:
+					PixbufOrientation = PixbufOrientation.BottomRight;
+					break;
+
+				case 5:
+					PixbufOrientation = PixbufOrientation.LeftBottom;
+					break;
+
+				case 6:
+					PixbufOrientation = PixbufOrientation.RightBottom;
+					break;
+
+				default:
+					throw new Exception ("Unexpected orientation returned!");
+			}
+
 			GLib.Idle.Add (delegate {
 				EventHandler<AreaPreparedEventArgs> prep = AreaPrepared;
 				if (prep != null)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]