[f-spot: 14/40] use the PixbufUtils for readability



commit 7ca48d1d9781360570ec3afd110d0eadd225664d
Author: Stephane Delcroix <stephane delcroix org>
Date:   Sun Jun 21 14:22:03 2009 +0200

    use the PixbufUtils for readability
    
    * Widgets/ImageView.cs: drop the custom pixbuf rotation code and use PixbufUtils.TransformOrientation. This adds readibility and enforce a Disposal of pixbufs by the use os 'using' keyword

 src/Widgets/ImageView.cs |   49 +++++++--------------------------------------
 1 files changed, 8 insertions(+), 41 deletions(-)
---
diff --git a/src/Widgets/ImageView.cs b/src/Widgets/ImageView.cs
index 09548d1..7523c19 100644
--- a/src/Widgets/ImageView.cs
+++ b/src/Widgets/ImageView.cs
@@ -761,48 +761,15 @@ namespace FSpot.Widgets
 						       CheckPattern.CheckSize, CheckPattern.Color1, CheckPattern.Color2);
 
 
-				Pixbuf dest_pixbuf;
-				switch (pixbuf_orientation) {
-				default:
-				case PixbufOrientation.TopLeft:
-					dest_pixbuf = temp_pixbuf;
-					break;
-				case PixbufOrientation.TopRight:
-					dest_pixbuf = temp_pixbuf.Flip (false);
-					break;
-				case PixbufOrientation.BottomRight:
-					dest_pixbuf = temp_pixbuf.RotateSimple (PixbufRotation.Upsidedown);
-					break;
-				case PixbufOrientation.BottomLeft:
-					dest_pixbuf = temp_pixbuf.Flip (true);
-					break;
-				case PixbufOrientation.LeftTop:
-					using (var rotated = temp_pixbuf.RotateSimple (PixbufRotation.Clockwise)) {
-						dest_pixbuf = rotated.Flip (false);
-					}
-					break;
-				case PixbufOrientation.RightTop:
-					dest_pixbuf = temp_pixbuf.RotateSimple (PixbufRotation.Clockwise);
-					break;
-				case PixbufOrientation.RightBottom:
-					using (var rotated = temp_pixbuf.RotateSimple (PixbufRotation.Counterclockwise)) {
-						dest_pixbuf = rotated.Flip (false);
-					}
-					break;
-				case PixbufOrientation.LeftBottom:
-					dest_pixbuf = temp_pixbuf.RotateSimple (PixbufRotation.Counterclockwise);
-					break;
+				using (var dest_pixbuf = PixbufUtils.TransformOrientation (temp_pixbuf, pixbuf_orientation)) {
+					GdkWindow.DrawPixbuf (Style.BlackGC,
+							      dest_pixbuf,
+							      0, 0,
+							      area.X, area.Y,
+							      area.Width, area.Height,
+							      RgbDither.Max,
+							      area.X - x_offset, area.Y - y_offset);
 				}
-
-				GdkWindow.DrawPixbuf (Style.BlackGC,
-						      dest_pixbuf,
-						      0, 0,
-						      area.X, area.Y,
-						      area.Width, area.Height,
-						      RgbDither.Max,
-						      area.X - x_offset, area.Y - y_offset);
-				if (dest_pixbuf != temp_pixbuf)
-					dest_pixbuf.Dispose ();
 			}
 		}
 



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