Browse Source

Add test making sure compressed alpha data is smaller then image size

pull/2173/head
Brian Popow 4 years ago
parent
commit
80b336711d
  1. 20
      tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs

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

@ -283,6 +283,26 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp
image.VerifyEncoder(provider, "webp", $"with_alpha_compressed_{compressed}", encoder, ImageComparer.Tolerant(0.04f));
}
[Theory]
[WithFile(TestImages.Png.Transparency, PixelTypes.Rgba32)]
public void Encode_Lossy_WithCompressedAlpha_AlphaShouldBeSmaller<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
var encoder = new WebpEncoder()
{
FileFormat = WebpFileFormatType.Lossy,
UseAlphaCompression = true
};
using Image<TPixel> image = provider.GetImage();
using (var memoryStream = new MemoryStream())
{
image.SaveAsWebp(memoryStream, encoder);
int size = memoryStream.ToArray().Length;
Assert.True(size < 16300);
}
}
[Theory]
[WithFile(TestPatternOpaque, PixelTypes.Rgba32)]
[WithFile(TestPatternOpaqueSmall, PixelTypes.Rgba32)]

Loading…
Cancel
Save