[f-spot] re-enable Color Management



commit 59deb8041653dee4f7a9cf1d56300b341c091a2e
Author: Stephane Delcroix <stephane delcroix org>
Date:   Thu Jul 9 17:40:31 2009 +0200

    re-enable Color Management
    
    there's now a ApplyColorTransform hook in ImageView that can be overriden by subclasses. PhotoImageView does that and apply the currnet screen profile to the portion of the pixbuf about to be drawn.
    
    drop some knots in spaghetty code, by removing the x-references between ColorManagement and PhotoImageView.

 src/Core/ColorManagement.cs |   11 ------
 src/PhotoImageView.cs       |   24 ++++++++++++--
 src/Widgets/ImageView.cs    |   76 ++++++++++++++++++++++---------------------
 3 files changed, 60 insertions(+), 51 deletions(-)
---
diff --git a/src/Core/ColorManagement.cs b/src/Core/ColorManagement.cs
index f35cfd4..59d84dc 100644
--- a/src/Core/ColorManagement.cs
+++ b/src/Core/ColorManagement.cs
@@ -22,19 +22,9 @@ public class ColorManagement {
 		private static Cms.Profile destination_profile;
 		private static Cms.Transform standard_transform;
 		
-		private static FSpot.Widgets.PhotoImageView photo_image_view;
-
 		private static string [] search_dir = { "/usr/share/color/icc", "~/.color/icc", "/usr/local/share/color/icc " }; //the main directory list to find a profiles
 		public static ArrayList Profiles = new ArrayList();
 		
-		public static FSpot.Widgets.PhotoImageView PhotoImageView {
-			set {
-				if (photo_image_view == null)
-					photo_image_view = value;
-			}
-			get { return photo_image_view; }
-		}
-		
 		public static Cms.Profile DisplayProfile {
 			set {
 				display_profile = value;
@@ -137,7 +127,6 @@ public class ColorManagement {
 			GetXProfile ();
 			GetSettings ();
 			CreateStandardTransform ();
-			PhotoImageView.Reload ();
 		}
 		
 		private static void CreateStandardTransform ()
diff --git a/src/PhotoImageView.cs b/src/PhotoImageView.cs
index a2bd364..da5fbd6 100644
--- a/src/PhotoImageView.cs
+++ b/src/PhotoImageView.cs
@@ -26,10 +26,8 @@ namespace FSpot.Widgets {
 
 		public PhotoImageView (BrowsablePointer item) : base ()
 		{
-			FSpot.ColorManagement.PhotoImageView = this;
-			Transform = FSpot.ColorManagement.StandardTransform (); //for preview windows
-
 			Accelerometer.OrientationChanged += HandleOrientationChanged;
+			Preferences.SettingChanged += OnPreferencesChanged;
 
 			this.item = item;
 			item.Changed += HandlePhotoItemChanged;
@@ -389,6 +387,26 @@ namespace FSpot.Widgets {
 
 			sharpener.Show ();	
 		}
+
+		void OnPreferencesChanged (object sender, NotifyEventArgs args)
+		{
+			LoadPreference (args.Key);
+		}
+
+		void LoadPreference (String key)
+		{
+			switch (key) {
+			case Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE:
+			case Preferences.COLOR_MANAGEMENT_ENABLED:
+				Reload ();
+				break;
+			}
+		}
+
+		protected override void ApplyColorTransform (Pixbuf pixbuf)
+		{
+			FSpot.ColorManagement.ApplyScreenProfile (pixbuf);
+		}
 		
 	}
 }
diff --git a/src/Widgets/ImageView.cs b/src/Widgets/ImageView.cs
index 7be3cbb..a01ef09 100644
--- a/src/Widgets/ImageView.cs
+++ b/src/Widgets/ImageView.cs
@@ -163,12 +163,6 @@ namespace FSpot.Widgets
 			} 
 		}
 
-		Cms.Transform transform;
-		public Cms.Transform Transform {
-			get { return transform; } 
-			set { transform = value;} 
-		}
-
 		InterpType interpolation = InterpType.Bilinear;
 		public Gdk.InterpType Interpolation {
 			get { return interpolation; } 
@@ -240,37 +234,6 @@ namespace FSpot.Widgets
 					   (int) Math.Floor (win.Y * (double)(((int)PixbufOrientation <= 4 ? Pixbuf.Height : Pixbuf.Width) - 1) / (double)(scaled_height - 1) + .5));
 		}
 
-		protected Point ImageCoordsToWindow (Point image)
-		{
-			if (this.Pixbuf == null)
-				return Point.Zero;
-
-			image = PixbufUtils.TransformOrientation (Pixbuf.Width, Pixbuf.Height, image, pixbuf_orientation);
-			int x_offset = scaled_width < Allocation.Width ? (int)(Allocation.Width - scaled_width) / 2 : -XOffset;
-			int y_offset = scaled_height < Allocation.Height ? (int)(Allocation.Height - scaled_height) / 2 : -YOffset;
-
-			return new Point ((int) Math.Floor (image.X * (double) (scaled_width - 1) / (Pixbuf.Width - 1) + 0.5) + x_offset,
-					  (int) Math.Floor (image.Y * (double) (scaled_height - 1) / (Pixbuf.Height - 1) + 0.5) + y_offset);
-		}
-
-		protected Rectangle ImageCoordsToWindow (Rectangle image)
-		{
-			if (this.Pixbuf == null)
-				return Gdk.Rectangle.Zero;
-
-			image = PixbufUtils.TransformOrientation (Pixbuf.Width, Pixbuf.Height, image, pixbuf_orientation);
-			int x_offset = scaled_width < Allocation.Width ? (int)(Allocation.Width - scaled_width) / 2 : -XOffset;
-			int y_offset = scaled_height < Allocation.Height ? (int)(Allocation.Height - scaled_height) / 2 : -YOffset;
-
-			Gdk.Rectangle win = Gdk.Rectangle.Zero;
-			win.X = (int) Math.Floor (image.X * (double) (scaled_width - 1) / (((int)pixbuf_orientation <= 4 ? Pixbuf.Width : Pixbuf.Height) - 1) + 0.5) + x_offset;
-			win.Y = (int) Math.Floor (image.Y * (double) (scaled_height - 1) / (((int)pixbuf_orientation <= 4 ? Pixbuf.Height : Pixbuf.Width) - 1) + 0.5) + y_offset;
-			win.Width = (int) Math.Floor ((image.X + image.Width) * (double) (scaled_width - 1) / (((int)pixbuf_orientation <= 4 ? Pixbuf.Width : Pixbuf.Height) - 1) + 0.5) - win.X + x_offset;
-			win.Height = (int) Math.Floor ((image.Y + image.Height) * (double) (scaled_height - 1) / (((int)pixbuf_orientation <= 4 ? Pixbuf.Height : Pixbuf.Width) - 1) + 0.5) - win.Y + y_offset;
-
-			return win;
-		}
-
 		List<LayoutChild> children;
 		public void Put (Gtk.Widget widget, int x, int y)
 		{
@@ -313,6 +276,43 @@ namespace FSpot.Widgets
 		{
 			ZoomFit (upscale);
 		}
+
+		protected virtual void ApplyColorTransform (Pixbuf pixbuf)
+		{
+		}
+
+		protected Point ImageCoordsToWindow (Point image)
+		{
+			if (this.Pixbuf == null)
+				return Point.Zero;
+
+			image = PixbufUtils.TransformOrientation (Pixbuf.Width, Pixbuf.Height, image, pixbuf_orientation);
+			int x_offset = scaled_width < Allocation.Width ? (int)(Allocation.Width - scaled_width) / 2 : -XOffset;
+			int y_offset = scaled_height < Allocation.Height ? (int)(Allocation.Height - scaled_height) / 2 : -YOffset;
+
+			return new Point ((int) Math.Floor (image.X * (double) (scaled_width - 1) / (Pixbuf.Width - 1) + 0.5) + x_offset,
+					  (int) Math.Floor (image.Y * (double) (scaled_height - 1) / (Pixbuf.Height - 1) + 0.5) + y_offset);
+		}
+
+		protected Rectangle ImageCoordsToWindow (Rectangle image)
+		{
+			if (this.Pixbuf == null)
+				return Gdk.Rectangle.Zero;
+
+			image = PixbufUtils.TransformOrientation (Pixbuf.Width, Pixbuf.Height, image, pixbuf_orientation);
+			int x_offset = scaled_width < Allocation.Width ? (int)(Allocation.Width - scaled_width) / 2 : -XOffset;
+			int y_offset = scaled_height < Allocation.Height ? (int)(Allocation.Height - scaled_height) / 2 : -YOffset;
+
+			Gdk.Rectangle win = Gdk.Rectangle.Zero;
+			win.X = (int) Math.Floor (image.X * (double) (scaled_width - 1) / (((int)pixbuf_orientation <= 4 ? Pixbuf.Width : Pixbuf.Height) - 1) + 0.5) + x_offset;
+			win.Y = (int) Math.Floor (image.Y * (double) (scaled_height - 1) / (((int)pixbuf_orientation <= 4 ? Pixbuf.Height : Pixbuf.Width) - 1) + 0.5) + y_offset;
+			win.Width = (int) Math.Floor ((image.X + image.Width) * (double) (scaled_width - 1) / (((int)pixbuf_orientation <= 4 ? Pixbuf.Width : Pixbuf.Height) - 1) + 0.5) - win.X + x_offset;
+			win.Height = (int) Math.Floor ((image.Y + image.Height) * (double) (scaled_height - 1) / (((int)pixbuf_orientation <= 4 ? Pixbuf.Height : Pixbuf.Width) - 1) + 0.5) - win.Y + y_offset;
+
+			return win;
+		}
+
+
 #endregion
 
 #region container
@@ -761,6 +761,8 @@ namespace FSpot.Widgets
 						       CheckPattern.CheckSize, CheckPattern.Color1, CheckPattern.Color2);
 
 
+				ApplyColorTransform (temp_pixbuf);
+
 				using (var dest_pixbuf = PixbufUtils.TransformOrientation (temp_pixbuf, pixbuf_orientation)) {
 					GdkWindow.DrawPixbuf (Style.BlackGC,
 							      dest_pixbuf,



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