Browse Source

Adding missing halftone method

Former-commit-id: f64a75cf15909739e4eb37638a58b03a2a7cf78a
Former-commit-id: 93dfcfd532f011d666fa8cd551bf15ede1689109
pull/17/head
James South 11 years ago
parent
commit
d21607aaa1
  1. 1
      src/ImageProcessor.Web/Configuration/Resources/processing.config.transform
  2. 1
      src/ImageProcessor.Web/ImageProcessor.Web.csproj
  3. 89
      src/ImageProcessor.Web/Processors/Halftone.cs
  4. 4
      src/ImageProcessor/Imaging/Colors/CmykColor.cs
  5. 1
      src/TestWebsites/MVC/config/imageprocessor/processing.config

1
src/ImageProcessor.Web/Configuration/Resources/processing.config.transform

@ -27,6 +27,7 @@
<setting key="MaxThreshold" value="100"/>
</settings>
</plugin>
<plugin name="Halftone" type="ImageProcessor.Web.Processors.Halftone, ImageProcessor.Web"/>
<plugin name="Hue" type="ImageProcessor.Web.Processors.Hue, ImageProcessor.Web"/>
<plugin name="Mask" type="ImageProcessor.Web.Processors.Mask, ImageProcessor.Web">
<settings>

1
src/ImageProcessor.Web/ImageProcessor.Web.csproj

@ -55,6 +55,7 @@
<Compile Include="Helpers\ProcessQueryStringEventArgs.cs" />
<Compile Include="Processors\DetectEdges.cs" />
<Compile Include="Processors\EntropyCrop.cs" />
<Compile Include="Processors\Halftone.cs" />
<Compile Include="Processors\Hue.cs" />
<Compile Include="Processors\Mask.cs" />
<Compile Include="Processors\Overlay.cs" />

89
src/ImageProcessor.Web/Processors/Halftone.cs

@ -0,0 +1,89 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Halftone.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// The halftone processor applies a classical CMYK halftone to the given image.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Web.Processors
{
using System.Text.RegularExpressions;
using ImageProcessor.Processors;
/// <summary>
/// The halftone processor applies a classical CMYK halftone to the given image.
/// </summary>
public class Halftone : IWebGraphicsProcessor
{
/// <summary>
/// The regular expression to search strings for.
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"halftone(=comic)?", RegexOptions.Compiled);
/// <summary>
/// Initializes a new instance of the <see cref="Halftone"/> class.
/// </summary>
public Halftone()
{
this.Processor = new ImageProcessor.Processors.Halftone();
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
public Regex RegexPattern
{
get
{
return QueryRegex;
}
}
/// <summary>
/// Gets the order in which this processor is to be used in a chain.
/// </summary>
public int SortOrder { get; private set; }
/// <summary>
/// Gets the associated graphics processor.
/// </summary>
public IGraphicsProcessor Processor { get; private set; }
/// <summary>
/// The position in the original string where the first character of the captured substring was found.
/// </summary>
/// <param name="queryString">The query string to search.</param>
/// <returns>
/// The zero-based starting position in the original string where the captured substring was found.
/// </returns>
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;
}
}
}

4
src/ImageProcessor/Imaging/Colors/CmykColor.cs

@ -251,13 +251,13 @@ namespace ImageProcessor.Imaging.Colors
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="CmykColor"/> to a
/// <see cref="System.Drawing.Color"/>.
/// <see cref="RgbaColor"/>.
/// </summary>
/// <param name="cmykColor">
/// The instance of <see cref="CmykColor"/> to convert.
/// </param>
/// <returns>
/// An instance of <see cref="System.Drawing.Color"/>.
/// An instance of <see cref="RgbaColor"/>.
/// </returns>
public static implicit operator RgbaColor(CmykColor cmykColor)
{

1
src/TestWebsites/MVC/config/imageprocessor/processing.config

@ -27,6 +27,7 @@
<setting key="MaxThreshold" value="100"/>
</settings>
</plugin>
<plugin name="Halftone" type="ImageProcessor.Web.Processors.Halftone, ImageProcessor.Web"/>
<plugin name="Hue" type="ImageProcessor.Web.Processors.Hue, ImageProcessor.Web"/>
<plugin name="Mask" type="ImageProcessor.Web.Processors.Mask, ImageProcessor.Web">
<settings>

Loading…
Cancel
Save