[f-spot] move some more methods to FSpot.Utils



commit eb520f7941d9e5ce50b4d000bb66cae03887932b
Author: Stephane Delcroix <stephane delcroix org>
Date:   Thu Jun 18 17:02:02 2009 +0200

    move some more methods to FSpot.Utils

 src/Makefile.am                |    1 +
 src/PixbufUtils.cs             |   57 +-----------------------
 src/Utils/PixbufOrientation.cs |   28 ------------
 src/Utils/PixbufUtils.cs       |   92 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 96 insertions(+), 82 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 138de9d..ff7e82a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,6 +56,7 @@ UTILS_CSDISTFILES =				\
 	$(srcdir)/Utils/GtkUtil.cs		\
 	$(srcdir)/Utils/Log.cs			\
 	$(srcdir)/Utils/PixbufOrientation.cs	\
+	$(srcdir)/Utils/PixbufUtils.cs		\
 	$(srcdir)/Utils/Unix.cs			\
 	$(srcdir)/Utils/UriUtils.cs
 
diff --git a/src/PixbufUtils.cs b/src/PixbufUtils.cs
index 7af1861..66e7423 100644
--- a/src/PixbufUtils.cs
+++ b/src/PixbufUtils.cs
@@ -800,60 +800,9 @@ public class PixbufUtils {
 		return TransformOrientation (src, orientation, true);
 	}
 
-	public static Gdk.Rectangle TransformOrientation (Gdk.Pixbuf src, Gdk.Rectangle args, PixbufOrientation orientation)
-	{
-		return TransformOrientation (src.Width, src.Height, args, orientation);
-	}
-	
-	public static Gdk.Rectangle TransformOrientation (int total_width, int total_height, Gdk.Rectangle args, PixbufOrientation orientation)
-	{
-		Gdk.Rectangle area = args;
-		
-		switch (orientation) {
-		case PixbufOrientation.BottomRight:
-			area.X = total_width - args.X - args.Width;
-			area.Y = total_height - args.Y - args.Height;
-			break;
-		case PixbufOrientation.TopRight:
-			area.X = total_width - args.X - args.Width;
-			break;
-		case PixbufOrientation.BottomLeft:
-			area.Y = total_height - args.Y - args.Height;
-			break;
-		case PixbufOrientation.LeftTop:
-			area.X = args.Y;
-			area.Y = args.X;
-			area.Width = args.Height;
-			area.Height = args.Width;
-			break;
-		case PixbufOrientation.RightBottom:
-			area.X = total_height - args.Y - args.Height;
-			area.Y = total_width - args.X - args.Width;
-			area.Width = args.Height;
-			area.Height = args.Width;
-			break;
-		case PixbufOrientation.RightTop:
-			area.X = total_height - args.Y - args.Height;
-			area.Y = args.X;
-			area.Width = args.Height;
-			area.Height = args.Width;
-			break;
-		case PixbufOrientation.LeftBottom:
-			area.X = args.Y;
-			area.Y = total_width - args.X - args.Width;
-			area.Width = args.Height;
-			area.Height = args.Width;
-			break;
-		default:
-			break;
-		}
-		
-		return area;
-	}
-	
 	public static Gdk.Rectangle TransformAndCopy (Gdk.Pixbuf src, Gdk.Pixbuf dest, PixbufOrientation orientation, Gdk.Rectangle args)
 	{
-		Gdk.Rectangle area = TransformOrientation (src, args, orientation);
+		Gdk.Rectangle area = FSpot.Utils.PixbufUtils.TransformOrientation (src, args, orientation);
 
 		int step = 256;
 
@@ -861,7 +810,7 @@ public class PixbufUtils {
 							Math.Min (step, args.Width),
 							Math.Min (step, args.Height));
 
-		Gdk.Rectangle trect = TransformOrientation (src, rect, orientation);
+		Gdk.Rectangle trect = FSpot.Utils.PixbufUtils.TransformOrientation (src, rect, orientation);
 		Gdk.Pixbuf tmp = new Gdk.Pixbuf (src.Colorspace, src.HasAlpha, 
 						 src.BitsPerSample,
 						 trect.Width, trect.Height);
@@ -869,7 +818,7 @@ public class PixbufUtils {
 		Gdk.Rectangle subarea;
 		BlockProcessor proc = new BlockProcessor (args, 256);
 		while (proc.Step (out subarea)) {
-			Gdk.Rectangle trans = TransformOrientation (src, subarea, orientation);
+			Gdk.Rectangle trans = FSpot.Utils.PixbufUtils.TransformOrientation (src, subarea, orientation);
 			Gdk.Pixbuf ssub = new Gdk.Pixbuf (src, subarea.X, subarea.Y,
 							  subarea.Width, subarea.Height);
 
diff --git a/src/Utils/PixbufOrientation.cs b/src/Utils/PixbufOrientation.cs
index 3bed592..1157138 100644
--- a/src/Utils/PixbufOrientation.cs
+++ b/src/Utils/PixbufOrientation.cs
@@ -34,32 +34,4 @@ namespace FSpot.Utils
 		RightBottom = 7,
 		LeftBottom = 8
 	}
-
-	public static class PixbufUtils
-	{
-		static public PixbufOrientation Rotate270 (PixbufOrientation orientation)
-		{
-			PixbufOrientation [] rot = new PixbufOrientation [] {
-				PixbufOrientation.LeftBottom, 
-				PixbufOrientation.LeftTop,
-				PixbufOrientation.RightTop,
-				PixbufOrientation.RightBottom, 
-				PixbufOrientation.BottomLeft,
-				PixbufOrientation.TopLeft,
-				PixbufOrientation.TopRight,
-				PixbufOrientation.BottomRight
-			};
-	
-			orientation = rot [((int)orientation) -1];
-			return orientation;
-		}
-	
-		static public PixbufOrientation Rotate90 (PixbufOrientation orientation)
-		{
-			orientation = Rotate270 (orientation);
-			orientation = Rotate270 (orientation);
-			orientation = Rotate270 (orientation);
-			return orientation;
-		}
-	}
 }
diff --git a/src/Utils/PixbufUtils.cs b/src/Utils/PixbufUtils.cs
new file mode 100644
index 0000000..4b3f429
--- /dev/null
+++ b/src/Utils/PixbufUtils.cs
@@ -0,0 +1,92 @@
+//
+// FSpot.PixbufUtils.cs
+//
+// Author(s):
+//	Ettore Perazzoli
+//	Larry Ewing  <lewing novell com>
+//	Stephane Delcroix  <stephane declroix org>
+//
+// This is free softwae. See cOPYING for details
+//
+
+namespace FSpot.Utils
+{
+	public static class PixbufUtils
+	{
+		static public PixbufOrientation Rotate270 (PixbufOrientation orientation)
+		{
+			PixbufOrientation [] rot = new PixbufOrientation [] {
+				PixbufOrientation.LeftBottom, 
+				PixbufOrientation.LeftTop,
+				PixbufOrientation.RightTop,
+				PixbufOrientation.RightBottom, 
+				PixbufOrientation.BottomLeft,
+				PixbufOrientation.TopLeft,
+				PixbufOrientation.TopRight,
+				PixbufOrientation.BottomRight
+			};
+	
+			orientation = rot [((int)orientation) -1];
+			return orientation;
+		}
+	
+		static public PixbufOrientation Rotate90 (PixbufOrientation orientation)
+		{
+			orientation = Rotate270 (orientation);
+			orientation = Rotate270 (orientation);
+			orientation = Rotate270 (orientation);
+			return orientation;
+		}
+
+		public static Gdk.Rectangle TransformOrientation (Gdk.Pixbuf src, Gdk.Rectangle args, PixbufOrientation orientation)
+		{
+			return TransformOrientation (src.Width, src.Height, args, orientation);
+		}
+		
+		public static Gdk.Rectangle TransformOrientation (int total_width, int total_height, Gdk.Rectangle args, PixbufOrientation orientation)
+		{
+			Gdk.Rectangle area = args;
+			
+			switch (orientation) {
+			case PixbufOrientation.BottomRight:
+				area.X = total_width - args.X - args.Width;
+				area.Y = total_height - args.Y - args.Height;
+				break;
+			case PixbufOrientation.TopRight:
+				area.X = total_width - args.X - args.Width;
+				break;
+			case PixbufOrientation.BottomLeft:
+				area.Y = total_height - args.Y - args.Height;
+				break;
+			case PixbufOrientation.LeftTop:
+				area.X = args.Y;
+				area.Y = args.X;
+				area.Width = args.Height;
+				area.Height = args.Width;
+				break;
+			case PixbufOrientation.RightBottom:
+				area.X = total_height - args.Y - args.Height;
+				area.Y = total_width - args.X - args.Width;
+				area.Width = args.Height;
+				area.Height = args.Width;
+				break;
+			case PixbufOrientation.RightTop:
+				area.X = total_height - args.Y - args.Height;
+				area.Y = args.X;
+				area.Width = args.Height;
+				area.Height = args.Width;
+				break;
+			case PixbufOrientation.LeftBottom:
+				area.X = args.Y;
+				area.Y = total_width - args.X - args.Width;
+				area.Width = args.Height;
+				area.Height = args.Width;
+				break;
+			default:
+				break;
+			}
+			
+			return area;
+		}
+	}
+}



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