[f-spot/rubenv-gsoc-2009: 78/86] Completely kill the old way of loading.



commit 3e3646b905cce4588da4ddc7d84aa1e65c177130
Author: Ruben Vermeersch <ruben savanne be>
Date:   Thu Aug 13 20:22:20 2009 +0200

    Completely kill the old way of loading.
    
    Everything goes through IImageLoader now!

 extensions/Exporters/PicasaWebExport/Makefile.am   |    1 +
 .../Exporters/PicasaWebExport/PicasaWebExport.cs   |    6 ++-
 src/Filters/SharpFilter.cs                         |   56 ++++++++++++--------
 src/Imaging/Ciff.cs                                |    8 ---
 src/Imaging/ImageFile.cs                           |   28 +---------
 src/Imaging/MrwFile.cs                             |   12 ----
 src/Imaging/PnmFile.cs                             |   18 ------
 src/Imaging/RafFile.cs                             |   14 -----
 src/Imaging/SvgFile.cs                             |   15 +-----
 src/MainWindow.cs                                  |   10 +++-
 src/Makefile.am                                    |    1 -
 src/PhotoImageView.cs                              |   29 ++---------
 src/PrintOperation.cs                              |    7 ++-
 src/RotateCommand.cs                               |   12 +++--
 src/SlideView.cs                                   |    6 ++-
 src/ThumbnailGenerator.cs                          |   30 +---------
 src/UI.Dialog/EditTagIconDialog.cs                 |    7 ++-
 src/Widgets/ImageInfo.cs                           |   10 ++--
 src/Widgets/InfoBox.cs                             |   12 +++-
 src/Widgets/SlideShow.cs                           |    7 ++-
 20 files changed, 98 insertions(+), 191 deletions(-)
---
diff --git a/extensions/Exporters/PicasaWebExport/Makefile.am b/extensions/Exporters/PicasaWebExport/Makefile.am
index a1fe340..aad1668 100644
--- a/extensions/Exporters/PicasaWebExport/Makefile.am
+++ b/extensions/Exporters/PicasaWebExport/Makefile.am
@@ -13,6 +13,7 @@ REFS =						\
 	-r:$(top_builddir)/src/f-spot.exe	\
 	-r:$(top_builddir)/src/FSpot.Core.dll	\
 	-r:$(top_builddir)/src/FSpot.Utils.dll	\
+	-r:$(top_builddir)/src/FSpot.Loaders.dll	\
 	-r:$(top_builddir)/src/FSpot.Imaging.dll	\
 	$(LINK_SEMWEB)				\
 	-r:google-sharp/Mono.Google.dll		\
diff --git a/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs b/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs
index 31e13df..f075330 100644
--- a/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs
+++ b/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs
@@ -19,6 +19,7 @@ using Mono.Unix;
 using FSpot;
 using FSpot.Filters;
 using FSpot.Widgets;
+using FSpot.Loaders;
 using FSpot.Utils;
 using FSpot.UI.Dialog;
 
@@ -285,8 +286,9 @@ namespace FSpotGoogleExport {
 
 			if (show_captcha) {
 				try {
-					using  (ImageFile img = ImageFile.Create(new Uri(captcha_exception.CaptchaUrl))) {
-						captcha_image.Pixbuf = img.Load();
+					using (IImageLoader loader = ImageLoader.Create (new Uri (captcha_exception.CaptchaUrl))) {
+						loader.Load (ImageLoaderItem.Full);
+						captcha_image.Pixbuf = loader.Full;
 						token = captcha_exception.Token;
 					}
 				} catch (Exception) {}
diff --git a/src/Filters/SharpFilter.cs b/src/Filters/SharpFilter.cs
index 1fa3087..6028212 100644
--- a/src/Filters/SharpFilter.cs
+++ b/src/Filters/SharpFilter.cs
@@ -13,6 +13,7 @@ using System.IO;
 using Gdk;
 
 using FSpot.Imaging;
+using FSpot.Loaders;
 
 using Mono.Unix;
 
@@ -32,35 +33,46 @@ namespace FSpot.Filters {
 		{
 			Uri dest_uri = req.TempUri (System.IO.Path.GetExtension (req.Current.LocalPath));
 
-			using (ImageFile img = ImageFile.Create (req.Current)) {
-				using (Pixbuf in_pixbuf = img.Load ()) {
-					using (Pixbuf out_pixbuf = PixbufUtils.UnsharpMask (in_pixbuf, radius, amount, threshold)) {
-						string destination_extension = Path.GetExtension (dest_uri.LocalPath);
-		
-						if (Path.GetExtension (req.Current.LocalPath).ToLower () == Path.GetExtension (dest_uri.LocalPath).ToLower () && img is IWritableImageFile) {
-							using (Stream output = File.OpenWrite (dest_uri.LocalPath)) {
-								(img as IWritableImageFile).Save (out_pixbuf, output);
-							}
-						} else if (destination_extension == ".jpg") {
-							// FIXME this is a bit of a nasty hack to work around
-							// the lack of being able to change the path in this filter
-							// and the lack of proper metadata copying yuck
-							Exif.ExifData exif_data;
-		
-							exif_data = new Exif.ExifData (req.Current.LocalPath);
-							
-							FSpotPixbufUtils.SaveJpeg (out_pixbuf, dest_uri.LocalPath, 90, exif_data);
-						} else 
-							throw new NotImplementedException (String.Format (Catalog.GetString ("No way to save files of type \"{0}\""), destination_extension));
-						
+			ImageFile img = null;
+			IImageLoader loader = null;
+			Pixbuf in_pixbuf = null;
+			Pixbuf out_pixbuf = null;
+			try {
+				img = ImageFile.Create (req.Current);
+				loader = ImageLoader.Create (req.Current);
+				loader.Load (ImageLoaderItem.Full);
+
+				in_pixbuf = loader.Full;
+				out_pixbuf = PixbufUtils.UnsharpMask (in_pixbuf, radius, amount, threshold);
+				string destination_extension = Path.GetExtension (dest_uri.LocalPath);
+
+				if (Path.GetExtension (req.Current.LocalPath).ToLower () == Path.GetExtension (dest_uri.LocalPath).ToLower () && img is IWritableImageFile) {
+					using (Stream output = File.OpenWrite (dest_uri.LocalPath)) {
+						(img as IWritableImageFile).Save (out_pixbuf, output);
 					}
+				} else if (destination_extension == ".jpg") {
+					// FIXME this is a bit of a nasty hack to work around
+					// the lack of being able to change the path in this filter
+					// and the lack of proper metadata copying yuck
+					Exif.ExifData exif_data;
+
+					exif_data = new Exif.ExifData (req.Current.LocalPath);
+
+					FSpotPixbufUtils.SaveJpeg (out_pixbuf, dest_uri.LocalPath, 90, exif_data);
+				} else  {
+					// TODO: Implement the saving like in ResizeFilter.
+					throw new NotImplementedException (String.Format (Catalog.GetString ("No way to save files of type \"{0}\""), destination_extension));
 				}
+			} finally {
+				if (img != null) img.Dispose ();
+				if (loader != null) loader.Dispose ();
+				if (in_pixbuf != null) in_pixbuf.Dispose ();
+				if (out_pixbuf != null) out_pixbuf.Dispose ();
 			}
 
 			req.Current = dest_uri;
 			return true;
 		}
-
 	}
 }
 
diff --git a/src/Imaging/Ciff.cs b/src/Imaging/Ciff.cs
index f1b6f68..2114d31 100644
--- a/src/Imaging/Ciff.cs
+++ b/src/Imaging/Ciff.cs
@@ -456,14 +456,6 @@ namespace FSpot.Ciff {
 				return DCRawFile.RawPixbufStream (uri);
 		}
 
-		public override Gdk.Pixbuf Load (int width, int height)
-		{
-			Gdk.Pixbuf full = this.Load ();
-			Gdk.Pixbuf scaled  = PixbufUtils.ScaleToMaxSize (full, width, height);
-			full.Dispose ();
-			return scaled;
-		}
-
 		public void Dump ()
 		{
 			Root.Dump ();
diff --git a/src/Imaging/ImageFile.cs b/src/Imaging/ImageFile.cs
index 0f63717..6b255a7 100644
--- a/src/Imaging/ImageFile.cs
+++ b/src/Imaging/ImageFile.cs
@@ -136,33 +136,7 @@ namespace FSpot {
 			
 			return rotated;
 		}
-		
-		[Obsolete ("Use an Async way to load the pixbuf")]
-		public virtual Gdk.Pixbuf Load ()
-		{
-			using (Stream stream = PixbufStream ()) {
-				Gdk.Pixbuf orig = new Gdk.Pixbuf (stream);
-				return TransformAndDispose (orig);
-			}
-		}
-		
-		[Obsolete ("Use an Async way to load the pixbuf")]
-		public virtual Gdk.Pixbuf Load (int max_width, int max_height)
-		{
-			System.IO.Stream stream = PixbufStream ();
-			if (stream == null) {
-				Gdk.Pixbuf orig = this.Load ();
-				Gdk.Pixbuf scaled = PixbufUtils.ScaleToMaxSize (orig,  max_width, max_height, false);
-				orig.Dispose ();
-				return scaled;
-			}
 
-			using (stream) {
-				PixbufUtils.AspectLoader aspect = new PixbufUtils.AspectLoader (max_width, max_height);
-				return aspect.Load (stream, Orientation);
-			}	
-		}
-	
 		public virtual PixbufOrientation GetOrientation () 
 		{
 			return PixbufOrientation.TopLeft;
diff --git a/src/Imaging/MrwFile.cs b/src/Imaging/MrwFile.cs
index 7bd3c6b..07dae42 100644
--- a/src/Imaging/MrwFile.cs
+++ b/src/Imaging/MrwFile.cs
@@ -218,18 +218,6 @@ namespace FSpot.Mrw {
 			return DCRawFile.RawPixbufStream (uri);
 		}
 		
-		public override Gdk.Pixbuf Load ()
-		{
-			using (System.IO.Stream stream = Open ()) {
-				return new Gdk.Pixbuf (PixbufStream ());
-			}
-		}
-
-		public override Gdk.Pixbuf Load (int width, int height)
-		{
-			return PixbufUtils.ScaleToMaxSize (this.Load (), width, height);
-		}
-
 		protected void LoadBlocks () 
 		{
 			using (System.IO.Stream file = Open ()) {
diff --git a/src/Imaging/PnmFile.cs b/src/Imaging/PnmFile.cs
index da6f0b5..8ca1c50 100644
--- a/src/Imaging/PnmFile.cs
+++ b/src/Imaging/PnmFile.cs
@@ -207,24 +207,6 @@ namespace FSpot.Pnm {
 			}			
 		}
 
-		public override Gdk.Pixbuf Load ()
-		{
-			try {
-				using (Stream stream = Open ()) {
-					Gdk.Pixbuf pixbuf = PnmFile.Load (stream);
-					return pixbuf;
-				}
-			} catch (System.Exception e) {
-				System.Console.WriteLine (e.ToString ());
-			}
-			return null;
-		}
-
-		public override Gdk.Pixbuf Load (int width, int height)
-		{
-			return PixbufUtils.ScaleToMaxSize (this.Load (), width, height);
-		}
-
 		public void Save (Gdk.Pixbuf pixbuf, System.IO.Stream stream)
 		{
 			if (pixbuf.HasAlpha)
diff --git a/src/Imaging/RafFile.cs b/src/Imaging/RafFile.cs
index 29f333b..cb63a00 100644
--- a/src/Imaging/RafFile.cs
+++ b/src/Imaging/RafFile.cs
@@ -72,20 +72,6 @@ namespace FSpot.Raf {
 				return DCRawFile.RawPixbufStream (uri);
 		}
  
-		public override Gdk.Pixbuf Load ()
-		{
-			return new Gdk.Pixbuf (PixbufStream ());
-		}
-
-		public override Gdk.Pixbuf Load (int width, int height)
-		{
-			Gdk.Pixbuf full = this.Load ();
-			Gdk.Pixbuf rotated = FSpot.Utils.PixbufUtils.TransformOrientation (full, this.GetOrientation());
-			Gdk.Pixbuf scaled  = PixbufUtils.ScaleToMaxSize (rotated, width, height);
-			full.Dispose ();
-			return scaled;
-		}
-
 		public void Select (SemWeb.StatementSink sink)
 		{
 			byte [] data = GetEmbeddedJpeg ();
diff --git a/src/Imaging/SvgFile.cs b/src/Imaging/SvgFile.cs
index 428758f..9e411b9 100644
--- a/src/Imaging/SvgFile.cs
+++ b/src/Imaging/SvgFile.cs
@@ -30,7 +30,7 @@ namespace FSpot.Svg {
 			}
 		}
 
-		public void Load (System.IO.Stream stream)
+		void Load (System.IO.Stream stream)
 		{
 			try {
 				store.Import (new SemWeb.RdfXmlReader (stream));
@@ -41,19 +41,6 @@ namespace FSpot.Svg {
 			}
 		}
 
-#if BROKEN_RSVG
-		public override Gdk.Pixbuf Load (int max_width, int max_height)
-		{
-			// FIXME this is a hack to work around a crash in the scaled
-			// gdk pixbuf rsvg loader.  We load it without scaling it then scale the image
-			using (System.IO.Stream stream = Open ()) {
-				using (Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (stream)) {
-					Gdk.Pixbuf scaled = PixbufUtils.ScaleToMaxSize (pixbuf, max_width, max_height);
-					return scaled;
-				}
-			}
-		}
-#endif
 		public void Select (SemWeb.StatementSink sink)
 		{
 			Store.Select (sink);
diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index abe1a87..8b0dfa7 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -23,6 +23,7 @@ using FSpot;
 using FSpot.Extensions;
 using FSpot.Query;
 using FSpot.Widgets;
+using FSpot.Loaders;
 using FSpot.Utils;
 using FSpot.UI.Dialog;
 using FSpot.Platform;
@@ -942,9 +943,12 @@ namespace FSpot
 				// FIXME this needs a lot more work.
 				Pixbuf icon = null;
 				try {
-					Pixbuf tmp = FSpot.PhotoLoader.LoadAtMaxSize (query [nums[0]], 128, 128);
-					icon = FSpotPixbufUtils.TagIconFromPixbuf (tmp);
-					tmp.Dispose ();
+					using (IImageLoader loader = ImageLoader.Create (query [nums[0]].DefaultVersion.Uri)) {
+						loader.Load (ImageLoaderItem.Thumbnail);
+						using (Pixbuf thumb = loader.Thumbnail)
+							using (Pixbuf tmp = PixbufUtils.ScaleToMaxSize (thumb, 128, 128))
+							icon = FSpotPixbufUtils.TagIconFromPixbuf (tmp);
+					}
 				} catch {
 					icon = null;
 				}
diff --git a/src/Makefile.am b/src/Makefile.am
index 35d6e09..c09f6f3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -251,7 +251,6 @@ F_SPOT_CSDISTFILES =				\
 	$(srcdir)/MetaStore.cs			\
 	$(srcdir)/PhotoEventArgs.cs		\
 	$(srcdir)/PhotoImageView.cs		\
-	$(srcdir)/PhotoLoader.cs		\
 	$(srcdir)/PhotoPopup.cs			\
 	$(srcdir)/PhotoQuery.cs			\
 	$(srcdir)/PhotoStore.cs			\
diff --git a/src/PhotoImageView.cs b/src/PhotoImageView.cs
index cff0e22..af8dcfe 100644
--- a/src/PhotoImageView.cs
+++ b/src/PhotoImageView.cs
@@ -301,29 +301,8 @@ namespace FSpot.Widgets {
 				ChangeImage (Loader.Pixbuf (current_item), Accelerometer.GetViewOrientation (Loader.PixbufOrientation (current_item)), false, false);
 			}
 
-			if (Pixbuf == null) {
-				// FIXME: Do we have test cases for this ???
-
-				// FIXME in some cases the image passes completely through the
-				// pixbuf loader without properly loading... I'm not sure what to do about this other
-				// than try to load the image one last time.
-				try {
-					Log.Warning ("Falling back to file loader");
-					Pixbuf = PhotoLoader.Load (item.Collection, item.Index);
-				} catch (Exception e) {
-					LoadErrorImage (e);
-				}
-			}
-
-			if (loader.Pixbuf != null) //FIXME: this test in case the photo was loaded with the direct loader
-				PixbufOrientation = Accelerometer.GetViewOrientation (loader.PixbufOrientation);
-			else
-				PixbufOrientation = PixbufOrientation.TopLeft;
-
 			if (Pixbuf == null)
-				LoadErrorImage (null);
-			else
-				ZoomFit ();
+				LoadErrorImage ();
 
 			progressive_display = true;
 
@@ -346,7 +325,7 @@ namespace FSpot.Widgets {
 			get { return progressive_display; }
 		}
 
-		void LoadErrorImage (System.Exception e)
+		void LoadErrorImage ()
 		{
 			// FIXME we should check the exception type and do something
 			// like offer the user a chance to locate the moved file and
@@ -392,10 +371,10 @@ namespace FSpot.Widgets {
 				if (Item.IsValid) 
 					Load (Item.Current.DefaultVersion.Uri);
 				else
-					LoadErrorImage (null);
+					LoadErrorImage ();
 			} catch (System.Exception e) {
 				Log.DebugException (e);
-				LoadErrorImage (e);
+				LoadErrorImage ();
 			}
 			
 			Selection = Gdk.Rectangle.Zero;
diff --git a/src/PrintOperation.cs b/src/PrintOperation.cs
index 83d6b75..1aefe29 100644
--- a/src/PrintOperation.cs
+++ b/src/PrintOperation.cs
@@ -14,6 +14,7 @@ using Mono.Unix;
 
 using FSpot.Widgets;
 using FSpot.Utils;
+using FSpot.Loaders;
 
 namespace FSpot
 {
@@ -114,7 +115,11 @@ namespace FSpot
 					{
 						Gdk.Pixbuf pixbuf;
 						try {
-							pixbuf = img.Load ((int) mx, (int) my);
+							using (IImageLoader loader = ImageLoader.Create (selected_photos[p_index].DefaultVersionUri)) {
+								loader.Load (ImageLoaderItem.Full);
+								using (Gdk.Pixbuf full = loader.Full)
+									pixbuf = PixbufUtils.ScaleToMaxSize (full, (int) mx, (int) my);
+							}
 							Cms.Profile printer_profile;
 							if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE), out printer_profile)) 
 								FSpot.ColorManagement.ApplyProfile (pixbuf, img.GetProfile (), printer_profile);
diff --git a/src/RotateCommand.cs b/src/RotateCommand.cs
index bc2484f..0a19554 100644
--- a/src/RotateCommand.cs
+++ b/src/RotateCommand.cs
@@ -17,6 +17,7 @@ using Gdk;
 using FSpot;
 using FSpot.Png;
 using FSpot.Imaging;
+using FSpot.Loaders;
 using FSpot.UI.Dialog;
 
 using FSpot.Utils;
@@ -99,10 +100,13 @@ namespace FSpot {
 
 					string backup = ImageFile.TempPath (original_path);
 					using (Stream stream = File.Open (backup, FileMode.Truncate, FileAccess.Write)) {
-						using (Pixbuf pixbuf = img.Load ()) {
-							PixbufOrientation fake = (direction == RotateDirection.Clockwise) ? PixbufOrientation.RightTop : PixbufOrientation.LeftBottom;
-							using (Pixbuf rotated = FSpot.Utils.PixbufUtils.TransformOrientation (pixbuf, fake)) {
-								(img as IWritableImageFile).Save (rotated, stream);
+						using (IImageLoader loader = ImageLoader.Create (UriUtils.PathToFileUri (original_path))) {
+							loader.Load (ImageLoaderItem.Full);
+							using (Pixbuf pixbuf = loader.Large) {
+								PixbufOrientation fake = (direction == RotateDirection.Clockwise) ? PixbufOrientation.RightTop : PixbufOrientation.LeftBottom;
+								using (Pixbuf rotated = FSpot.Utils.PixbufUtils.TransformOrientation (pixbuf, fake)) {
+									(img as IWritableImageFile).Save (rotated, stream);
+								}
 							}
 						}
 					}
diff --git a/src/SlideView.cs b/src/SlideView.cs
index 352df37..4cfad20 100644
--- a/src/SlideView.cs
+++ b/src/SlideView.cs
@@ -5,6 +5,7 @@ using GLib;
 using System.Runtime.InteropServices;
 using FSpot;
 using FSpot.Utils;
+using FSpot.Loaders;
 
 namespace FSpot {
 	public class XScreenSaverSlide : Gtk.Window {
@@ -343,7 +344,10 @@ namespace FSpot {
 		{
 			Pixbuf orig;
 			try { 
-				orig = FSpot.PhotoLoader.LoadAtMaxSize (photo, Allocation.Width, Allocation.Height);
+				using (IImageLoader loader = ImageLoader.Create (photo.DefaultVersionUri)) {
+					loader.Load (ImageLoaderItem.Full);
+					orig = loader.Full;
+				}
 			} catch {
 				orig = null;
 			}
diff --git a/src/ThumbnailGenerator.cs b/src/ThumbnailGenerator.cs
index 385e3f1..f92a83b 100644
--- a/src/ThumbnailGenerator.cs
+++ b/src/ThumbnailGenerator.cs
@@ -28,35 +28,11 @@ namespace FSpot {
 
 		public static Gdk.Pixbuf Create (Uri uri)
 		{
-			try {
-				Gdk.Pixbuf thumb;
-
-				using (ImageFile img = ImageFile.Create (uri)) {
-					thumb = img.Load (256, 256);
-				}
-				using (IImageLoader loader = ImageLoader.Create (uri)) {
-					loader.Load (ImageLoaderItem.Thumbnail);
-					thumb = loader.Thumbnail;
-				}
-
-				if (thumb == null)
-					return null;
-
-				try { //Setting the thumb options
-					GFileInfo info = GLib.FileFactory.NewForUri (uri).QueryInfo ("time::modified", GLib.FileQueryInfoFlags.None, null);
-					DateTime mtime = NativeConvert.ToDateTime ((long)info.GetAttributeULong ("time::modified"));
-
-					thumb.SetOption (ThumbUri, UriUtils.UriToStringEscaped (uri));
-					thumb.SetOption (ThumbMTime, ((uint)GLib.Marshaller.DateTimeTotime_t (mtime)).ToString ());
-				} catch (System.Exception e) {
-					Log.Exception (e);
-				}
-
+			using (IImageLoader loader = ImageLoader.Create (uri)) {
+				loader.Load (ImageLoaderItem.Thumbnail);
+				Gdk.Pixbuf thumb = loader.Thumbnail;
 				Save (thumb, uri);
 				return thumb;
-			} catch (Exception e) {
-				Log.Exception (e);
-				return null;
 			}
 		}
 		
diff --git a/src/UI.Dialog/EditTagIconDialog.cs b/src/UI.Dialog/EditTagIconDialog.cs
index cdcd683..52c7f2b 100644
--- a/src/UI.Dialog/EditTagIconDialog.cs
+++ b/src/UI.Dialog/EditTagIconDialog.cs
@@ -16,6 +16,7 @@ using Mono.Unix;
 using Gtk;
 using FSpot.Widgets;
 using FSpot.Utils;
+using FSpot.Loaders;
 
 namespace FSpot.UI.Dialog
 {
@@ -159,10 +160,10 @@ namespace FSpot.UI.Dialog
 		void CreateTagIconFromExternalPhoto ()
 		{
 			try {
-				using (FSpot.ImageFile img = FSpot.ImageFile.Create (new Uri(external_photo_chooser.Uri))) {
-					using (Gdk.Pixbuf external_image = img.Load ()) {
+				using (IImageLoader loader = ImageLoader.Create (new Uri (external_photo_chooser.Uri))) {
+					loader.Load (ImageLoaderItem.Large);
+					using (Gdk.Pixbuf external_image = loader.Large)
 						PreviewPixbuf = FSpotPixbufUtils.TagIconFromPixbuf (external_image);
-					}
 				}
 			} catch (Exception) {
 				string caption = Catalog.GetString ("Unable to load image");
diff --git a/src/Widgets/ImageInfo.cs b/src/Widgets/ImageInfo.cs
index 64c90cd..4ae3b50 100644
--- a/src/Widgets/ImageInfo.cs
+++ b/src/Widgets/ImageInfo.cs
@@ -11,6 +11,7 @@ using Cairo;
 using Gdk;
 using Gtk;
 using FSpot.Utils;
+using FSpot.Loaders;
 
 namespace FSpot.Widgets {
 	public class ImageInfo : IDisposable {
@@ -19,11 +20,12 @@ namespace FSpot.Widgets {
 		
 		public ImageInfo (Uri uri)
 		{
-				using (ImageFile img = ImageFile.Create (uri)) {
-					Pixbuf pixbuf = img.Load ();
+			using (IImageLoader loader = ImageLoader.Create (uri)) {
+				loader.Load (ImageLoaderItem.Full);
+				using (Gdk.Pixbuf pixbuf = loader.Full)
 					SetPixbuf (pixbuf);
-					pixbuf.Dispose ();
-				}
+
+			}
 		}
 		
 		public ImageInfo (Pixbuf pixbuf)
diff --git a/src/Widgets/InfoBox.cs b/src/Widgets/InfoBox.cs
index 2130ac3..2563dca 100644
--- a/src/Widgets/InfoBox.cs
+++ b/src/Widgets/InfoBox.cs
@@ -20,6 +20,7 @@ using FSpot;
 using SemWeb;
 using Mono.Unix;
 using FSpot.Utils;
+using FSpot.Loaders;
 using GLib;
 using GFile = GLib.File;
 using GFileInfo = GLib.FileInfo;
@@ -707,9 +708,14 @@ namespace FSpot.Widgets
 			int max = histogram_expander.Allocation.Width;
 
 			try {
-				if (hint == null)
-					using (ImageFile img = ImageFile.Create (photo.DefaultVersion.Uri))
-						hint = img.Load (256, 256);
+				if (hint == null) {
+					using (IImageLoader loader = ImageLoader.Create (photo.DefaultVersion.Uri)) {
+						loader.Load (ImageLoaderItem.Large);
+
+						using (Gdk.Pixbuf large = loader.Large)
+							hint = PixbufUtils.ScaleToMaxSize (large, 256, 256);
+					}
+				}
 				
 				histogram_image.Pixbuf = histogram.Generate (hint, max);
 				
diff --git a/src/Widgets/SlideShow.cs b/src/Widgets/SlideShow.cs
index 2a6430d..2154c6d 100644
--- a/src/Widgets/SlideShow.cs
+++ b/src/Widgets/SlideShow.cs
@@ -14,6 +14,7 @@ using Gtk;
 using Gdk;
 using Mono.Addins;
 using FSpot.Bling;
+using FSpot.Loaders;
 using FSpot.Extensions;
 
 namespace FSpot.Widgets
@@ -113,9 +114,11 @@ namespace FSpot.Widgets
 				if (item == null || item.Current == null)
 					return;
 
-				using (ImageFile img = ImageFile.Create (item.Current.DefaultVersion.Uri)) {
+				using (IImageLoader loader = ImageLoader.Create (item.Current.DefaultVersion.Uri)) {
+					// FIXME: This does synchronous loading, so it sucks!
+					loader.Load (ImageLoaderItem.Large);
 					try {
-						using (var pb =  img.Load ()) {
+						using (var pb = loader.Large) {
 							double scale = Math.Min ((double)Allocation.Width/(double)pb.Width, (double)Allocation.Height/(double)pb.Height);
 							int w = (int)(pb.Width * scale);
 							int h = (int)(pb.Height * scale);



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