Browse Source

Split up alpha encoding test in compressed and uncompressed test

pull/2258/head
Brian Popow 4 years ago
parent
commit
0ce8a21244
  1. 33
      tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs

33
tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs

@ -267,22 +267,45 @@ public class WebpEncoderTests
}
[Theory]
[WithFile(TestImages.Png.Transparency, PixelTypes.Rgba32, false, 64020)]
[WithFile(TestImages.Png.Transparency, PixelTypes.Rgba32, true, 16200)]
public void Encode_Lossy_WithAlpha_Works<TPixel>(TestImageProvider<TPixel> provider, bool compressed, int expectedFileSize)
[WithFile(TestImages.Png.Transparency, PixelTypes.Rgba32, 64020)]
public void Encode_Lossy_WithAlpha_Works<TPixel>(TestImageProvider<TPixel> provider, int expectedFileSize)
where TPixel : unmanaged, IPixel<TPixel>
{
var encoder = new WebpEncoder()
{
FileFormat = WebpFileFormatType.Lossy,
UseAlphaCompression = compressed
UseAlphaCompression = false
};
using Image<TPixel> image = provider.GetImage();
string encodedFile = image.VerifyEncoder(
provider,
"webp",
$"with_alpha_compressed_{compressed}",
"with_alpha",
encoder,
ImageComparer.Tolerant(0.04f),
referenceDecoder: new MagickReferenceDecoder());
int encodedBytes = File.ReadAllBytes(encodedFile).Length;
Assert.True(encodedBytes <= expectedFileSize, $"encoded bytes are {encodedBytes} and should be smaller then expected file size of {expectedFileSize}");
}
[Theory]
[WithFile(TestImages.Png.Transparency, PixelTypes.Rgba32, 16200)]
public void Encode_Lossy_WithAlphaUsingCompression_Works<TPixel>(TestImageProvider<TPixel> provider, int expectedFileSize)
where TPixel : unmanaged, IPixel<TPixel>
{
var encoder = new WebpEncoder()
{
FileFormat = WebpFileFormatType.Lossy,
UseAlphaCompression = true
};
using Image<TPixel> image = provider.GetImage();
string encodedFile = image.VerifyEncoder(
provider,
"webp",
"with_alpha_compressed",
encoder,
ImageComparer.Tolerant(0.04f),
referenceDecoder: new MagickReferenceDecoder());

Loading…
Cancel
Save