//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageSharp.Tests.Processing.Effects
{
using ImageSharp.PixelFormats;
using Xunit;
public class AlphaTest : FileTestBase
{
public static readonly TheoryData AlphaValues
= new TheoryData
{
20/100F,
80/100F
};
[Theory]
[WithFileCollection(nameof(DefaultFiles), nameof(AlphaValues), StandardPixelType)]
public void ImageShouldApplyAlphaFilter(TestImageProvider provider, float value)
where TPixel : struct, IPixel
{
using (Image image = provider.GetImage())
{
image.Alpha(value)
.DebugSave(provider, value, Extensions.Png);
}
}
[Theory]
[WithFileCollection(nameof(DefaultFiles), nameof(AlphaValues), StandardPixelType)]
public void ImageShouldApplyAlphaFilterInBox(TestImageProvider provider, float value)
where TPixel : struct, IPixel
{
using (Image source = provider.GetImage())
using (var image = new Image(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);
}
}
}
}