From e5954b9c99531293a2a768d2fc3cc05b545fba44 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 14 Jan 2016 10:23:08 +1100 Subject: [PATCH] Use vectors for gaussian blur/sharpen. Former-commit-id: 7daa8a1a37b5aa793b0273a097e8d08cf21a381d Former-commit-id: 7f213693822645fe4922140b9bd81d15d2efccd1 Former-commit-id: ed5dbdb6e13eb3fe066808d9cb8ba8b5d039bcf9 --- .../Filters/Convolution/Convolution2PassFilter.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/ImageProcessor/Filters/Convolution/Convolution2PassFilter.cs b/src/ImageProcessor/Filters/Convolution/Convolution2PassFilter.cs index a7b7ac06c..e1507544f 100644 --- a/src/ImageProcessor/Filters/Convolution/Convolution2PassFilter.cs +++ b/src/ImageProcessor/Filters/Convolution/Convolution2PassFilter.cs @@ -80,10 +80,7 @@ namespace ImageProcessor.Filters { for (int x = startX; x < endX; x++) { - float red = 0; - float green = 0; - float blue = 0; - float alpha = 0; + Color destination = new Color(); // Apply each matrix multiplier to the color components for each pixel. for (int fy = 0; fy < kernelHeight; fy++) @@ -101,15 +98,11 @@ namespace ImageProcessor.Filters offsetX = offsetX.Clamp(0, maxX); Color currentColor = source[offsetX, offsetY]; - - red += kernel[fy, fx] * currentColor.R; - green += kernel[fy, fx] * currentColor.G; - blue += kernel[fy, fx] * currentColor.B; - alpha += kernel[fy, fx] * currentColor.A; + destination += kernel[fy, fx] * currentColor; } } - target[x, y] = new Color(red, green, blue, alpha); + target[x, y] = destination; } } });