Browse Source

Merge branch 'beta-1' of https://github.com/SixLabors/ImageSharp into beta-1

pull/299/head
James Jackson-South 9 years ago
parent
commit
a7befcb8be
  1. 2
      tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs
  2. 4
      tests/ImageSharp.Tests/Processing/Processors/Binarization/DitherTests.cs
  3. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/BlackWhiteTest.cs
  4. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/ColorBlindnessTest.cs
  5. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/GrayscaleTest.cs
  6. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/HueTest.cs
  7. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/KodachromeTest.cs
  8. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/LomographTest.cs
  9. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/PolaroidTest.cs
  10. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/SaturationTest.cs
  11. 2
      tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/SepiaTest.cs
  12. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs
  13. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs
  14. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs
  15. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/AlphaTest.cs
  16. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs
  17. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/BrightnessTest.cs
  18. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/ContrastTest.cs
  19. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/InvertTest.cs
  20. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs
  21. 2
      tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs
  22. 2
      tests/ImageSharp.Tests/Processing/Processors/Overlays/GlowTest.cs
  23. 2
      tests/ImageSharp.Tests/Processing/Processors/Overlays/VignetteTest.cs
  24. 51
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs

2
tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs

@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
image.Mutate(x => x.BinaryThreshold(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

4
tests/ImageSharp.Tests/Processing/Processors/Binarization/DitherTests.cs

@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
image.Mutate(x => x.Dither(DefaultDitherer, bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
image.Mutate(x => x.Dither(DefaultErrorDiffuser, .5F, bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/BlackWhiteTest.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.ColorMatrix
image.Mutate(x => x.BlackWhite(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/ColorBlindnessTest.cs

@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.ColorMatrix
image.Mutate(x => x.ColorBlindness(colorBlindness, bounds));
image.DebugSave(provider, colorBlindness.ToString());
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/GrayscaleTest.cs

@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.ColorMatrix
image.Mutate(x => x.Grayscale(value, bounds));
image.DebugSave(provider, value.ToString());
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/HueTest.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.ColorMatrix
image.Mutate(x => x.Hue(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/KodachromeTest.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.ColorMatrix
image.Mutate(x => x.Kodachrome(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/LomographTest.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.ColorMatrix
image.Mutate(x => x.Lomograph(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/PolaroidTest.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.ColorMatrix
image.Mutate(x => x.Polaroid(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/SaturationTest.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.ColorMatrix
image.Mutate(x => x.Saturation(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/ColorMatrix/SepiaTest.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.ColorMatrix
image.Mutate(x => x.Sepia(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/BoxBlurTest.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution
image.Mutate(x => x.BoxBlur(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution
image.Mutate(x => x.GaussianBlur(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution
image.Mutate(x => x.GaussianSharpen(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Effects/AlphaTest.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
image.Mutate(x => x.Alpha(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
image.Mutate(x => x.BackgroundColor(NamedColors<TPixel>.HotPink, bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Effects/BrightnessTest.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
image.Mutate(x => x.Brightness(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Effects/ContrastTest.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
image.Mutate(x => x.Contrast(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Effects/InvertTest.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
image.Mutate(x => x.Invert(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
image.Mutate(x => x.OilPaint(levels, brushSize, bounds));
image.DebugSave(provider, string.Join("-", levels, brushSize));
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs

@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
}
}
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Overlays/GlowTest.cs

@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays
image.Mutate(x => x.Glow(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

2
tests/ImageSharp.Tests/Processing/Processors/Overlays/VignetteTest.cs

@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays
image.Mutate(x => x.Vignette(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().EnsureProcessorChangesAreConstrained(source, image, bounds);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}

51
tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
{
result.Add(report);
}
if (expected.Frames.Count != actual.Frames.Count)
{
throw new Exception("Frame count does not match!");
@ -82,29 +82,46 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
}
}
/// <summary>
/// Fills the bounded area with a solid color and does a visual comparison between 2 images asserting the difference outwith
/// that area is less then a configurable threshold.
/// </summary>
/// <typeparam name="TPixelA">The color of the expected image</typeparam>
/// <typeparam name="TPixelB">The color type fo the the actual image</typeparam>
/// <param name="comparer">The <see cref="ImageComparer"/> to use</param>
/// <param name="expected">The expected image</param>
/// <param name="actual">The actual image</param>
/// <param name="bounds">The bounds within the image has been altered</param>
public static void EnsureProcessorChangesAreConstrained<TPixelA, TPixelB>(
public static void VerifySimilarityIgnoreRegion<TPixelA, TPixelB>(
this ImageComparer comparer,
Image<TPixelA> expected,
Image<TPixelB> actual,
Rectangle bounds)
Rectangle ignoredRegion)
where TPixelA : struct, IPixel<TPixelA>
where TPixelB : struct, IPixel<TPixelB>
{
// Draw identical shapes over the bounded and compare to ensure changes are constrained.
expected.Mutate(x => x.Fill(NamedColors<TPixelA>.HotPink, bounds));
actual.Mutate(x => x.Fill(NamedColors<TPixelB>.HotPink, bounds));
if (expected.Size() != actual.Size())
{
throw new ImageDimensionsMismatchException(expected.Size(), actual.Size());
}
if (expected.Frames.Count != actual.Frames.Count)
{
throw new ImagesSimilarityException("Image frame count does not match!");
}
comparer.VerifySimilarity(expected, actual);
IEnumerable<ImageSimilarityReport> reports = comparer.CompareImages(expected, actual);
if (reports.Any())
{
List<ImageSimilarityReport> cleanedReports = new List<ImageSimilarityReport>(reports.Count());
foreach (var r in reports)
{
var outsideChanges = r.Differences.Where(x => !(
ignoredRegion.X <= x.Position.X &&
x.Position.X <= ignoredRegion.Right &&
ignoredRegion.Y <= x.Position.Y &&
x.Position.Y <= ignoredRegion.Bottom));
if (outsideChanges.Any())
{
cleanedReports.Add(new ImageSimilarityReport(r.ExpectedImage, r.ActualImage, outsideChanges, null));
}
}
if (cleanedReports.Any())
{
throw new ImagePixelsAreDifferentException(cleanedReports);
}
}
}
}
}
Loading…
Cancel
Save