[f-spot/rubenv-gsoc-2009: 9/86] Add a simple thumbnail extracting loader.



commit e512dfa8fef045e0092be316964e2d1e62b01f82
Author: Ruben Vermeersch <ruben savanne be>
Date:   Sat Jul 18 18:48:48 2009 +0200

    Add a simple thumbnail extracting loader.
    
    Now I only have to figure out why it doesn't find my library.

 lib/libfspotraw-sharp/libfspotraw-sharp.dll.config |    1 +
 lib/libfspotraw-sharp/libfspotraw.sources          |    2 +-
 src/Loaders/ImageLoader.cs                         |   42 ++++++++++++++++++--
 src/Loaders/LibrawImageLoader.cs                   |   24 +++++++++--
 src/f-spot.in                                      |    2 +-
 5 files changed, 60 insertions(+), 11 deletions(-)
---
diff --git a/lib/libfspotraw-sharp/libfspotraw-sharp.dll.config b/lib/libfspotraw-sharp/libfspotraw-sharp.dll.config
index f9ccba9..d1514c0 100644
--- a/lib/libfspotraw-sharp/libfspotraw-sharp.dll.config
+++ b/lib/libfspotraw-sharp/libfspotraw-sharp.dll.config
@@ -6,4 +6,5 @@
   <dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0"/>
   <dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so.0"/>
   <dllmap dll="libgdk_pixbuf-2.0-0.dll" target="libgdk_pixbuf-2.0.so.0"/>
+  <dllmap dll="libfspotraw.dll" target="libfspotraw.so"/>
 </configuration>
diff --git a/lib/libfspotraw-sharp/libfspotraw.sources b/lib/libfspotraw-sharp/libfspotraw.sources
index 17d8476..9c72eff 100644
--- a/lib/libfspotraw-sharp/libfspotraw.sources
+++ b/lib/libfspotraw-sharp/libfspotraw.sources
@@ -1,6 +1,6 @@
 <gapi-parser-input>
 	<api filename="libfspotraw-api.raw">
-		<library name="libfspotraw-sharp.dll">
+		<library name="libfspotraw.dll">
 			<namespace name="FSpot">
 				<file>../libfspotraw/fspot-librawloader.h</file>
 			</namespace>
diff --git a/src/Loaders/ImageLoader.cs b/src/Loaders/ImageLoader.cs
index 94b20fb..3131315 100644
--- a/src/Loaders/ImageLoader.cs
+++ b/src/Loaders/ImageLoader.cs
@@ -22,10 +22,44 @@ namespace FSpot.Loaders {
 		static ImageLoader ()
 		{
 			name_table = new Dictionary<string, System.Type> ();
-			System.Type gdk_loader = typeof (GdkImageLoader);
-			foreach (string key in ImageFile.NameTable.Keys) {
-				name_table [key] = gdk_loader;
-			}
+			name_table [".svg"] = typeof (GdkImageLoader);
+			name_table [".gif"] = typeof (GdkImageLoader);
+			name_table [".bmp"] = typeof (GdkImageLoader);
+			name_table [".jpeg"] = typeof (GdkImageLoader);
+			name_table [".jpg"] = typeof (GdkImageLoader);
+			name_table [".png"] = typeof (GdkImageLoader);
+			name_table [".cr2"] = typeof (LibrawImageLoader);
+			name_table [".nef"] = typeof (GdkImageLoader);
+			name_table [".pef"] = typeof (GdkImageLoader);
+			name_table [".raw"] = typeof (GdkImageLoader);
+			name_table [".kdc"] = typeof (GdkImageLoader);
+			name_table [".arw"] = typeof (GdkImageLoader);
+			name_table [".tiff"] = typeof (GdkImageLoader);
+			name_table [".tif"] = typeof (GdkImageLoader);
+			name_table [".orf"] =  typeof (GdkImageLoader);
+			name_table [".srf"] = typeof (GdkImageLoader);
+			name_table [".dng"] = typeof (LibrawImageLoader);
+			name_table [".crw"] = typeof (GdkImageLoader);
+			name_table [".ppm"] = typeof (GdkImageLoader);
+			name_table [".mrw"] = typeof (GdkImageLoader);
+			name_table [".raf"] = typeof (GdkImageLoader);
+			name_table [".x3f"] = typeof (GdkImageLoader);
+
+			// add mimetypes for fallback
+			name_table ["image/bmp"]     = name_table ["image/x-bmp"] = name_table [".bmp"];
+			name_table ["image/gif"]     = name_table [".gif"];
+			name_table ["image/pjpeg"]   = name_table ["image/jpeg"] = name_table ["image/jpg"] = name_table [".jpg"];
+			name_table ["image/x-png"]   = name_table ["image/png"]  = name_table [".png"];
+			name_table ["image/svg+xml"] = name_table [".svg"];
+			name_table ["image/tiff"]    = name_table [".tiff"];
+			name_table ["image/x-dcraw"] = name_table [".raw"];
+			name_table ["image/x-ciff"]  = name_table [".crw"];
+			name_table ["image/x-mrw"]   = name_table [".mrw"];
+			name_table ["image/x-x3f"]   = name_table [".x3f"];
+			name_table ["image/x-orf"]   = name_table [".orf"];
+			name_table ["image/x-nef"]   = name_table [".nef"];
+			name_table ["image/x-cr2"]   = name_table [".cr2"];
+			name_table ["image/x-raf"]   = name_table [".raf"];
 
 			//as xcf pixbufloader is not part of gdk-pixbuf, check if it's there,
 			//and enable it if needed.
diff --git a/src/Loaders/LibrawImageLoader.cs b/src/Loaders/LibrawImageLoader.cs
index 3d07b81..87f9a7d 100644
--- a/src/Loaders/LibrawImageLoader.cs
+++ b/src/Loaders/LibrawImageLoader.cs
@@ -16,7 +16,10 @@ using FSpot.Loaders.Native;
 
 namespace FSpot.Loaders {
 	public class LibrawImageLoader : IImageLoader {
-		Uri uri = null;
+		NativeLibrawLoader loader;
+		Uri uri;
+		bool is_disposed = false;
+		bool is_loading = false;
 
 		public void Load (Uri uri)
 		{
@@ -24,6 +27,19 @@ namespace FSpot.Loaders {
 				throw new Exception ("You should only request one image per loader!");
 			this.uri = uri;
 
+			if (is_disposed)
+				return;
+
+			loader = new NativeLibrawLoader (uri.AbsolutePath);
+
+			Pixbuf thumb = loader.LoadThumbnail ();
+			PixbufOrientation = PixbufOrientation.TopLeft;
+			EventHandler<AreaPreparedEventArgs> prep = AreaPrepared;
+			if (prep != null)
+				prep (this, new AreaPreparedEventArgs (true));
+			EventHandler<AreaUpdatedEventArgs> upd = AreaUpdated;
+			if (upd != null)
+				upd (this, new AreaUpdatedEventArgs (new Rectangle (0, 0, thumb.Width, thumb.Height)));
 		}
 
 		public event EventHandler<AreaPreparedEventArgs> AreaPrepared;
@@ -31,7 +47,7 @@ namespace FSpot.Loaders {
 		public event EventHandler Completed;
 
 		public bool Loading {
-			get { throw new Exception ("Not implemented yet!"); }
+			get { return is_loading; }
 		}
 
 		public void Dispose ()
@@ -43,8 +59,6 @@ namespace FSpot.Loaders {
 			get { throw new Exception ("Not implemented yet!"); }
 		}
 
-		public PixbufOrientation PixbufOrientation {
-			get { throw new Exception ("Not implemented yet!"); }
-		}
+		public PixbufOrientation PixbufOrientation { get; private set; }
 	}
 }
diff --git a/src/f-spot.in b/src/f-spot.in
index 269bf82..c47e4fd 100644
--- a/src/f-spot.in
+++ b/src/f-spot.in
@@ -55,7 +55,7 @@ for arg in "$@"; do
 	x--uninstalled)
 	    echo "*** Running uninstalled f-spot ***"
 	    EXE_TO_RUN="./f-spot.exe"
-	    export MONO_PATH=../lib/libgphoto2-sharp:../lib/semweb:../lib/gio-sharp/gio:../lib/gtk-sharp-beans:../lib/unique-sharp/unique:$MONO_PATH
+	    export MONO_PATH=../lib/libgphoto2-sharp:../lib/semweb:../lib/gio-sharp/gio:../lib/gtk-sharp-beans:../lib/libfspotraw-sharp:../lib/libfspotraw:$MONO_PATH
 	    ;;
     esac
 done



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