From e7cde69b846759c086b3fd7e699cde2b48785a1d 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: 9e4f5229abe9f2589802628787a34ff66e63b29f Former-commit-id: 792bb44a20e76fe1ae47be3f597d5967935a24ac Former-commit-id: 281e94a6f0c4d30625f1c5be42103de494f6b080 --- .../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 a7b7ac06cc..e1507544f1 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; } } });