Browse Source

Added Reset, tweaked Gotham and fixed ToArray() bug.

Former-commit-id: d09731b9c6777e48004d8ebf7219be9ac5009068
af/merge-core
JimBobSquarePants 13 years ago
parent
commit
fee7d322fa
  1. 2
      src/ImageProcessor.Web/Config/ImageProcessorConfig.cs
  2. 4
      src/ImageProcessor/Helpers/Extensions/StringExtensions.cs
  3. 63
      src/ImageProcessor/ImageFactory.cs
  4. 23
      src/ImageProcessor/Imaging/Filters/ColorMatrixes.cs
  5. 13
      src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs
  6. 24
      src/ImageProcessor/Imaging/Filters/GothamMatrixFilter.cs
  7. 24
      src/ImageProcessor/Processors/Alpha.cs
  8. 26
      src/ImageProcessor/Processors/Brightness.cs
  9. 26
      src/ImageProcessor/Processors/Contrast.cs
  10. 24
      src/ImageProcessor/Processors/Crop.cs
  11. 22
      src/ImageProcessor/Processors/Filter.cs
  12. 22
      src/ImageProcessor/Processors/Flip.cs
  13. 22
      src/ImageProcessor/Processors/Format.cs
  14. 18
      src/ImageProcessor/Processors/IGraphicsProcessor.cs
  15. 24
      src/ImageProcessor/Processors/Quality.cs
  16. 26
      src/ImageProcessor/Processors/Resize.cs
  17. 22
      src/ImageProcessor/Processors/Rotate.cs
  18. 28
      src/ImageProcessor/Processors/Saturate.cs
  19. 22
      src/ImageProcessor/Processors/Vignette.cs
  20. 30
      src/ImageProcessor/Processors/Watermark.cs

2
src/ImageProcessor.Web/Config/ImageProcessorConfig.cs

@ -257,7 +257,7 @@ namespace ImageProcessor.Web.Config
// Add the available settings.
foreach (IGraphicsProcessor processor in this.GraphicsProcessors)
{
processor.Settings = this.GetPluginSettings(processor.Name);
processor.Settings = this.GetPluginSettings(processor.GetType().Name);
}
}
catch (ReflectionTypeLoadException ex)

4
src/ImageProcessor/Helpers/Extensions/StringExtensions.cs

@ -114,11 +114,11 @@ namespace ImageProcessor.Helpers.Extensions
/// </summary>
/// <param name="expression">The <see cref="T:System.String">String</see> instance that this method extends.</param>
/// <returns>An array of integers scraped from the String.</returns>
public static int[] ToIntegerArray(this string expression)
public static int[] ToPositiveIntegerArray(this string expression)
{
Contract.Requires(!string.IsNullOrWhiteSpace(expression));
Regex regex = new Regex(@"(-|)\d+", RegexOptions.Compiled);
Regex regex = new Regex(@"\d+", RegexOptions.Compiled);
MatchCollection matchCollection = regex.Matches(expression);

63
src/ImageProcessor/ImageFactory.cs

@ -30,6 +30,11 @@ namespace ImageProcessor
/// </summary>
private const int DefaultJpegQuality = 90;
/// <summary>
/// The backup image format.
/// </summary>
private ImageFormat backupImageFormat;
/// <summary>
/// A value indicating whether this instance of the given entity has been disposed.
/// </summary>
@ -117,6 +122,7 @@ namespace ImageProcessor
// Set the other properties.
this.JpegQuality = DefaultJpegQuality;
this.backupImageFormat = ImageFormat.Jpeg;
this.ImageFormat = ImageFormat.Jpeg;
this.ShouldProcess = true;
@ -167,7 +173,9 @@ namespace ImageProcessor
// Set the other properties.
this.JpegQuality = DefaultJpegQuality;
this.ImageFormat = ImageUtils.GetImageFormat(imageName);
ImageFormat imageFormat = ImageUtils.GetImageFormat(imageName);
this.backupImageFormat = imageFormat;
this.ImageFormat = imageFormat;
this.ShouldProcess = true;
}
}
@ -175,6 +183,37 @@ namespace ImageProcessor
return this;
}
/// <summary>
/// Resets the ImageFactory to its original loaded state.
/// </summary>
/// <returns>
/// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns>
public ImageFactory Reset()
{
if (this.ShouldProcess)
{
MemoryStream memoryStream = (MemoryStream)this.Image.Tag;
// Set our new image as the memorystream value.
Image newImage = Image.FromStream(memoryStream);
// Store the stream in the image Tag property so we can dispose of it later.
newImage.Tag = memoryStream;
// Dispose and reassign the image.
this.Image.Dispose();
this.Image = newImage;
// Set the other properties.
this.JpegQuality = DefaultJpegQuality;
this.ImageFormat = this.backupImageFormat;
}
return this;
}
#region Manipulation
/// <summary>
/// Adds a query-string to the image factory to allow auto-processing of remote files.
@ -441,7 +480,7 @@ namespace ImageProcessor
/// <returns>
/// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns>
public ImageFactory Saturate(int percentage)
public ImageFactory Saturation(int percentage)
{
if (this.ShouldProcess)
{
@ -451,7 +490,7 @@ namespace ImageProcessor
percentage = 0;
}
Saturate saturate = new Saturate { DynamicParameter = percentage };
Saturation saturate = new Saturation { DynamicParameter = percentage };
this.Image = saturate.ProcessImage(this);
}
@ -504,7 +543,10 @@ namespace ImageProcessor
/// Saves the current image to the specified file path.
/// </summary>
/// <param name="filePath">The path to save the image to.</param>
public void Save(string filePath)
/// <returns>
/// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns>
public ImageFactory Save(string filePath)
{
if (this.ShouldProcess)
{
@ -527,9 +569,9 @@ namespace ImageProcessor
ImageCodecInfo.GetImageEncoders().FirstOrDefault(
ici => ici.MimeType.Equals("image/jpeg", StringComparison.OrdinalIgnoreCase));
// ReSharper disable AssignNullToNotNullAttribute
// ReSharper disable AssignNullToNotNullAttribute
this.Image.Save(filePath, imageCodecInfo, encoderParameters);
// ReSharper restore AssignNullToNotNullAttribute
// ReSharper restore AssignNullToNotNullAttribute
}
}
else
@ -537,6 +579,8 @@ namespace ImageProcessor
this.Image.Save(filePath, this.ImageFormat);
}
}
return this;
}
/// <summary>
@ -545,7 +589,10 @@ namespace ImageProcessor
/// <param name="memoryStream">
/// The <see cref="T:System.IO.MemoryStream"/> to save the image information to.
/// </param>
public void Save(MemoryStream memoryStream)
/// <returns>
/// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns>
public ImageFactory Save(MemoryStream memoryStream)
{
if (this.ShouldProcess)
{
@ -573,6 +620,8 @@ namespace ImageProcessor
this.Image.Save(memoryStream, this.ImageFormat);
}
}
return this;
}
#region IDisposable Members

23
src/ImageProcessor/Imaging/Filters/ColorMatrixes.cs

@ -10,6 +10,7 @@ namespace ImageProcessor.Imaging.Filters
#region Using
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Drawing.Imaging;
@ -80,6 +81,7 @@ namespace ImageProcessor.Imaging.Filters
/// <summary>
/// Gets Lomograph.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
internal static ColorMatrix Lomograph
{
get
@ -115,25 +117,6 @@ namespace ImageProcessor.Imaging.Filters
}
}
/// <summary>
/// Gets Gotham.
/// </summary>
internal static ColorMatrix Gotham
{
get
{
return new ColorMatrix(
new float[][]
{
new float[] { .9f, .9f, .9f, 0, 0 },
new float[] { .9f, .9f, .9f, 0, 0 },
new float[] { .9f, .9f, .9f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { -.5f, -.5f, -.45f, 0, 1 }
});
}
}
/// <summary>
/// Gets Invert.
/// </summary>
@ -156,6 +139,7 @@ namespace ImageProcessor.Imaging.Filters
/// <summary>
/// Gets HiSatch.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
internal static ColorMatrix HiSatch
{
get
@ -175,6 +159,7 @@ namespace ImageProcessor.Imaging.Filters
/// <summary>
/// Gets LoSatch.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
internal static ColorMatrix LoSatch
{
get

13
src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs

@ -9,9 +9,11 @@ namespace ImageProcessor.Imaging.Filters
{
#region Using
using System;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
#endregion
/// <summary>
@ -20,8 +22,9 @@ namespace ImageProcessor.Imaging.Filters
internal class ComicMatrixFilter : IMatrixFilter
{
/// <summary>
/// Enumurates Argb colour channels.
/// Enumerates Argb color channels.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
private enum ChannelArgb
{
/// <summary>
@ -148,6 +151,7 @@ namespace ImageProcessor.Imaging.Filters
patternBitmap.Dispose();
}
}
return image;
}
@ -185,7 +189,7 @@ namespace ImageProcessor.Imaging.Filters
byte[] sourceRgbValues = new byte[bytes];
// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(bitmapDataSource.Scan0, sourceRgbValues, 0, bytes);
Marshal.Copy(bitmapDataSource.Scan0, sourceRgbValues, 0, bytes);
// Unlockbits the source.
source.UnlockBits(bitmapDataSource);
@ -197,7 +201,7 @@ namespace ImageProcessor.Imaging.Filters
byte[] destinationRgbValues = new byte[bytes];
// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(bitmapDataDestination.Scan0, destinationRgbValues, 0, bytes);
Marshal.Copy(bitmapDataDestination.Scan0, destinationRgbValues, 0, bytes);
int s = (int)sourceChannel;
int d = (int)destinationChannel;
@ -210,11 +214,10 @@ namespace ImageProcessor.Imaging.Filters
}
// Copy the RGB values back to the bitmap
System.Runtime.InteropServices.Marshal.Copy(destinationRgbValues, 0, bitmapDataDestination.Scan0, bytes);
Marshal.Copy(destinationRgbValues, 0, bitmapDataDestination.Scan0, bytes);
// Unlock bits the destination.
destination.UnlockBits(bitmapDataDestination);
}
}
}

24
src/ImageProcessor/Imaging/Filters/GothamMatrixFilter.cs

@ -8,13 +8,12 @@
namespace ImageProcessor.Imaging.Filters
{
#region Using
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using ImageProcessor.Processors;
#endregion
/// <summary>
@ -27,7 +26,7 @@ namespace ImageProcessor.Imaging.Filters
/// </summary>
public ColorMatrix Matrix
{
get { return ColorMatrixes.Gotham; }
get { return ColorMatrixes.GreyScale; }
}
/// <summary>
@ -61,14 +60,14 @@ namespace ImageProcessor.Imaging.Filters
// Paint a burgundy rectangle with a transparency of ~30% over the image.
// Paint a blue rectangle with a transparency of 20% over the image.
using (SolidBrush brush = new SolidBrush(Color.FromArgb(77, 43, 4, 18)))
using (SolidBrush brush = new SolidBrush(Color.FromArgb(77, 38, 14, 28)))
{
Region oldClip = graphics.Clip;
graphics.Clip = new Region(rectangle);
graphics.FillRectangle(brush, rectangle);
// Fill the blue.
brush.Color = Color.FromArgb(51, 12, 22, 88);
brush.Color = Color.FromArgb(51, 29, 32, 59);
graphics.FillRectangle(brush, rectangle);
graphics.Clip = oldClip;
}
@ -76,6 +75,15 @@ namespace ImageProcessor.Imaging.Filters
}
}
// Add brightness and contrast to finish the effect.
factory.Image = newImage;
Brightness brightness = new Brightness { DynamicParameter = 5 };
newImage = (Bitmap)brightness.ProcessImage(factory);
factory.Image = newImage;
Contrast contrast = new Contrast { DynamicParameter = 85 };
newImage = (Bitmap)contrast.ProcessImage(factory);
// Reassign the image.
image.Dispose();
image = newImage;

24
src/ImageProcessor/Processors/Alpha.cs

@ -27,28 +27,6 @@ namespace ImageProcessor.Processors
private static readonly Regex QueryRegex = new Regex(@"alpha=(?:100|[1-9]?[0-9])", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Alpha";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Changes the alpha component of the image to effect its transparency.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
@ -111,7 +89,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
int percentage = match.Value.ToIntegerArray()[0];
int percentage = int.Parse(match.Value.Split('=')[1]);
this.DynamicParameter = percentage;
}

26
src/ImageProcessor/Processors/Brightness.cs

@ -24,31 +24,9 @@ namespace ImageProcessor.Processors
/// The regular expression to search strings for.
/// <see cref="http://stackoverflow.com/a/6400969/427899"/>
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"brightness=(-|)(?:100|[1-9]?[0-9])", RegexOptions.Compiled);
private static readonly Regex QueryRegex = new Regex(@"brightness=(-?(?:100)|-?([1-9]?[0-9]))", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Brightness";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Changes the the brightness component of the image.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
@ -111,7 +89,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
int percentage = match.Value.ToIntegerArray()[0];
int percentage = int.Parse(match.Value.Split('=')[1]);
this.DynamicParameter = percentage;
}

26
src/ImageProcessor/Processors/Contrast.cs

@ -24,31 +24,9 @@ namespace ImageProcessor.Processors
/// The regular expression to search strings for.
/// <see cref="http://stackoverflow.com/a/6400969/427899"/>
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"contrast=(-|)(?:100|[1-9]?[0-9])", RegexOptions.Compiled);
private static readonly Regex QueryRegex = new Regex(@"contrast=(-?(?:100)|-?([1-9]?[0-9]))", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Contrast";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Changes the the contrast component of the image.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
@ -111,7 +89,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
int percentage = match.Value.ToIntegerArray()[0];
int percentage = int.Parse(match.Value.Split('=')[1]);
this.DynamicParameter = percentage;
}

24
src/ImageProcessor/Processors/Crop.cs

@ -28,28 +28,6 @@ namespace ImageProcessor.Processors
private static readonly Regex QueryRegex = new Regex(@"crop=\d+-\d+-\d+-\d+", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Crop";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Crops an image to the given dimensions.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
@ -112,7 +90,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
int[] coordinates = match.Value.ToIntegerArray();
int[] coordinates = match.Value.ToPositiveIntegerArray();
int x = coordinates[0];
int y = coordinates[1];

22
src/ImageProcessor/Processors/Filter.cs

@ -26,28 +26,6 @@ namespace ImageProcessor.Processors
private static readonly Regex QueryRegex = new Regex(@"filter=(lomograph|polaroid|blackwhite|sepia|greyscale|gotham|invert|hisatch|losatch|comic)", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Filter";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Encapsulates methods with which to add filters to an image. e.g polaroid, lomograph";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>

22
src/ImageProcessor/Processors/Flip.cs

@ -25,28 +25,6 @@ namespace ImageProcessor.Processors
private static readonly Regex QueryRegex = new Regex(@"flip=(horizontal|vertical)", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Flip";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Flips an image either horizontally or vertically.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>

22
src/ImageProcessor/Processors/Format.cs

@ -25,28 +25,6 @@ namespace ImageProcessor.Processors
private static readonly Regex QueryRegex = new Regex(@"format=(jpeg|png|bmp|gif)", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Format";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Sets the output of the image to a specific format.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>

18
src/ImageProcessor/Processors/IGraphicsProcessor.cs

@ -8,9 +8,7 @@
namespace ImageProcessor.Processors
{
#region Using
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Drawing;
using System.Text.RegularExpressions;
#endregion
@ -20,18 +18,7 @@ namespace ImageProcessor.Processors
/// </summary>
public interface IGraphicsProcessor
{
#region MetaData
/// <summary>
/// Gets the name.
/// </summary>
string Name { get; }
/// <summary>
/// Gets the description.
/// </summary>
string Description { get; }
#endregion
#region Properties
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
@ -50,7 +37,8 @@ namespace ImageProcessor.Processors
/// <summary>
/// Gets or sets any additional settings required by the processor.
/// </summary>
Dictionary<string, string> Settings { get; set; }
Dictionary<string, string> Settings { get; set; }
#endregion
#region Methods
/// <summary>

24
src/ImageProcessor/Processors/Quality.cs

@ -25,28 +25,6 @@ namespace ImageProcessor.Processors
private static readonly Regex QueryRegex = new Regex(@"quality=(?:100|[1-9]?[0-9])", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Quality";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Sets the the quality output for jpeg images.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
@ -109,7 +87,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
int percentage = match.Value.ToIntegerArray()[0];
int percentage = int.Parse(match.Value.Split('=')[1]);
this.DynamicParameter = percentage;
}

26
src/ImageProcessor/Processors/Resize.cs

@ -28,28 +28,6 @@ namespace ImageProcessor.Processors
private static readonly Regex QueryRegex = new Regex(@"(width|height)=\d+", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Resize";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Resizes an image to the given dimensions.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
@ -118,11 +96,11 @@ namespace ImageProcessor.Processors
// Match syntax
if (match.Value.Contains("width"))
{
size.Width = match.Value.ToIntegerArray()[0];
size.Width = match.Value.ToPositiveIntegerArray()[0];
}
else
{
size.Height = match.Value.ToIntegerArray()[0];
size.Height = match.Value.ToPositiveIntegerArray()[0];
}
index += 1;

22
src/ImageProcessor/Processors/Rotate.cs

@ -37,28 +37,6 @@ namespace ImageProcessor.Processors
private static readonly Regex ColorRegex = new Regex(@"bgcolor-([0-9a-fA-F]{3}){1,2}", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Rotate";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Rotates an image at the given angle.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>

28
src/ImageProcessor/Processors/Saturate.cs

@ -21,37 +21,15 @@ namespace ImageProcessor.Processors
/// <remarks>
/// <see cref="http://www.bobpowell.net/imagesaturation.htm"/>
/// </remarks>
public class Saturate : IGraphicsProcessor
public class Saturation : IGraphicsProcessor
{
/// <summary>
/// The regular expression to search strings for.
/// <see cref="http://stackoverflow.com/a/6400969/427899"/>
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"saturate=(-|)(?:100|[1-9]?[0-9])", RegexOptions.Compiled);
private static readonly Regex QueryRegex = new Regex(@"saturation=(-?(?:100)|-?([1-9]?[0-9]))", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Saturate";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Changes the the saturation component of the image.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
@ -114,7 +92,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
int percentage = match.Value.ToIntegerArray()[0];
int percentage = int.Parse(match.Value.Split('=')[1]);
this.DynamicParameter = percentage;
}

22
src/ImageProcessor/Processors/Vignette.cs

@ -26,28 +26,6 @@ namespace ImageProcessor.Processors
private static readonly Regex QueryRegex = new Regex(@"vignette=true", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Vignette";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Adds a vignette image effect to the image.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>

30
src/ImageProcessor/Processors/Watermark.cs

@ -45,12 +45,12 @@ private static readonly Regex PositionRegex = new Regex(@"position-\d+-\d+", Reg
private static readonly Regex ColorRegex = new Regex(@"color-([0-9a-fA-F]{3}){1,2}", RegexOptions.Compiled);
/// <summary>
/// The regular expression to search strings for the fontsize attribute.
/// The regular expression to search strings for the font size attribute.
/// </summary>
private static readonly Regex FontSizeRegex = new Regex(@"size-\d{1,3}", RegexOptions.Compiled);
/// <summary>
/// The regular expression to search strings for the fontstyle attribute.
/// The regular expression to search strings for the font style attribute.
/// </summary>
private static readonly Regex FontStyleRegex = new Regex(@"style-(bold|italic|regular|strikeout|underline)", RegexOptions.Compiled);
@ -70,28 +70,6 @@ private static readonly Regex OpacityRegex = new Regex(@"opacity-(?:100|[1-9]?[0
private static readonly Regex ShadowRegex = new Regex(@"shadow-true", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the name.
/// </summary>
public string Name
{
get
{
return "Watermark";
}
}
/// <summary>
/// Gets the description.
/// </summary>
public string Description
{
get
{
return "Adds a watermark containing text to the image.";
}
}
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
@ -333,7 +311,7 @@ private static readonly Regex ShadowRegex = new Regex(@"shadow-true", RegexOptio
{
foreach (Match match in PositionRegex.Matches(input))
{
int[] position = match.Value.ToIntegerArray();
int[] position = match.Value.ToPositiveIntegerArray();
if (position != null)
{
@ -392,7 +370,7 @@ private static readonly Regex ShadowRegex = new Regex(@"shadow-true", RegexOptio
/// Returns the correct <see cref="T:System.Drawing.FontStyle"/> for the given string.
/// </summary>
/// <param name="input">
/// The string containing the respective fontstyle.
/// The string containing the respective font style.
/// </param>
/// <returns>
/// The correct <see cref="T:System.Drawing.FontStyle"/>

Loading…
Cancel
Save