From 591d9b8a7c6d4bc45b1176f1b998ab0143521040 Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 31 Dec 2013 14:44:27 +0000 Subject: [PATCH] Adding blur and sharpen Former-commit-id: 3e988b0d327e4572f9ef3979cdfce5251ade3bd1 --- src/ImageProcessor/ImageFactory.cs | 28 + src/ImageProcessor/ImageProcessor.csproj | 10 +- src/ImageProcessor/Imaging/Convolution.cs | 499 ++++++++++++++++++ .../Imaging/Filters/ComicMatrixFilter.cs | 13 +- src/ImageProcessor/Imaging/GaussianLayer.cs | 179 +++++++ src/ImageProcessor/Imaging/Pixel.cs | 38 ++ src/ImageProcessor/Processors/Crop.cs | 1 + src/ImageProcessor/Processors/GaussianBlur.cs | 267 ++++------ .../Processors/GaussianSharpen.cs | 227 ++++++++ .../Images/Thumbs.db.REMOVED.git-id | 1 - .../Test_Website_NET45/Images/sample1.jpg | Bin 0 -> 33850 bytes .../NET45/Test_Website_NET45/Images/text.png | Bin 0 -> 7317 bytes .../Views/Home/Index.cshtml | 4 +- .../config/imageprocessor/processing.config | 14 + 14 files changed, 1108 insertions(+), 173 deletions(-) create mode 100644 src/ImageProcessor/Imaging/Convolution.cs create mode 100644 src/ImageProcessor/Imaging/GaussianLayer.cs create mode 100644 src/ImageProcessor/Imaging/Pixel.cs create mode 100644 src/ImageProcessor/Processors/GaussianSharpen.cs delete mode 100644 src/TestWebsites/NET45/Test_Website_NET45/Images/Thumbs.db.REMOVED.git-id create mode 100644 src/TestWebsites/NET45/Test_Website_NET45/Images/sample1.jpg create mode 100644 src/TestWebsites/NET45/Test_Website_NET45/Images/text.png diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index e6bf4609f..adcfb9178 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -323,6 +323,34 @@ namespace ImageProcessor return this; } + /// + /// Applies a Gaussian blur to the current image. + /// + /// + /// The radius by which to blur the images pixels. + /// Any integer between 0 and 100. + /// + /// + /// The current instance of the class. + /// + public ImageFactory Blur(int radius) + { + if (this.ShouldProcess) + { + // Sanitize the input. + if (radius > 100) + { + radius = 0; + } + + GaussianBlur blur = new GaussianBlur { DynamicParameter = radius }; + + this.Image = blur.ProcessImage(this); + } + + return this; + } + /// /// Constrains the current image, resizing it to fit within the given dimensions whilst keeping its aspect ratio. /// diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 1d62f5252..236724acd 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -12,6 +12,8 @@ ImageProcessor v4.0 512 + ..\ + true true @@ -57,11 +59,15 @@ + + + + @@ -83,8 +89,10 @@ + + @@ -99,8 +107,8 @@ - +