mirror of https://github.com/SixLabors/ImageSharp
126 changed files with 2283 additions and 2294 deletions
Binary file not shown.
@ -0,0 +1,51 @@ |
|||
// <copyright file="BinaryThresholdTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Binarization |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class BinaryThresholdTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<float> BinaryThresholdValues |
|||
= new TheoryData<float> |
|||
{ |
|||
.25F, |
|||
.75F |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(BinaryThresholdValues), DefaultPixelType)] |
|||
public void ImageShouldApplyBinaryThresholdFilter<TPixel>(TestImageProvider<TPixel> provider, float value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.BinaryThreshold(value) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(BinaryThresholdValues), DefaultPixelType)] |
|||
public void ImageShouldApplyBinaryThresholdInBox<TPixel>(TestImageProvider<TPixel> provider, float value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
|
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.BinaryThreshold(value, bounds) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
// <copyright file="DitherTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Binarization |
|||
{ |
|||
using ImageSharp.Dithering; |
|||
using ImageSharp.Dithering.Ordered; |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class DitherTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<string, IOrderedDither> Ditherers = new TheoryData<string, IOrderedDither> |
|||
{ |
|||
{ "Ordered", new Ordered() }, |
|||
{ "Bayer", new Bayer() } |
|||
}; |
|||
|
|||
public static readonly TheoryData<string, IErrorDiffuser> ErrorDiffusers = new TheoryData<string, IErrorDiffuser> |
|||
{ |
|||
{ "Atkinson", new Atkinson() }, |
|||
{ "Burks", new Burks() }, |
|||
{ "FloydSteinberg", new FloydSteinberg() }, |
|||
{ "JarvisJudiceNinke", new JarvisJudiceNinke() }, |
|||
{ "Sierra2", new Sierra2() }, |
|||
{ "Sierra3", new Sierra3() }, |
|||
{ "SierraLite", new SierraLite() }, |
|||
{ "Stucki", new Stucki() }, |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(Ditherers), DefaultPixelType)] |
|||
public void ImageShouldApplyDitherFilter<TPixel>(TestImageProvider<TPixel> provider, string name, IOrderedDither ditherer) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Dither(ditherer) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(Ditherers), DefaultPixelType)] |
|||
public void ImageShouldApplyDitherFilterInBox<TPixel>(TestImageProvider<TPixel> provider, string name, IOrderedDither ditherer) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Dither(ditherer, bounds) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(ErrorDiffusers), DefaultPixelType)] |
|||
public void ImageShouldApplyDiffusionFilter<TPixel>(TestImageProvider<TPixel> provider, string name, IErrorDiffuser diffuser) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Dither(diffuser, .5F) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(ErrorDiffusers), DefaultPixelType)] |
|||
public void ImageShouldApplyDiffusionFilterInBox<TPixel>(TestImageProvider<TPixel> provider, string name, IErrorDiffuser diffuser) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Dither(diffuser,.5F, bounds) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
// <copyright file="BlackWhiteTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.ColorMatrix |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class BlackWhiteTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyBlackWhiteFilter<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.BlackWhite() |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyBlackWhiteFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.BlackWhite(bounds) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
// <copyright file="ColorBlindnessTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.ColorMatrix |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
using ImageSharp.Processing; |
|||
|
|||
using Xunit; |
|||
|
|||
public class ColorBlindnessTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<ColorBlindness> ColorBlindnessFilters |
|||
= new TheoryData<ColorBlindness> |
|||
{ |
|||
ColorBlindness.Achromatomaly, |
|||
ColorBlindness.Achromatopsia, |
|||
ColorBlindness.Deuteranomaly, |
|||
ColorBlindness.Deuteranopia, |
|||
ColorBlindness.Protanomaly, |
|||
ColorBlindness.Protanopia, |
|||
ColorBlindness.Tritanomaly, |
|||
ColorBlindness.Tritanopia |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(ColorBlindnessFilters), DefaultPixelType)] |
|||
public void ImageShouldApplyColorBlindnessFilter<TPixel>(TestImageProvider<TPixel> provider, ColorBlindness colorBlindness) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.ColorBlindness(colorBlindness) |
|||
.DebugSave(provider, colorBlindness.ToString(), Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(ColorBlindnessFilters), DefaultPixelType)] |
|||
public void ImageShouldApplyColorBlindnessFilterInBox<TPixel>(TestImageProvider<TPixel> provider, ColorBlindness colorBlindness) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.ColorBlindness(colorBlindness, bounds) |
|||
.DebugSave(provider, colorBlindness.ToString(), Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
// <copyright file="HueTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.ColorMatrix |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class HueTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int> HueValues |
|||
= new TheoryData<int> |
|||
{ |
|||
180, |
|||
-180 |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(HueValues), DefaultPixelType)] |
|||
public void ImageShouldApplyHueFilter<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Hue(value) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(HueValues), DefaultPixelType)] |
|||
public void ImageShouldApplyHueFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Hue(value, bounds) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
// <copyright file="KodachromeTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.ColorMatrix |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class KodachromeTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyKodachromeFilter<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Kodachrome() |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyKodachromeFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Kodachrome(bounds) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
// <copyright file="LomographTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class LomographTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyLomographFilter<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Lomograph() |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyLomographFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Lomograph(bounds) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
// <copyright file="PolaroidTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.ColorMatrix |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class PolaroidTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyPolaroidFilter<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Polaroid() |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyPolaroidFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Polaroid(bounds) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
// <copyright file="SaturationTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.ColorMatrix |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class SaturationTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int> SaturationValues |
|||
= new TheoryData<int> |
|||
{ |
|||
50 , |
|||
-50 , |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(SaturationValues), DefaultPixelType)] |
|||
public void ImageShouldApplySaturationFilter<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Saturation(value) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(SaturationValues), DefaultPixelType)] |
|||
public void ImageShouldApplySaturationFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Saturation(value, bounds) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
// <copyright file="SepiaTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.ColorMatrix |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class SepiaTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplySepiaFilter<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Sepia() |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplySepiaFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Sepia(bounds) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
// <copyright file="BoxBlurTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Convolution |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class BoxBlurTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int> BoxBlurValues |
|||
= new TheoryData<int> |
|||
{ |
|||
3, |
|||
5 |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(BoxBlurValues), DefaultPixelType)] |
|||
public void ImageShouldApplyBoxBlurFilter<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.BoxBlur(value) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(BoxBlurValues), DefaultPixelType)] |
|||
public void ImageShouldApplyBoxBlurFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.BoxBlur(value, bounds) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
// <copyright file="DetectEdgesTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Convolution |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
using ImageSharp.Processing; |
|||
|
|||
using Xunit; |
|||
|
|||
public class DetectEdgesTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<EdgeDetection> DetectEdgesFilters |
|||
= new TheoryData<EdgeDetection> |
|||
{ |
|||
EdgeDetection.Kayyali, |
|||
EdgeDetection.Kirsch, |
|||
EdgeDetection.Lapacian3X3, |
|||
EdgeDetection.Lapacian5X5, |
|||
EdgeDetection.LaplacianOfGaussian, |
|||
EdgeDetection.Prewitt, |
|||
EdgeDetection.RobertsCross, |
|||
EdgeDetection.Robinson, |
|||
EdgeDetection.Scharr, |
|||
EdgeDetection.Sobel |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(DetectEdgesFilters), DefaultPixelType)] |
|||
public void ImageShouldApplyDetectEdgesFilter<TPixel>(TestImageProvider<TPixel> provider, EdgeDetection detector) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.DetectEdges(detector) |
|||
.DebugSave(provider, detector.ToString(), Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(DetectEdgesFilters), DefaultPixelType)] |
|||
public void ImageShouldApplyDetectEdgesFilterInBox<TPixel>(TestImageProvider<TPixel> provider, EdgeDetection detector) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.DetectEdges(detector, bounds) |
|||
.DebugSave(provider, detector.ToString(), Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
// <copyright file="AlphaTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Effects |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class AlphaTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<float> AlphaValues |
|||
= new TheoryData<float> |
|||
{ |
|||
20/100F, |
|||
80/100F |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(AlphaValues), DefaultPixelType)] |
|||
public void ImageShouldApplyAlphaFilter<TPixel>(TestImageProvider<TPixel> provider, float value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Alpha(value) |
|||
.DebugSave(provider, value, Extensions.Png); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(AlphaValues), DefaultPixelType)] |
|||
public void ImageShouldApplyAlphaFilterInBox<TPixel>(TestImageProvider<TPixel> provider, float value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Alpha(value, bounds) |
|||
.DebugSave(provider, value, Extensions.Png); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
// <copyright file="BackgroundColorTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Effects |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class BackgroundColorTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyBackgroundColorFilter<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.BackgroundColor(NamedColors<TPixel>.HotPink) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyBackgroundColorFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.BackgroundColor(NamedColors<TPixel>.HotPink, bounds) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
// <copyright file="BrightnessTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Effects |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class BrightnessTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int> BrightnessValues |
|||
= new TheoryData<int> |
|||
{ |
|||
50, |
|||
-50 |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(BrightnessValues), DefaultPixelType)] |
|||
public void ImageShouldApplyBrightnessFilter<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Brightness(value) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(BrightnessValues), DefaultPixelType)] |
|||
public void ImageShouldApplyBrightnessFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Brightness(value, bounds) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); ; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
// <copyright file="ContrastTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Effects |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class ContrastTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int> ContrastValues |
|||
= new TheoryData<int> |
|||
{ |
|||
50, |
|||
-50 |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(ContrastValues), DefaultPixelType)] |
|||
public void ImageShouldApplyContrastFilter<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Contrast(value) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(ContrastValues), DefaultPixelType)] |
|||
public void ImageShouldApplyContrastFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Contrast(value, bounds) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
// <copyright file="InvertTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Effects |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class InvertTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyInvertFilter<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Invert() |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyInvertFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Invert(bounds) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
// <copyright file="OilPaintTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class OilPaintTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int, int> OilPaintValues |
|||
= new TheoryData<int, int> |
|||
{ |
|||
{ 15, 10 }, |
|||
{ 6, 5 } |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(OilPaintValues), DefaultPixelType)] |
|||
public void ImageShouldApplyOilPaintFilter<TPixel>(TestImageProvider<TPixel> provider, int levels, int brushSize) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.OilPaint(levels, brushSize) |
|||
.DebugSave(provider, string.Join("-", levels, brushSize), Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(OilPaintValues), DefaultPixelType)] |
|||
public void ImageShouldApplyOilPaintFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int levels, int brushSize) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.OilPaint(levels, brushSize, bounds) |
|||
.DebugSave(provider, string.Join("-", levels, brushSize), Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds, 0.001F); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,84 @@ |
|||
// <copyright file="PixelateTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Effects |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class PixelateTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int> PixelateValues |
|||
= new TheoryData<int> |
|||
{ |
|||
4 , |
|||
8 |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithTestPatternImages(nameof(PixelateValues), 320, 240, PixelTypes.Rgba32)] |
|||
public void ImageShouldApplyPixelateFilter<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Pixelate(value) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
|
|||
// Test the neigbouring pixels
|
|||
for (int y = 0; y < image.Height; y += value) |
|||
{ |
|||
for (int x = 0; x < image.Width; x += value) |
|||
{ |
|||
TPixel source = image[x, y]; |
|||
for (int pixY = y; pixY < y + value && pixY < image.Height; pixY++) |
|||
{ |
|||
for (int pixX = x; pixX < x + value && pixX < image.Width; pixX++) |
|||
{ |
|||
Assert.Equal(source, image[pixX, pixY]); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithTestPatternImages(nameof(PixelateValues), 320, 240, PixelTypes.Rgba32)] |
|||
public void ImageShouldApplyPixelateFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Pixelate(value, bounds) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
|
|||
for (int y = 0; y < image.Height; y++) |
|||
{ |
|||
for (int x = 0; x < image.Width; x++) |
|||
{ |
|||
int tx = x; |
|||
int ty = y; |
|||
TPixel sourceColor = source[tx, ty]; |
|||
if (bounds.Contains(tx, ty)) |
|||
{ |
|||
int sourceX = tx - ((tx - bounds.Left) % value) + (value / 2); |
|||
int sourceY = ty - ((ty - bounds.Top) % value) + (value / 2); |
|||
|
|||
sourceColor = image[sourceX, sourceY]; |
|||
} |
|||
Assert.Equal(sourceColor, image[tx, ty]); |
|||
} |
|||
} |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
// <copyright file="GlowTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Overlays |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class GlowTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyGlowFilter<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Glow() |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyGlowFilterColor<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Glow(NamedColors<TPixel>.Orange) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyGlowFilterRadius<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Glow(image.Width / 4F) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyGlowFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Glow(bounds) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
// <copyright file="VignetteTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Overlays |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class VignetteTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyVignetteFilter<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Vignette() |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyVignetteFilterColor<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Vignette(NamedColors<TPixel>.Orange) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyVignetteFilterRadius<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Vignette(image.Width / 4F, image.Height / 4F) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldApplyVignetteFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> source = provider.GetImage()) |
|||
using (var image = new Image<TPixel>(source)) |
|||
{ |
|||
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Vignette(bounds) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
|
|||
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
// <copyright file="CropTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Transforms |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class CropTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldCrop<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Crop(image.Width / 2, image.Height / 2) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
// <copyright file="EntropyCropTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Transforms |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class EntropyCropTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<float> EntropyCropValues |
|||
= new TheoryData<float> |
|||
{ |
|||
.25F, |
|||
.75F |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(EntropyCropValues), DefaultPixelType)] |
|||
public void ImageShouldEntropyCrop<TPixel>(TestImageProvider<TPixel> provider, float value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.EntropyCrop(value) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
// <copyright file="FlipTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Transforms |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
using ImageSharp.Processing; |
|||
|
|||
using Xunit; |
|||
|
|||
public class FlipTests : FileTestBase |
|||
{ |
|||
public static readonly string[] FlipFiles = { TestImages.Bmp.F }; |
|||
|
|||
public static readonly TheoryData<FlipType> FlipValues |
|||
= new TheoryData<FlipType> |
|||
{ |
|||
{ FlipType.None }, |
|||
{ FlipType.Vertical }, |
|||
{ FlipType.Horizontal }, |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(FlipFiles), nameof(FlipValues), DefaultPixelType)] |
|||
public void ImageShouldFlip<TPixel>(TestImageProvider<TPixel> provider, FlipType flipType) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Flip(flipType) |
|||
.DebugSave(provider, flipType, Extensions.Bmp); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
// <copyright file="PadTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Transforms |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class PadTest : FileTestBase |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
|||
public void ImageShouldPad<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Pad(image.Width + 50, image.Height + 50) |
|||
.DebugSave(provider, null, Extensions.Bmp); |
|||
|
|||
// Check pixels are empty
|
|||
for (int y = 0; y < 25; y++) |
|||
{ |
|||
for (int x = 0; x < 25; x++) |
|||
{ |
|||
Assert.Equal(image[x, y], default(TPixel)); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,273 @@ |
|||
// <copyright file="ResizeTests.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Transforms |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
using ImageSharp.Processing; |
|||
|
|||
using Xunit; |
|||
|
|||
public class ResizeTests : FileTestBase |
|||
{ |
|||
public static readonly string[] ResizeFiles = { TestImages.Jpeg.Baseline.Calliphora }; |
|||
|
|||
public static readonly TheoryData<string, IResampler> ReSamplers = |
|||
new TheoryData<string, IResampler> |
|||
{ |
|||
{ "Bicubic", new BicubicResampler() }, |
|||
{ "Triangle", new TriangleResampler() }, |
|||
{ "NearestNeighbor", new NearestNeighborResampler() }, |
|||
{ "Box", new BoxResampler() }, |
|||
{ "Lanczos3", new Lanczos3Resampler() }, |
|||
{ "Lanczos5", new Lanczos5Resampler() }, |
|||
{ "MitchellNetravali", new MitchellNetravaliResampler() }, |
|||
{ "Lanczos8", new Lanczos8Resampler() }, |
|||
{ "Hermite", new HermiteResampler() }, |
|||
{ "Spline", new SplineResampler() }, |
|||
{ "Robidoux", new RobidouxResampler() }, |
|||
{ "RobidouxSharp", new RobidouxSharpResampler() }, |
|||
{ "Welch", new WelchResampler() } |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResize<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Resize(image.Width / 2, image.Height / 2, sampler, true) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResizeFromSourceRectangle<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
var sourceRectangle = new Rectangle(image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); |
|||
var destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); |
|||
|
|||
image.Resize(image.Width, image.Height, sampler, sourceRectangle, destRectangle, false) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResizeWidthAndKeepAspect<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Resize(image.Width / 3, 0, sampler, false) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResizeHeightAndKeepAspect<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Resize(0, image.Height / 3, sampler, false) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResizeWithCropWidthMode<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
var options = new ResizeOptions |
|||
{ |
|||
Sampler = sampler, |
|||
Size = new Size(image.Width / 2, image.Height) |
|||
}; |
|||
|
|||
image.Resize(options) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResizeWithCropHeightMode<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
var options = new ResizeOptions |
|||
{ |
|||
Sampler = sampler, |
|||
Size = new Size(image.Width, image.Height / 2) |
|||
}; |
|||
|
|||
image.Resize(options) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResizeWithPadMode<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
var options = new ResizeOptions |
|||
{ |
|||
Sampler = sampler, |
|||
Size = new Size(image.Width + 200, image.Height), |
|||
Mode = ResizeMode.Pad |
|||
}; |
|||
|
|||
image.Resize(options) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResizeWithBoxPadMode<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
var options = new ResizeOptions |
|||
{ |
|||
Sampler = sampler, |
|||
Size = new Size(image.Width + 200, image.Height + 200), |
|||
Mode = ResizeMode.BoxPad |
|||
}; |
|||
|
|||
image.Resize(options) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResizeWithMaxMode<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
var options = new ResizeOptions |
|||
{ |
|||
Sampler = sampler, |
|||
Size = new Size(300, 300), |
|||
Mode = ResizeMode.Max |
|||
}; |
|||
|
|||
image.Resize(options) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResizeWithMinMode<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
var options = new ResizeOptions |
|||
{ |
|||
Sampler = sampler, |
|||
Size = new Size((int)MathF.Round(image.Width * .75F), (int)MathF.Round(image.Height * .95F)), |
|||
Mode = ResizeMode.Min |
|||
}; |
|||
|
|||
image.Resize(options) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ResizeFiles), nameof(ReSamplers), DefaultPixelType)] |
|||
public void ImageShouldResizeWithStretchMode<TPixel>(TestImageProvider<TPixel> provider, string name, IResampler sampler) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
var options = new ResizeOptions |
|||
{ |
|||
Sampler = sampler, |
|||
Size = new Size(image.Width / 2, image.Height), |
|||
Mode = ResizeMode.Stretch |
|||
}; |
|||
|
|||
image.Resize(options) |
|||
.DebugSave(provider, name, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(-2, 0)] |
|||
[InlineData(-1, 0)] |
|||
[InlineData(0, 1)] |
|||
[InlineData(1, 0)] |
|||
[InlineData(2, 0)] |
|||
public static void BicubicWindowOscillatesCorrectly(float x, float expected) |
|||
{ |
|||
var sampler = new BicubicResampler(); |
|||
float result = sampler.GetValue(x); |
|||
|
|||
Assert.Equal(result, expected); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(-2, 0)] |
|||
[InlineData(-1, 0)] |
|||
[InlineData(0, 1)] |
|||
[InlineData(1, 0)] |
|||
[InlineData(2, 0)] |
|||
public static void TriangleWindowOscillatesCorrectly(float x, float expected) |
|||
{ |
|||
var sampler = new TriangleResampler(); |
|||
float result = sampler.GetValue(x); |
|||
|
|||
Assert.Equal(result, expected); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(-2, 0)] |
|||
[InlineData(-1, 0)] |
|||
[InlineData(0, 1)] |
|||
[InlineData(1, 0)] |
|||
[InlineData(2, 0)] |
|||
public static void Lanczos3WindowOscillatesCorrectly(float x, float expected) |
|||
{ |
|||
var sampler = new Lanczos3Resampler(); |
|||
float result = sampler.GetValue(x); |
|||
|
|||
Assert.Equal(result, expected); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(-4, 0)] |
|||
[InlineData(-2, 0)] |
|||
[InlineData(0, 1)] |
|||
[InlineData(2, 0)] |
|||
[InlineData(4, 0)] |
|||
public static void Lanczos5WindowOscillatesCorrectly(float x, float expected) |
|||
{ |
|||
var sampler = new Lanczos5Resampler(); |
|||
float result = sampler.GetValue(x); |
|||
|
|||
Assert.Equal(result, expected); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
// <copyright file="RotateFlipTests.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Transforms |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
using ImageSharp.Processing; |
|||
|
|||
using Xunit; |
|||
|
|||
public class RotateFlipTests : FileTestBase |
|||
{ |
|||
public static readonly string[] FlipFiles = { TestImages.Bmp.F }; |
|||
|
|||
public static readonly TheoryData<RotateType, FlipType> RotateFlipValues |
|||
= new TheoryData<RotateType, FlipType> |
|||
{ |
|||
{ RotateType.None, FlipType.Vertical }, |
|||
{ RotateType.None, FlipType.Horizontal }, |
|||
{ RotateType.Rotate90, FlipType.None }, |
|||
{ RotateType.Rotate180, FlipType.None }, |
|||
{ RotateType.Rotate270, FlipType.None }, |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(FlipFiles), nameof(RotateFlipValues), DefaultPixelType)] |
|||
public void ImageShouldRotateFlip<TPixel>(TestImageProvider<TPixel> provider, RotateType rotateType, FlipType flipType) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.RotateFlip(rotateType, flipType) |
|||
.DebugSave(provider, string.Join("_", rotateType, flipType), Extensions.Bmp); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
// <copyright file="RotateTests.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Transforms |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
using ImageSharp.Processing; |
|||
|
|||
using Xunit; |
|||
|
|||
public class RotateTests : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<float> RotateFloatValues |
|||
= new TheoryData<float> |
|||
{ |
|||
170, |
|||
-170 |
|||
}; |
|||
|
|||
public static readonly TheoryData<RotateType> RotateEnumValues |
|||
= new TheoryData<RotateType> |
|||
{ |
|||
RotateType.None, |
|||
RotateType.Rotate90, |
|||
RotateType.Rotate180, |
|||
RotateType.Rotate270 |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(RotateFloatValues), DefaultPixelType)] |
|||
public void ImageShouldRotate<TPixel>(TestImageProvider<TPixel> provider, float value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Rotate(value) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(RotateEnumValues), DefaultPixelType)] |
|||
public void ImageShouldRotateEnum<TPixel>(TestImageProvider<TPixel> provider, RotateType value) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Rotate(value) |
|||
.DebugSave(provider, value, Extensions.Bmp); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
// <copyright file="SkewTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests.Processing.Transforms |
|||
{ |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class SkewTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<float, float> SkewValues |
|||
= new TheoryData<float, float> |
|||
{ |
|||
{ 20, 10 }, |
|||
{ -20, -10 } |
|||
}; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(DefaultFiles), nameof(SkewValues), DefaultPixelType)] |
|||
public void ImageShouldSkew<TPixel>(TestImageProvider<TPixel> provider, float x, float y) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (Image<TPixel> image = provider.GetImage()) |
|||
{ |
|||
image.Skew(x, y) |
|||
.DebugSave(provider, string.Join("_", x, y), Extensions.Bmp); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,57 +0,0 @@ |
|||
// <copyright file="AlphaTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class AlphaTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<float> AlphaValues |
|||
= new TheoryData<float> |
|||
{ |
|||
20/100f , |
|||
80/100f |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(AlphaValues))] |
|||
public void ImageShouldApplyAlphaFilter(float value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Alpha"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Alpha(value).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(AlphaValues))] |
|||
public void ImageShouldApplyAlphaFilterInBox(float value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Alpha"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value + "-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Alpha(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,47 +0,0 @@ |
|||
// <copyright file="BackgroundColorTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class BackgroundColorTest : FileTestBase |
|||
{ |
|||
[Fact] |
|||
public void ImageShouldApplyBackgroundColorFilter() |
|||
{ |
|||
string path = this.CreateOutputDirectory("BackgroundColor"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) |
|||
{ |
|||
image.BackgroundColor(Rgba32.HotPink).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void ImageShouldApplyBackgroundColorFilterInBox() |
|||
{ |
|||
string path = this.CreateOutputDirectory("BackgroundColor"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName("-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.BackgroundColor(Rgba32.HotPink, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,57 +0,0 @@ |
|||
// <copyright file="BinaryThresholdTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class BinaryThresholdTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<float> BinaryThresholdValues |
|||
= new TheoryData<float> |
|||
{ |
|||
.25f , |
|||
.75f , |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(BinaryThresholdValues))] |
|||
public void ImageShouldApplyBinaryThresholdFilter(float value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("BinaryThreshold"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.BinaryThreshold(value).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(BinaryThresholdValues))] |
|||
public void ImageShouldApplyBinaryThresholdInBox(float value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("BinaryThreshold"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value + "-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.BinaryThreshold(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,47 +0,0 @@ |
|||
// <copyright file="BlackWhiteTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class BlackWhiteTest : FileTestBase |
|||
{ |
|||
[Fact] |
|||
public void ImageShouldApplyBlackWhiteFilter() |
|||
{ |
|||
string path = this.CreateOutputDirectory("BlackWhite"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) |
|||
{ |
|||
image.BlackWhite().Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void ImageShouldApplyBlackWhiteFilterInBox() |
|||
{ |
|||
string path = this.CreateOutputDirectory("BlackWhite"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName("-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.BlackWhite(new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,57 +0,0 @@ |
|||
// <copyright file="BoxBlurTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class BoxBlurTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int> BoxBlurValues |
|||
= new TheoryData<int> |
|||
{ |
|||
3 , |
|||
5 , |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(BoxBlurValues))] |
|||
public void ImageShouldApplyBoxBlurFilter(int value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("BoxBlur"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.BoxBlur(value).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(BoxBlurValues))] |
|||
public void ImageShouldApplyBoxBlurFilterInBox(int value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("BoxBlur"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value + "-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.BoxBlur(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,57 +0,0 @@ |
|||
// <copyright file="BrightnessTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class BrightnessTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int> BrightnessValues |
|||
= new TheoryData<int> |
|||
{ |
|||
50 , |
|||
-50 , |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(BrightnessValues))] |
|||
public void ImageShouldApplyBrightnessFilter(int value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Brightness"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Brightness(value).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(BrightnessValues))] |
|||
public void ImageShouldApplyBrightnessFilterInBox(int value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Brightness"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value + "-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Brightness(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,64 +0,0 @@ |
|||
// <copyright file="ColorBlindnessTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using Processing; |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class ColorBlindnessTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<ColorBlindness> ColorBlindnessFilters |
|||
= new TheoryData<ColorBlindness> |
|||
{ |
|||
ColorBlindness.Achromatomaly, |
|||
ColorBlindness.Achromatopsia, |
|||
ColorBlindness.Deuteranomaly, |
|||
ColorBlindness.Deuteranopia, |
|||
ColorBlindness.Protanomaly, |
|||
ColorBlindness.Protanopia, |
|||
ColorBlindness.Tritanomaly, |
|||
ColorBlindness.Tritanopia |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(ColorBlindnessFilters))] |
|||
public void ImageShouldApplyColorBlindnessFilter(ColorBlindness colorBlindness) |
|||
{ |
|||
string path = this.CreateOutputDirectory("ColorBlindness"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(colorBlindness); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.ColorBlindness(colorBlindness).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(ColorBlindnessFilters))] |
|||
public void ImageShouldApplyBrightnessFilterInBox(ColorBlindness colorBlindness) |
|||
{ |
|||
string path = this.CreateOutputDirectory("ColorBlindness"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(colorBlindness + "-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.ColorBlindness(colorBlindness, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,56 +0,0 @@ |
|||
// <copyright file="ContrastTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class ContrastTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int> ContrastValues |
|||
= new TheoryData<int> |
|||
{ |
|||
50 , |
|||
-50 , |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(ContrastValues))] |
|||
public void ImageShouldApplyContrastFilter(int value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Contrast"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) |
|||
{ |
|||
image.Contrast(value).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(ContrastValues))] |
|||
public void ImageShouldApplyContrastFilterInBox(int value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Contrast"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value + "-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Contrast(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
// <copyright file="CropTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class CropTest : FileTestBase |
|||
{ |
|||
[Fact] |
|||
public void ImageShouldApplyCropSampler() |
|||
{ |
|||
string path = this.CreateOutputDirectory("Crop"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) |
|||
{ |
|||
image.Crop(image.Width / 2, image.Height / 2).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,67 +0,0 @@ |
|||
// <copyright file="DetectEdgesTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using Processing; |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class DetectEdgesTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<EdgeDetection> DetectEdgesFilters |
|||
= new TheoryData<EdgeDetection> |
|||
{ |
|||
EdgeDetection.Kayyali, |
|||
EdgeDetection.Kirsch, |
|||
EdgeDetection.Lapacian3X3, |
|||
EdgeDetection.Lapacian5X5, |
|||
EdgeDetection.LaplacianOfGaussian, |
|||
EdgeDetection.Prewitt, |
|||
EdgeDetection.RobertsCross, |
|||
EdgeDetection.Robinson, |
|||
EdgeDetection.Scharr, |
|||
EdgeDetection.Sobel |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(DetectEdgesFilters))] |
|||
public void ImageShouldApplyDetectEdgesFilter(EdgeDetection detector) |
|||
{ |
|||
string path = this.CreateOutputDirectory("DetectEdges"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(detector); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.DetectEdges(detector).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(DetectEdgesFilters))] |
|||
public void ImageShouldApplyDetectEdgesFilterInBox(EdgeDetection detector) |
|||
{ |
|||
string path = this.CreateOutputDirectory("DetectEdges"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(detector + "-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.DetectEdges(detector, new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2)) |
|||
.Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,104 +0,0 @@ |
|||
// <copyright file="DitherTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.Dithering; |
|||
using ImageSharp.Dithering.Ordered; |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class DitherTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<string, IOrderedDither> Ditherers = new TheoryData<string, IOrderedDither> |
|||
{ |
|||
{ "Ordered", new Ordered() }, |
|||
{ "Bayer", new Bayer() } |
|||
}; |
|||
|
|||
public static readonly TheoryData<string, IErrorDiffuser> ErrorDiffusers = new TheoryData<string, IErrorDiffuser> |
|||
{ |
|||
{ "Atkinson", new Atkinson() }, |
|||
{ "Burks", new Burks() }, |
|||
{ "FloydSteinberg", new FloydSteinberg() }, |
|||
{ "JarvisJudiceNinke", new JarvisJudiceNinke() }, |
|||
{ "Sierra2", new Sierra2() }, |
|||
{ "Sierra3", new Sierra3() }, |
|||
{ "SierraLite", new SierraLite() }, |
|||
{ "Stucki", new Stucki() }, |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(Ditherers))] |
|||
public void ImageShouldApplyDitherFilter(string name, IOrderedDither ditherer) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Dither", "Dither"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(name); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Dither(ditherer).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(Ditherers))] |
|||
public void ImageShouldApplyDitherFilterInBox(string name, IOrderedDither ditherer) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Dither", "Dither"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName($"{name}-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Dither(ditherer, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(ErrorDiffusers))] |
|||
public void ImageShouldApplyDiffusionFilter(string name, IErrorDiffuser diffuser) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Dither", "Diffusion"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(name); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Dither(diffuser, .5F).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(ErrorDiffusers))] |
|||
public void ImageShouldApplyDiffusionFilterInBox(string name, IErrorDiffuser diffuser) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Dither", "Diffusion"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName($"{name}-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Dither(diffuser, .5F, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,40 +0,0 @@ |
|||
// <copyright file="EntropyCropTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class EntropyCropTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<float> EntropyCropValues |
|||
= new TheoryData<float> |
|||
{ |
|||
.25f , |
|||
.75f , |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(EntropyCropValues))] |
|||
public void ImageShouldApplyEntropyCropSampler(float value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("EntropyCrop"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.EntropyCrop(value).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,42 +0,0 @@ |
|||
// <copyright file="RotateFlipTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Processing; |
|||
using Xunit; |
|||
|
|||
public class FlipTests : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<FlipType> FlipValues |
|||
= new TheoryData<FlipType> |
|||
{ |
|||
{ FlipType.None }, |
|||
{ FlipType.Vertical }, |
|||
{ FlipType.Horizontal }, |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(FlipValues))] |
|||
public void ImageShouldFlip(FlipType flipType) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Flip"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(flipType); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Flip(flipType).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,80 +0,0 @@ |
|||
// <copyright file="GlowTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class GlowTest : FileTestBase |
|||
{ |
|||
[Fact] |
|||
public void ImageShouldApplyGlowFilter() |
|||
{ |
|||
string path = this.CreateOutputDirectory("Glow"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) |
|||
{ |
|||
image.Glow().Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void ImageShouldApplyGlowFilterColor() |
|||
{ |
|||
string path = this.CreateOutputDirectory("Glow"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName("Color"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Glow(Rgba32.HotPink).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void ImageShouldApplyGlowFilterRadius() |
|||
{ |
|||
string path = this.CreateOutputDirectory("Glow"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName("Radius"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Glow(image.Width / 4F).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void ImageShouldApplyGlowFilterInBox() |
|||
{ |
|||
string path = this.CreateOutputDirectory("Glow"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName("InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Glow(new Rectangle(image.Width / 8, image.Height / 8, image.Width / 2, image.Height / 2)) |
|||
.Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,57 +0,0 @@ |
|||
// <copyright file="HueTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class HueTest : FileTestBase |
|||
{ |
|||
public static readonly TheoryData<int> HueValues |
|||
= new TheoryData<int> |
|||
{ |
|||
180 , |
|||
-180 , |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(HueValues))] |
|||
public void ImageShouldApplyHueFilter(int value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Hue"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Hue(value).Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(HueValues))] |
|||
public void ImageShouldApplyHueFilterInBox(int value) |
|||
{ |
|||
string path = this.CreateOutputDirectory("Hue"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName(value + "-InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Hue(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,46 +0,0 @@ |
|||
// <copyright file="InvertTest.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Tests |
|||
{ |
|||
using System.IO; |
|||
|
|||
using ImageSharp.PixelFormats; |
|||
|
|||
using Xunit; |
|||
|
|||
public class InvertTest : FileTestBase |
|||
{ |
|||
[Fact] |
|||
public void ImageShouldApplyInvertFilter() |
|||
{ |
|||
string path = this.CreateOutputDirectory("Invert"); |
|||
foreach (TestFile file in Files) |
|||
{ |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) |
|||
{ |
|||
image.Invert().Save(output); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void ImageShouldApplyInvertFilterInBox() |
|||
{ |
|||
string path = this.CreateOutputDirectory("Invert"); |
|||
|
|||
foreach (TestFile file in Files) |
|||
{ |
|||
string filename = file.GetFileName("InBox"); |
|||
using (Image<Rgba32> image = file.CreateImage()) |
|||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|||
{ |
|||
image.Invert(new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue