//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageSharp.Tests.Processing.Processors.Effects
{
using ImageSharp.PixelFormats;
using SixLabors.Primitives;
using Xunit;
public class ContrastTest : FileTestBase
{
public static readonly TheoryData ContrastValues
= new TheoryData
{
50,
-50
};
[Theory]
[WithFileCollection(nameof(DefaultFiles), nameof(ContrastValues), DefaultPixelType)]
public void ImageShouldApplyContrastFilter(TestImageProvider provider, int value)
where TPixel : struct, IPixel
{
using (Image image = provider.GetImage())
{
image.Mutate(x => x.Contrast(value));
image.DebugSave(provider, value);
}
}
[Theory]
[WithFileCollection(nameof(DefaultFiles), nameof(ContrastValues), DefaultPixelType)]
public void ImageShouldApplyContrastFilterInBox(TestImageProvider provider, int value)
where TPixel : struct, IPixel
{
using (Image source = provider.GetImage())
using (var image = source.Clone())
{
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Contrast(value, bounds));
image.DebugSave(provider, value);
ImageComparer.EnsureProcessorChangesAreConstrained(source, image, bounds);
}
}
}
}