[mistelix] Fixes Star Wipe preview & strides



commit a3e851c53737e644e9d30e029dc18d8eab2f1490
Author: Jordi Mas <jmas softcatala org>
Date:   Thu Jul 2 00:07:08 2009 +0200

    Fixes Star Wipe preview & strides

 extensions/SlideTransitions/StarWipe/StarWipe.cs |   18 ++++++------------
 src/core/SlideImage.cs                           |    6 +++---
 2 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/extensions/SlideTransitions/StarWipe/StarWipe.cs b/extensions/SlideTransitions/StarWipe/StarWipe.cs
index 845ef2b..5f1c8c1 100644
--- a/extensions/SlideTransitions/StarWipe/StarWipe.cs
+++ b/extensions/SlideTransitions/StarWipe/StarWipe.cs
@@ -42,15 +42,12 @@ namespace Mistelix.Transitions
 			SlideImage image = new SlideImage ();
 			image.CopyProperties (Source);
 			image.Pixels = new byte [Target.Stride * Target.Height];
-
-			SlideImage tmp = new SlideImage ();
-			tmp.CopyProperties (Target);
+			SlideImage draw_image = new SlideImage ();
 
 			double cx = Convert.ToInt32 ((Source.Width / 2));
 			double cy = Convert.ToInt32 ((Source.Height / 2));
 			double r1 = Target.Width * percentage;
 			double r2 = Target.Width * percentage * 0.5;
-			int pixels = 0;
 						
 			DataImageSurface draw = Source.ToDataImageSurface ();
 
@@ -86,10 +83,10 @@ namespace Mistelix.Transitions
 				gr.Color = new Color (1, 115, 0);
 			    	gr.Fill ();
 				gr.Restore ();
-				tmp.Pixels = draw.Get24bitsPixBuf ();
+
+				draw_image.FromDataImageSurface (draw);
 
 				bool sourced = percentage < 0.5;
-        			
 				if (sourced)
                         		Array.Copy (Source.Pixels, image.Pixels, Source.Stride * Source.Height);
 				else 
@@ -102,15 +99,14 @@ namespace Mistelix.Transitions
 				for (int h = 0; h < Target.Height; h++)
 				{
 					int pos = h *  Target.Stride;
-					int posTMP = h * Target.Width * Target.Channels;
+					int pos_draw = h * draw_image.Stride;
 					for (int w = 0; w < Target.Width; w++)
 					{
-						if (tmp.Pixels[posTMP] != 0) {
+						if (draw_image.Pixels[pos_draw] != 0) {
                                                         if (sourced) {
 							        for (int c = 0; c < Target.Channels; c++)
 								{
 								        image.Pixels[pos + c] = Target.Pixels[pos + c];
-                                                                        pixels++;
 							        }
                                                         }
 						}else{
@@ -118,17 +114,15 @@ namespace Mistelix.Transitions
 						                for (int c = 0; c < Target.Channels; c++)
 								{
 							        	image.Pixels[pos + c] = Source.Pixels[pos + c];
-                                                                        pixels++;
 							        }
                                                         }
 						}
 
 						pos += Target.Channels;
-						posTMP += Target.Channels;
+						pos_draw += draw_image.Channels;
 					}
 				}
 			}
-
 			((IDisposable) draw).Dispose ();
 			return image;
 		}
diff --git a/src/core/SlideImage.cs b/src/core/SlideImage.cs
index ff3cec4..d9bd2e1 100644
--- a/src/core/SlideImage.cs
+++ b/src/core/SlideImage.cs
@@ -239,7 +239,7 @@ namespace Mistelix.DataModel
 		}
 
 		// mistelixvideosrc expects images in 24 bits (3 channels)
-		void FromDataImageSurface (DataImageSurface img)
+		public void FromDataImageSurface (DataImageSurface img)
 		{
 			if (img.Format != Cairo.Format.Argb32)
 				throw new InvalidOperationException (String.Format ("SlideImage.FromCairo: unsupported format {0}", img.Format));
@@ -248,7 +248,7 @@ namespace Mistelix.DataModel
 			height = img.Height;
 			pixels = img.Get24bitsPixBuf ();
 			channels = 3;
-			stride = img.Width * channels;
+			stride = ((img.Width * channels) + 3) & ~3;
 			alpha = false;
 		}
 		
@@ -490,7 +490,7 @@ namespace Mistelix.DataModel
 			// Target data array
 			width = width_src;
 			height = height_src;
-			stride = channels * width;
+			stride = ((width * channels) + 3) & ~3;
 			len = stride * height;
 			pixels = new byte [len];
 				



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