Browse Source

add unit test and format

pull/2569/head
Poker 3 years ago
parent
commit
2c260b27bf
No known key found for this signature in database GPG Key ID: C65A6AD457D5C8F8
  1. 6
      src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs
  2. 29
      tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs

6
src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs

@ -44,9 +44,6 @@ internal class Vp8LBitWriter : BitWriterBase
{
}
/// <inheritdoc/>
public override int NumBytes => this.cur + ((this.used + 7) >> 3);
/// <summary>
/// Initializes a new instance of the <see cref="Vp8LBitWriter"/> class.
/// Used internally for cloning.
@ -59,6 +56,9 @@ internal class Vp8LBitWriter : BitWriterBase
this.cur = cur;
}
/// <inheritdoc/>
public override int NumBytes => this.cur + ((this.used + 7) >> 3);
/// <summary>
/// This function writes bits into bytes in increasing addresses (little endian),
/// and within a byte least-significant-bit first. This function can write up to 32 bits in one go.

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

@ -2,6 +2,7 @@
// Licensed under the Six Labors Split License.
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Webp;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
@ -17,14 +18,28 @@ public class WebpEncoderTests
{
private static string TestImageLossyFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, Lossy.NoFilter06);
[Fact]
public void Encode_AnimatedLossy()
[Theory]
[WithFile(Lossless.Animated, PixelTypes.Rgba32)]
public void Encode_AnimatedLossless<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
Image<Rgba32> image = Image.Load<Rgba32>(@"C:\WorkSpace\ImageSharp\tests\Images\Input\Webp\leo_animated_lossless.webp");
image.SaveAsWebp(@"C:\Users\poker\Desktop\3.webp", new WebpEncoder()
{
FileFormat = WebpFileFormatType.Lossless
});
using Image<TPixel> image = provider.GetImage();
using MemoryStream memStream = new();
image.SaveAsWebp(memStream, new() { FileFormat = WebpFileFormatType.Lossless });
// TODO: DebugSave, VerifySimilarity
}
[Theory]
[WithFile(Lossy.Animated, PixelTypes.Rgba32)]
public void Encode_AnimatedLossy<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage();
using MemoryStream memStream = new();
image.SaveAsWebp(memStream, new());
// TODO: DebugSave, VerifySimilarity
}
[Theory]

Loading…
Cancel
Save