From 54693fe22361e3f43f1a5aadceadf95726867f78 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 7 Jan 2016 19:38:32 +1100 Subject: [PATCH] Optimise resampler Former-commit-id: a8ff4bd48c3dd227beeebda998ca455c93cca173 Former-commit-id: c54775fc21c5f076cc644a991f6f7f70a903f819 Former-commit-id: dc8aabfcd64975ff08526c6c08c766614c1fa87b --- src/ImageProcessor/Samplers/Resampler.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/ImageProcessor/Samplers/Resampler.cs b/src/ImageProcessor/Samplers/Resampler.cs index e357b685b3..6a506a377d 100644 --- a/src/ImageProcessor/Samplers/Resampler.cs +++ b/src/ImageProcessor/Samplers/Resampler.cs @@ -7,7 +7,6 @@ namespace ImageProcessor.Samplers { using System; using System.Collections.Generic; - using System.Numerics; using System.Threading.Tasks; /// @@ -174,7 +173,7 @@ namespace ImageProcessor.Samplers Weight[] horizontalValues = this.horizontalWeights[x].Values; // Destination color components - Color destination = new Color(0, 0, 0, 0); + Color destination = new Color(); foreach (Weight yw in verticalValues) { @@ -185,11 +184,7 @@ namespace ImageProcessor.Samplers int originX = xw.Index; Color sourceColor = Color.Expand(source[originX, originY]); float weight = yw.Value * xw.Value; - - destination.R += sourceColor.R * weight; - destination.G += sourceColor.G * weight; - destination.B += sourceColor.B * weight; - destination.A += sourceColor.A * weight; + destination += sourceColor * weight; } } @@ -303,10 +298,7 @@ namespace ImageProcessor.Samplers { Color sourceColor = Color.Expand(source[rotated.X, rotated.Y]); float weight = yw.Value * xw.Value; - destination.R += sourceColor.R * weight; - destination.G += sourceColor.G * weight; - destination.B += sourceColor.B * weight; - destination.A += sourceColor.A * weight; + destination += sourceColor * weight; } } }