|
|
|
@ -7,6 +7,7 @@ using SixLabors.ImageSharp.Metadata; |
|
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
|
using SixLabors.ImageSharp.Tests.TestUtilities; |
|
|
|
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
|
|
|
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; |
|
|
|
using Xunit; |
|
|
|
using static SixLabors.ImageSharp.Tests.TestImages.Webp; |
|
|
|
|
|
|
|
@ -268,9 +269,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Png.Transparency, PixelTypes.Rgba32, false)] |
|
|
|
[WithFile(TestImages.Png.Transparency, PixelTypes.Rgba32, true)] |
|
|
|
public void Encode_Lossy_WithAlpha_Works<TPixel>(TestImageProvider<TPixel> provider, bool compressed) |
|
|
|
[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) |
|
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
|
{ |
|
|
|
var encoder = new WebpEncoder() |
|
|
|
@ -280,7 +281,16 @@ namespace SixLabors.ImageSharp.Tests.Formats.Webp |
|
|
|
}; |
|
|
|
|
|
|
|
using Image<TPixel> image = provider.GetImage(); |
|
|
|
image.VerifyEncoder(provider, "webp", $"with_alpha_compressed_{compressed}", encoder, ImageComparer.Tolerant(0.04f)); |
|
|
|
string encodedFile = image.VerifyEncoder( |
|
|
|
provider, |
|
|
|
"webp", |
|
|
|
$"with_alpha_compressed_{compressed}", |
|
|
|
encoder, |
|
|
|
ImageComparer.Tolerant(0.04f), |
|
|
|
referenceDecoder: new MagickReferenceDecoder()); |
|
|
|
|
|
|
|
int encodedBytes = File.ReadAllBytes(encodedFile).Length; |
|
|
|
Assert.True(encodedBytes <= expectedFileSize); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
|