|
|
|
@ -5,12 +5,8 @@ |
|
|
|
|
|
|
|
namespace ImageSharp.Tests |
|
|
|
{ |
|
|
|
using System.IO; |
|
|
|
|
|
|
|
using Xunit; |
|
|
|
using ImageSharp.Processing; |
|
|
|
using ImageSharp.Tests; |
|
|
|
using System.Numerics; |
|
|
|
|
|
|
|
using ImageSharp.PixelFormats; |
|
|
|
|
|
|
|
@ -20,7 +16,7 @@ namespace ImageSharp.Tests |
|
|
|
/// Use test patterns over loaded images to save decode time.
|
|
|
|
/// </summary>
|
|
|
|
[Theory] |
|
|
|
[WithTestPatternImages(50, 50, PixelTypes.StandardImageClass, GrayscaleMode.Bt709)] |
|
|
|
[WithTestPatternImages(50, 50, PixelTypes.StandardImageClass, GrayscaleMode.Bt709)] |
|
|
|
[WithTestPatternImages(50, 50, PixelTypes.StandardImageClass, GrayscaleMode.Bt601)] |
|
|
|
public void ImageShouldApplyGrayscaleFilterAll<TPixel>(TestImageProvider<TPixel> provider, GrayscaleMode value) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
@ -36,7 +32,27 @@ namespace ImageSharp.Tests |
|
|
|
Assert.Equal(data[1], data[2]); |
|
|
|
} |
|
|
|
|
|
|
|
image.DebugSave(provider); |
|
|
|
image.DebugSave(provider, value.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithTestPatternImages(50, 50, PixelTypes.StandardImageClass, GrayscaleMode.Bt709)] |
|
|
|
[WithTestPatternImages(50, 50, PixelTypes.StandardImageClass, GrayscaleMode.Bt601)] |
|
|
|
public void ImageShouldApplyGrayscaleFilterInBox<TPixel>(TestImageProvider<TPixel> provider, GrayscaleMode value) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using (Image<TPixel> source = provider.GetImage()) |
|
|
|
using (Image<TPixel> image = new Image<TPixel>(source)) |
|
|
|
{ |
|
|
|
Rectangle rect = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); |
|
|
|
image.Grayscale(rect, value) |
|
|
|
.DebugSave(provider, value.ToString()); |
|
|
|
|
|
|
|
// Let's draw identical shapes over the greyed areas and ensure that it didn't change the outer area
|
|
|
|
image.Fill(NamedColors<TPixel>.HotPink, rect); |
|
|
|
source.Fill(NamedColors<TPixel>.HotPink, rect); |
|
|
|
ImageComparer.CheckSimilarity(image, source); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|