diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs index 0e66576d2c..43c7d03f7e 100644 --- a/src/ImageSharp/Configuration.cs +++ b/src/ImageSharp/Configuration.cs @@ -6,7 +6,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; -using SixLabors.ImageSharp.Formats.Experimental.WebP; using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Png; @@ -78,7 +77,7 @@ namespace SixLabors.ImageSharp /// /// Gets or sets the size of the buffer to use when working with streams. - /// Intitialized with by default. + /// Initialized with by default. /// public int StreamProcessingBufferSize { @@ -95,9 +94,9 @@ namespace SixLabors.ImageSharp } /// - /// Gets a set of properties for the Congiguration. + /// Gets a set of properties for the Configuration. /// - /// This can be used for storing global settings and defaults to be accessable to processors. + /// This can be used for storing global settings and defaults to be accessible to processors. public IDictionary Properties { get; } = new ConcurrentDictionary(); /// @@ -190,8 +189,7 @@ namespace SixLabors.ImageSharp new JpegConfigurationModule(), new GifConfigurationModule(), new BmpConfigurationModule(), - new TgaConfigurationModule(), - new WebPConfigurationModule()); + new TgaConfigurationModule()); } } } diff --git a/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs b/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs index b1fc902a6e..d05077400e 100644 --- a/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs +++ b/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs @@ -181,9 +181,9 @@ namespace SixLabors.ImageSharp.Formats.Experimental.WebP.Lossy this.filterHeader = new Vp8FilterHeader(); int predSize = (((4 * this.mbw) + 1) * ((4 * this.mbh) + 1)) + this.predsWidth + 1; - this.proba = new Vp8EncProba(); - this.Preds = new byte[predSize * 2]; // TODO: figure out how much mem we need here. This is too much. this.predsWidth = (4 * this.mbw) + 1; + this.proba = new Vp8EncProba(); + this.Preds = new byte[predSize + this.predsWidth + this.mbw]; // Initialize with default values, which the reference c implementation uses, // to be able to compare to the original and spot differences. diff --git a/src/ImageSharp/Formats/WebP/WebPDecoder.cs b/src/ImageSharp/Formats/WebP/WebPDecoder.cs index 4e1d24db46..539ba0700c 100644 --- a/src/ImageSharp/Formats/WebP/WebPDecoder.cs +++ b/src/ImageSharp/Formats/WebP/WebPDecoder.cs @@ -12,6 +12,7 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Experimental.WebP { /// + /// EXPERIMENTAL: /// Image decoder for generating an image out of a webp stream. /// public sealed class WebPDecoder : IImageDecoder, IWebPDecoderOptions, IImageInfoDetector diff --git a/src/ImageSharp/Formats/WebP/WebPEncoder.cs b/src/ImageSharp/Formats/WebP/WebPEncoder.cs index 120716f8f2..cb9a4101dc 100644 --- a/src/ImageSharp/Formats/WebP/WebPEncoder.cs +++ b/src/ImageSharp/Formats/WebP/WebPEncoder.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Experimental.WebP { /// + /// EXPERIMENTAL: /// Image encoder for writing an image to a stream in the WebP format. /// public sealed class WebPEncoder : IImageEncoder, IWebPEncoderOptions diff --git a/src/ImageSharp/Formats/WebP/WebPFormat.cs b/src/ImageSharp/Formats/WebP/WebPFormat.cs index 782c26f5d5..241ec879a3 100644 --- a/src/ImageSharp/Formats/WebP/WebPFormat.cs +++ b/src/ImageSharp/Formats/WebP/WebPFormat.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; namespace SixLabors.ImageSharp.Formats.Experimental.WebP { /// + /// EXPERIMENTAL: /// Registers the image encoders, decoders and mime type detectors for the WebP format /// public sealed class WebPFormat : IImageFormat diff --git a/src/ImageSharp/Formats/WebP/WebpConfigurationModule.cs b/src/ImageSharp/Formats/WebP/WebpConfigurationModule.cs index 393771535e..ec25718074 100644 --- a/src/ImageSharp/Formats/WebP/WebpConfigurationModule.cs +++ b/src/ImageSharp/Formats/WebP/WebpConfigurationModule.cs @@ -4,6 +4,7 @@ namespace SixLabors.ImageSharp.Formats.Experimental.WebP { /// + /// EXPERIMENTAL: /// Registers the image encoders, decoders and mime type detectors for the webp format. /// public sealed class WebPConfigurationModule : IConfigurationModule diff --git a/tests/ImageSharp.Tests/ConfigurationTests.cs b/tests/ImageSharp.Tests/ConfigurationTests.cs index f6111da5a3..655e98c7f6 100644 --- a/tests/ImageSharp.Tests/ConfigurationTests.cs +++ b/tests/ImageSharp.Tests/ConfigurationTests.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests public Configuration DefaultConfiguration { get; } - private readonly int expectedDefaultConfigurationCount = 6; + private readonly int expectedDefaultConfigurationCount = 5; public ConfigurationTests() { diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index d5b17ad502..7577093d9a 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -127,11 +127,6 @@ namespace SixLabors.ImageSharp.Tests.Formats { image.SaveAsTga(output); } - - using (FileStream output = File.OpenWrite(Path.Combine(path, $"{file.FileNameWithoutExtension}.webp"))) - { - image.SaveAsWebp(output); - } } } } @@ -179,8 +174,6 @@ namespace SixLabors.ImageSharp.Tests.Formats [InlineData(100, 100, "tga")] [InlineData(100, 10, "tga")] [InlineData(10, 100, "tga")] - [InlineData(100, 10, "webp")] - [InlineData(10, 100, "webp")] public void CanIdentifyImageLoadedFromBytes(int width, int height, string extension) { using (var image = Image.LoadPixelData(new Rgba32[width * height], width, height)) diff --git a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs index 2757aaea7e..d6ba59e4b8 100644 --- a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs +++ b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs @@ -37,14 +37,12 @@ namespace SixLabors.ImageSharp.Tests.Formats Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); - Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); - Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType().Count()); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs index 43e21f6da4..cb17184ad4 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs @@ -20,6 +20,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP private static MagickReferenceDecoder ReferenceDecoder => new MagickReferenceDecoder(); + public WebPDecoderTests() + { + Configuration.Default.ImageFormatsManager.AddImageFormat(WebPFormat.Instance); + Configuration.Default.ImageFormatsManager.AddImageFormatDetector(new WebPImageFormatDetector()); + Configuration.Default.ImageFormatsManager.SetDecoder(WebPFormat.Instance, new WebPDecoder()); + } + [Theory] [InlineData(Lossless.GreenTransform1, 1000, 307, 32)] [InlineData(Lossless.BikeThreeTransforms, 250, 195, 32)]