Browse Source

Add ColorMatrix functionality

Former-commit-id: 741ed5325553c7e521375e2b6168cfd345fe69d5
Former-commit-id: f290ab071672406c5f3d846cedea2e7c280329c0
Former-commit-id: 1ca475830cd7732a17fb3f407418189aea692e8e
af/merge-core
James Jackson-South 10 years ago
parent
commit
5e0d0de329
  1. 35
      src/ImageProcessor/Filters/ColorMatrix/BlackWhite.cs
  2. 273
      src/ImageProcessor/Filters/ColorMatrix/ColorMatrix.cs
  3. 101
      src/ImageProcessor/Filters/ColorMatrix/ColorMatrixFilter.cs
  4. 35
      src/ImageProcessor/Filters/ColorMatrix/GreyscaleBt601.cs
  5. 35
      src/ImageProcessor/Filters/ColorMatrix/GreyscaleBt709.cs
  6. 35
      src/ImageProcessor/Filters/ColorMatrix/Invert.cs
  7. 35
      src/ImageProcessor/Filters/ColorMatrix/Lomograph.cs
  8. 35
      src/ImageProcessor/Filters/ColorMatrix/Polaroid.cs
  9. 35
      src/ImageProcessor/Filters/ColorMatrix/Sepia.cs
  10. 23
      src/ImageProcessor/Filters/ImageFilterExtensions.cs
  11. 2
      src/ImageProcessor/Formats/Gif/Quantizer/Quantizer.cs
  12. 18
      src/ImageProcessor/ImageProcessor.csproj
  13. 1
      src/ImageProcessor/ImageProcessor.csproj.DotSettings
  14. 6
      src/ImageProcessor/Settings.StyleCop
  15. 2
      src/ImageProcessor/packages.config
  16. 7
      tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs

35
src/ImageProcessor/Filters/ColorMatrix/BlackWhite.cs

@ -0,0 +1,35 @@
// <copyright file="BlackWhite.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessor.Filters
{
/// <summary>
/// Converts the colors of the image to their black and white equivalent.
/// </summary>
public class BlackWhite : ColorMatrixFilter
{
/// <summary>
/// The BlackWhite matrix.
/// TODO: Calculate a matrix that works in the linear color space.
/// </summary>
private static readonly ColorMatrix Matrix = new ColorMatrix(
new[]
{
new[] { 1.5f, 1.5f, 1.5f, 0, 0 },
new[] { 1.5f, 1.5f, 1.5f, 0, 0 },
new[] { 1.5f, 1.5f, 1.5f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { -1, -1, -1, 0, 1 }
});
/// <summary>
/// Initializes a new instance of the <see cref="BlackWhite"/> class.
/// </summary>
public BlackWhite()
: base(Matrix, false)
{
}
}
}

273
src/ImageProcessor/Filters/ColorMatrix/ColorMatrix.cs

@ -0,0 +1,273 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ColorMatrix.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Filters
{
/// <summary>
/// Defines a 5 x 5 matrix that contains the coordinates for the RGBAW color space.
/// </summary>
public sealed class ColorMatrix
{
/// <summary>
/// Initializes a new instance of the <see cref="ColorMatrix"/> class.
/// </summary>
public ColorMatrix()
{
// Setup the identity matrix by default
this.Matrix00 = 1.0f;
this.Matrix11 = 1.0f;
this.Matrix22 = 1.0f;
this.Matrix33 = 1.0f;
this.Matrix44 = 1.0f;
}
/// <summary>
/// Initializes a new instance of the <see cref="ColorMatrix"/> class with the
/// elements in the specified matrix.
/// </summary>
/// <param name="colorMatrix">
/// The elements defining the new Color Matrix.
/// </param>
public ColorMatrix(float[][] colorMatrix)
{
this.SetMatrix(colorMatrix);
}
/// <summary>
/// Gets or sets the element at the 0th row and 0th column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix00 { get; set; }
/// <summary>
/// Gets or sets the element at the 0th row and 1st column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix01 { get; set; }
/// <summary>
/// Gets or sets the element at the 0th row and 2nd column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix02 { get; set; }
/// <summary>
/// Gets or sets the element at the 0th row and 3rd column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix03 { get; set; }
/// <summary>
/// Gets or sets the element at the 0th row and 4th column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix04 { get; set; }
/// <summary>
/// Gets or sets the element at the 1st row and 0th column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix10 { get; set; }
/// <summary>
/// Gets or sets the element at the 1st row and 1st column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix11 { get; set; }
/// <summary>
/// Gets or sets the element at the 1st row and 2nd column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix12 { get; set; }
/// <summary>
/// Gets or sets the element at the 1st row and 3rd column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix13 { get; set; }
/// <summary>
/// Gets or sets the element at the 1st row and 4th column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix14 { get; set; }
/// <summary>
/// Gets or sets the element at the 2nd row and 0th column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix20 { get; set; }
/// <summary>
/// Gets or sets the element at the 2nd row and 1st column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix21 { get; set; }
/// <summary>
/// Gets or sets the element at the 2nd row and 2nd column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix22 { get; set; }
/// <summary>
/// Gets or sets the element at the 2nd row and 3rd column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix23 { get; set; }
/// <summary>
/// Gets or sets the element at the 2nd row and 4th column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix24 { get; set; }
/// <summary>
/// Gets or sets the element at the 3rd row and 0th column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix30 { get; set; }
/// <summary>
/// Gets or sets the element at the 3rd row and 1st column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix31 { get; set; }
/// <summary>
/// Gets or sets the element at the 3rd row and 2nd column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix32 { get; set; }
/// <summary>
/// Gets or sets the element at the 3rd row and 3rd column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix33 { get; set; }
/// <summary>
/// Gets or sets the element at the 3rd row and 4th column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix34 { get; set; }
/// <summary>
/// Gets or sets the element at the 4th row and 0th column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix40 { get; set; }
/// <summary>
/// Gets or sets the element at the 4th row and 1st column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix41 { get; set; }
/// <summary>
/// Gets or sets the element at the 4th row and 2nd column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix42 { get; set; }
/// <summary>
/// Gets or sets the element at the 4th row and 3rd column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix43 { get; set; }
/// <summary>
/// Gets or sets the element at the 4th row and 4th column of this <see cref="ColorMatrix"/>.
/// </summary>
public float Matrix44 { get; set; }
/// <summary>
/// Gets or sets the value of the specified element of this <see cref="ColorMatrix"/>.
/// </summary>
/// <param name="row">
/// The row index.
/// </param>
/// <param name="column">
/// The column index.
/// </param>
/// <returns>
/// The <see cref="float"/>.
/// </returns>
public float this[int row, int column]
{
get
{
return this.GetMatrix()[row][column];
}
set
{
float[][] tempMatrix = this.GetMatrix();
tempMatrix[row][column] = value;
this.SetMatrix(tempMatrix);
}
}
/// <summary>
/// Sets the values of this <see cref="ColorMatrix"/> to the values contained within the elements.
/// </summary>
/// <param name="colorMatrix">
/// The new color matrix.
/// </param>
internal void SetMatrix(float[][] colorMatrix)
{
this.Matrix00 = colorMatrix[0][0];
this.Matrix01 = colorMatrix[0][1];
this.Matrix02 = colorMatrix[0][2];
this.Matrix03 = colorMatrix[0][3];
this.Matrix04 = colorMatrix[0][4];
this.Matrix10 = colorMatrix[1][0];
this.Matrix11 = colorMatrix[1][1];
this.Matrix12 = colorMatrix[1][2];
this.Matrix13 = colorMatrix[1][3];
this.Matrix14 = colorMatrix[1][4];
this.Matrix20 = colorMatrix[2][0];
this.Matrix21 = colorMatrix[2][1];
this.Matrix22 = colorMatrix[2][2];
this.Matrix23 = colorMatrix[2][3];
this.Matrix24 = colorMatrix[2][4];
this.Matrix30 = colorMatrix[3][0];
this.Matrix31 = colorMatrix[3][1];
this.Matrix32 = colorMatrix[3][2];
this.Matrix33 = colorMatrix[3][3];
this.Matrix34 = colorMatrix[3][4];
this.Matrix40 = colorMatrix[4][0];
this.Matrix41 = colorMatrix[4][1];
this.Matrix42 = colorMatrix[4][2];
this.Matrix43 = colorMatrix[4][3];
this.Matrix44 = colorMatrix[4][4];
}
/// <summary>
/// Gets this <see cref="ColorMatrix"/>.
/// </summary>
/// <returns>
/// The <see cref="T:float[][]"/>.
/// </returns>
internal float[][] GetMatrix()
{
float[][] returnMatrix = new float[5][];
for (int i = 0; i < 5; i++)
{
returnMatrix[i] = new float[5];
}
returnMatrix[0][0] = this.Matrix00;
returnMatrix[0][1] = this.Matrix01;
returnMatrix[0][2] = this.Matrix02;
returnMatrix[0][3] = this.Matrix03;
returnMatrix[0][4] = this.Matrix04;
returnMatrix[1][0] = this.Matrix10;
returnMatrix[1][1] = this.Matrix11;
returnMatrix[1][2] = this.Matrix12;
returnMatrix[1][3] = this.Matrix13;
returnMatrix[1][4] = this.Matrix14;
returnMatrix[2][0] = this.Matrix20;
returnMatrix[2][1] = this.Matrix21;
returnMatrix[2][2] = this.Matrix22;
returnMatrix[2][3] = this.Matrix23;
returnMatrix[2][4] = this.Matrix24;
returnMatrix[3][0] = this.Matrix30;
returnMatrix[3][1] = this.Matrix31;
returnMatrix[3][2] = this.Matrix32;
returnMatrix[3][3] = this.Matrix33;
returnMatrix[3][4] = this.Matrix34;
returnMatrix[4][0] = this.Matrix40;
returnMatrix[4][1] = this.Matrix41;
returnMatrix[4][2] = this.Matrix42;
returnMatrix[4][3] = this.Matrix43;
returnMatrix[4][4] = this.Matrix44;
return returnMatrix;
}
}
}

101
src/ImageProcessor/Filters/ColorMatrix/ColorMatrixFilter.cs

@ -0,0 +1,101 @@
// <copyright file="ColorMatrixFilter.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessor.Filters
{
/// <summary>
/// The color matrix filter.
/// </summary>
public class ColorMatrixFilter : ParallelImageProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="ColorMatrixFilter"/> class.
/// </summary>
/// <param name="matrix">The matrix to apply.</param>
/// <param name="gammaAdjust">Whether to gamma adjust the colors before applying the matrix.</param>
public ColorMatrixFilter(ColorMatrix matrix, bool gammaAdjust)
{
this.Value = matrix;
this.GammaAdjust = gammaAdjust;
}
/// <summary>
/// Gets the matrix value.
/// </summary>
public ColorMatrix Value { get; }
/// <summary>
/// Gets a value indicating whether to gamma adjust the colors before applying the matrix.
/// </summary>
public bool GammaAdjust { get; }
/// <inheritdoc/>
protected override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
{
int sourceY = sourceRectangle.Y;
int sourceBottom = sourceRectangle.Bottom;
int startX = sourceRectangle.X;
int endX = sourceRectangle.Right;
ColorMatrix matrix = this.Value;
Bgra previousColor = source[0, 0];
Bgra pixelValue = this.ApplyMatrix(previousColor, matrix);
for (int y = startY; y < endY; y++)
{
if (y >= sourceY && y < sourceBottom)
{
for (int x = startX; x < endX; x++)
{
Bgra sourceColor = source[x, y];
// Check if this is the same as the last pixel. If so use that value
// rather than calculating it again. This is an inexpensive optimization.
if (sourceColor != previousColor)
{
// Perform the operation on the pixel.
pixelValue = this.ApplyMatrix(sourceColor, matrix);
// And setup the previous pointer
previousColor = sourceColor;
}
target[x, y] = pixelValue;
}
}
}
}
/// <summary>
/// Applies the color matrix against the given color.
/// </summary>
/// <param name="sourceColor">The source color.</param>
/// <param name="matrix">The matrix.</param>
/// <returns>
/// The <see cref="Bgra"/>.
/// </returns>
private Bgra ApplyMatrix(Bgra sourceColor, ColorMatrix matrix)
{
bool gamma = this.GammaAdjust;
if (gamma)
{
sourceColor = PixelOperations.ToLinear(sourceColor);
}
int sr = sourceColor.R;
int sg = sourceColor.G;
int sb = sourceColor.B;
int sa = sourceColor.A;
// TODO: Investigate RGBAW
byte r = ((sr * matrix.Matrix00) + (sg * matrix.Matrix10) + (sb * matrix.Matrix20) + (sa * matrix.Matrix30) + (255f * matrix.Matrix40)).ToByte();
byte g = ((sr * matrix.Matrix01) + (sg * matrix.Matrix11) + (sb * matrix.Matrix21) + (sa * matrix.Matrix31) + (255f * matrix.Matrix41)).ToByte();
byte b = ((sr * matrix.Matrix02) + (sg * matrix.Matrix12) + (sb * matrix.Matrix22) + (sa * matrix.Matrix32) + (255f * matrix.Matrix42)).ToByte();
byte a = ((sr * matrix.Matrix03) + (sg * matrix.Matrix13) + (sb * matrix.Matrix23) + (sa * matrix.Matrix33) + (255f * matrix.Matrix43)).ToByte();
return gamma ? PixelOperations.ToSrgb(new Bgra(b, g, r, a)) : new Bgra(b, g, r, a);
}
}
}

35
src/ImageProcessor/Filters/ColorMatrix/GreyscaleBt601.cs

@ -0,0 +1,35 @@
// <copyright file="GreyscaleBt601.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessor.Filters
{
/// <summary>
/// Converts the colors of the image to greyscale applying the formula as specified by
/// ITU-R Recommendation BT.601 <see href="https://en.wikipedia.org/wiki/Luma_%28video%29#Rec._601_luma_versus_Rec._709_luma_coefficients"/>.
/// </summary>
public class GreyscaleBt601 : ColorMatrixFilter
{
/// <summary>
/// The inversion matrix.
/// </summary>
private static readonly ColorMatrix Matrix = new ColorMatrix(
new[]
{
new float[] { 0.299f, 0.299f, 0.299f, 0, 0 },
new float[] { 0.587f, 0.587f, 0.587f, 0, 0 },
new float[] { 0.114f, 0.114f, 0.114f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 0, 0, 0, 0, 1 }
});
/// <summary>
/// Initializes a new instance of the <see cref="GreyscaleBt601"/> class.
/// </summary>
public GreyscaleBt601()
: base(Matrix, true)
{
}
}
}

35
src/ImageProcessor/Filters/ColorMatrix/GreyscaleBt709.cs

@ -0,0 +1,35 @@
// <copyright file="GreyscaleBt709.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessor.Filters
{
/// <summary>
/// Converts the colors of the image to greyscale applying the formula as specified by
/// ITU-R Recommendation BT.709 <see href="https://en.wikipedia.org/wiki/Rec._709#Luma_coefficients"/>.
/// </summary>
public class GreyscaleBt709 : ColorMatrixFilter
{
/// <summary>
/// The inversion matrix.
/// </summary>
private static readonly ColorMatrix Matrix = new ColorMatrix(
new[]
{
new float[] { 0.2126f, 0.2126f, 0.2126f, 0, 0 },
new float[] { 0.7152f, 0.7152f, 0.7152f, 0, 0 },
new float[] { 0.0722f, 0.0722f, 0.0722f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 0, 0, 0, 0, 1 }
});
/// <summary>
/// Initializes a new instance of the <see cref="GreyscaleBt709"/> class.
/// </summary>
public GreyscaleBt709()
: base(Matrix, true)
{
}
}
}

35
src/ImageProcessor/Filters/ColorMatrix/Invert.cs

@ -0,0 +1,35 @@
// <copyright file="Invert.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessor.Filters
{
/// <summary>
/// Inverts the colors of the image.
/// </summary>
public class Invert : ColorMatrixFilter
{
/// <summary>
/// The inversion matrix.
/// TODO: With gamma adjustment enabled this leaves the image too bright.
/// </summary>
private static readonly ColorMatrix Matrix = new ColorMatrix(
new[]
{
new float[] { -1, 0, 0, 0, 0 },
new float[] { 0, -1, 0, 0, 0 },
new float[] { 0, 0, -1, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 1, 1, 1, 0, 1 }
});
/// <summary>
/// Initializes a new instance of the <see cref="Invert"/> class.
/// </summary>
public Invert()
: base(Matrix, false)
{
}
}
}

35
src/ImageProcessor/Filters/ColorMatrix/Lomograph.cs

@ -0,0 +1,35 @@
// <copyright file="Lomograph.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessor.Filters
{
/// <summary>
/// Converts the colors of the image recreating an old Lomograph effect.
/// </summary>
public class Lomograph : ColorMatrixFilter
{
/// <summary>
/// The Lomograph matrix. Purely artistic in composition.
/// TODO: Calculate a matrix that works in the linear color space.
/// </summary>
private static readonly ColorMatrix Matrix = new ColorMatrix(
new[]
{
new[] { 1.50f, 0, 0, 0, 0 },
new[] { 0, 1.45f, 0, 0, 0 },
new[] { 0, 0, 1.09f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new[] { -0.10f, 0.05f, -0.08f, 0, 1 }
});
/// <summary>
/// Initializes a new instance of the <see cref="Lomograph"/> class.
/// </summary>
public Lomograph()
: base(Matrix, false)
{
}
}
}

35
src/ImageProcessor/Filters/ColorMatrix/Polaroid.cs

@ -0,0 +1,35 @@
// <copyright file="Polaroid.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessor.Filters
{
/// <summary>
/// Converts the colors of the image recreating an old Polaroid effect.
/// </summary>
public class Polaroid : ColorMatrixFilter
{
/// <summary>
/// The Polaroid matrix. Purely artistic in composition.
/// TODO: Calculate a matrix that works in the linear color space.
/// </summary>
private static readonly ColorMatrix Matrix = new ColorMatrix(
new[]
{
new[] { 1.638f, -0.062f, -0.262f, 0, 0 },
new[] { -0.122f, 1.378f, -0.122f, 0, 0 },
new[] { 1.016f, -0.016f, 1.383f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new[] { 0.06f, -0.05f, -0.05f, 0, 1 }
});
/// <summary>
/// Initializes a new instance of the <see cref="Polaroid"/> class.
/// </summary>
public Polaroid()
: base(Matrix, false)
{
}
}
}

35
src/ImageProcessor/Filters/ColorMatrix/Sepia.cs

@ -0,0 +1,35 @@
// <copyright file="Sepia.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessor.Filters
{
/// <summary>
/// Converts the colors of the image to their sepia equivalent recreating an old photo effect.
/// </summary>
public class Sepia : ColorMatrixFilter
{
/// <summary>
/// The sepia matrix.
/// TODO: Calculate a matrix that works in the linear color space.
/// </summary>
private static readonly ColorMatrix Matrix = new ColorMatrix(
new[]
{
new[] { .393f, .349f, .272f, 0, 0 },
new[] { .769f, .686f, .534f, 0, 0 },
new[] { .189f, .168f, .131f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 0, 0, 0, 0, 1 }
});
/// <summary>
/// Initializes a new instance of the <see cref="Sepia"/> class.
/// </summary>
public Sepia()
: base(Matrix, false)
{
}
}
}

23
src/ImageProcessor/Filters/ImageFilterExtensions.cs

@ -59,5 +59,28 @@ namespace ImageProcessor.Filters
{
return source.Process(sourceRectangle, new Alpha(percent));
}
/// <summary>
/// Alters the alpha component of the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image"/>.</returns>
public static Image Invert(this Image source)
{
return Invert(source, source.Bounds);
}
/// <summary>
/// Alters the alpha component of the image.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="sourceRectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
/// </param>
/// <returns>The <see cref="Image"/>.</returns>
public static Image Invert(this Image source, Rectangle sourceRectangle)
{
return source.Process(sourceRectangle, new Invert());
}
}
}

2
src/ImageProcessor/Formats/Gif/Quantizer/Quantizer.cs

@ -74,7 +74,7 @@ namespace ImageProcessor.Formats
// Loop through each row
for (int y = 0; y < height; y++)
{
// And loop through each xumn
// And loop through each column
for (int x = 0; x < width; x++)
{
// Now I have the pixel, call the FirstPassQuantize function...

18
src/ImageProcessor/ImageProcessor.csproj

@ -17,6 +17,7 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>cfa9b76b</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -27,6 +28,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\ImageProcessor.XML</DocumentationFile>
<LangVersion>default</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -44,6 +46,15 @@
<Compile Include="Common\Helpers\ImageMaths.cs" />
<Compile Include="Common\Helpers\PixelOperations.cs" />
<Compile Include="Filters\Alpha.cs" />
<Compile Include="Filters\ColorMatrix\ColorMatrix.cs" />
<Compile Include="Filters\ColorMatrix\ColorMatrixFilter.cs" />
<Compile Include="Filters\ColorMatrix\GreyscaleBt601.cs" />
<Compile Include="Filters\ColorMatrix\GreyscaleBt709.cs" />
<Compile Include="Filters\ColorMatrix\BlackWhite.cs" />
<Compile Include="Filters\ColorMatrix\Polaroid.cs" />
<Compile Include="Filters\ColorMatrix\Lomograph.cs" />
<Compile Include="Filters\ColorMatrix\Sepia.cs" />
<Compile Include="Filters\ColorMatrix\Invert.cs" />
<Compile Include="Filters\Contrast.cs" />
<Compile Include="Filters\ImageFilterExtensions.cs" />
<Compile Include="ImageExtensions.cs" />
@ -210,21 +221,24 @@
<None Include="Formats\Gif\README.md" />
<None Include="Formats\Jpg\README.md" />
<None Include="packages.config" />
<None Include="stylecop.json" />
</ItemGroup>
<ItemGroup>
<None Include="Formats\Bmp\README.md" />
<None Include="Formats\Png\README.md" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-beta013\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-beta013\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-beta015\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0-beta015\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\StyleCop.Analyzers.1.0.0-beta015\build\StyleCop.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\StyleCop.Analyzers.1.0.0-beta015\build\StyleCop.Analyzers.targets'))" />
</Target>
<Import Project="..\..\packages\StyleCop.Analyzers.1.0.0-beta015\build\StyleCop.Analyzers.targets" Condition="Exists('..\..\packages\StyleCop.Analyzers.1.0.0-beta015\build\StyleCop.Analyzers.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

1
src/ImageProcessor/ImageProcessor.csproj.DotSettings

@ -6,6 +6,7 @@
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=common_005Cextensions/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=common_005Chelpers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=encoders_005Cgif/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=filters_005Ccolormatrix/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=formats_005Cbmp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=formats_005Cgif/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=formats_005Cgif_005Cquantizer/@EntryIndexedValue">True</s:Boolean>

6
src/ImageProcessor/Settings.StyleCop

@ -12,6 +12,12 @@
<Value>scanlines</Value>
<Value>tEXt</Value>
<Value>xt</Value>
<Value>th</Value>
<Value>nd</Value>
<Value>rd</Value>
<Value>lomograph</Value>
<Value>polaroid</Value>
<Value>colorspace</Value>
</CollectionProperty>
</GlobalSettings>
</StyleCopSettings>

2
src/ImageProcessor/packages.config

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SharpZipLib.Portable" version="0.86.0.0002" targetFramework="portable-net45+win8+wp8" />
<package id="StyleCop.Analyzers" version="1.0.0-beta013" targetFramework="portable45-net45+win8+wp8" developmentDependency="true" />
<package id="StyleCop.Analyzers" version="1.0.0-beta015" targetFramework="portable-net45+dnxcore50+win+wpa81+wp80" developmentDependency="true" />
</packages>

7
tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs

@ -15,6 +15,13 @@ namespace ImageProcessor.Tests
{ "Contrast-50", new Contrast(50) },
{ "Contrast--50", new Contrast(-50) },
{ "Alpha--50", new Alpha(50) },
{ "Invert", new Invert() },
{ "Sepia", new Sepia() },
{ "BlackWhite", new BlackWhite() },
{ "Lomograph", new Lomograph() },
{ "Polaroid", new Polaroid() },
{ "GreyscaleBt709", new GreyscaleBt709() },
{ "GreyscaleBt601", new GreyscaleBt601() },
};
[Theory]

Loading…
Cancel
Save