diff --git a/src/ImageProcessor.Web/Configuration/Resources/processing.config.transform b/src/ImageProcessor.Web/Configuration/Resources/processing.config.transform index 4b6851a03..62f4804f2 100644 --- a/src/ImageProcessor.Web/Configuration/Resources/processing.config.transform +++ b/src/ImageProcessor.Web/Configuration/Resources/processing.config.transform @@ -27,6 +27,7 @@ + diff --git a/src/ImageProcessor.Web/ImageProcessor.Web.csproj b/src/ImageProcessor.Web/ImageProcessor.Web.csproj index 18fd4d2cf..27949c77b 100644 --- a/src/ImageProcessor.Web/ImageProcessor.Web.csproj +++ b/src/ImageProcessor.Web/ImageProcessor.Web.csproj @@ -55,6 +55,7 @@ + diff --git a/src/ImageProcessor.Web/Processors/Halftone.cs b/src/ImageProcessor.Web/Processors/Halftone.cs new file mode 100644 index 000000000..7a824ac0a --- /dev/null +++ b/src/ImageProcessor.Web/Processors/Halftone.cs @@ -0,0 +1,89 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// The halftone processor applies a classical CMYK halftone to the given image. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Processors +{ + using System.Text.RegularExpressions; + + using ImageProcessor.Processors; + + /// + /// The halftone processor applies a classical CMYK halftone to the given image. + /// + public class Halftone : IWebGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + private static readonly Regex QueryRegex = new Regex(@"halftone(=comic)?", RegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + public Halftone() + { + this.Processor = new ImageProcessor.Processors.Halftone(); + } + + /// + /// Gets the regular expression to search strings for. + /// + public Regex RegexPattern + { + get + { + return QueryRegex; + } + } + + /// + /// Gets the order in which this processor is to be used in a chain. + /// + public int SortOrder { get; private set; } + + /// + /// Gets the associated graphics processor. + /// + public IGraphicsProcessor Processor { get; private set; } + + /// + /// The position in the original string where the first character of the captured substring was found. + /// + /// The query string to search. + /// + /// The zero-based starting position in the original string where the captured substring was found. + /// + public int MatchRegexIndex(string queryString) + { + int index = 0; + + // Set the sort order to max to allow filtering. + this.SortOrder = int.MaxValue; + + foreach (Match match in this.RegexPattern.Matches(queryString)) + { + if (match.Success) + { + if (index == 0) + { + // Set the index on the first instance only. + this.SortOrder = match.Index; + bool comicMode = match.Value.Contains("comic"); + this.Processor.DynamicParameter = comicMode; + } + + index += 1; + } + } + + return this.SortOrder; + } + } +} diff --git a/src/ImageProcessor/Imaging/Colors/CmykColor.cs b/src/ImageProcessor/Imaging/Colors/CmykColor.cs index 4efeb6819..aabc468e4 100644 --- a/src/ImageProcessor/Imaging/Colors/CmykColor.cs +++ b/src/ImageProcessor/Imaging/Colors/CmykColor.cs @@ -251,13 +251,13 @@ namespace ImageProcessor.Imaging.Colors /// /// Allows the implicit conversion of an instance of to a - /// . + /// . /// /// /// The instance of to convert. /// /// - /// An instance of . + /// An instance of . /// public static implicit operator RgbaColor(CmykColor cmykColor) { diff --git a/src/TestWebsites/MVC/config/imageprocessor/processing.config b/src/TestWebsites/MVC/config/imageprocessor/processing.config index 521d082d9..fee55869f 100644 --- a/src/TestWebsites/MVC/config/imageprocessor/processing.config +++ b/src/TestWebsites/MVC/config/imageprocessor/processing.config @@ -27,6 +27,7 @@ +