diff --git a/src/ImageSharp/Formats/Webp/AlphaEncoder.cs b/src/ImageSharp/Formats/Webp/AlphaEncoder.cs index 208468696..cbd2aa8e7 100644 --- a/src/ImageSharp/Formats/Webp/AlphaEncoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaEncoder.cs @@ -43,8 +43,17 @@ internal static class AlphaEncoder { const WebpEncodingMethod effort = WebpEncodingMethod.Default; const int quality = 8 * (int)effort; - using Vp8LEncoder lossLessEncoder = new Vp8LEncoder(memoryAllocator, configuration, width, height, quality, - skipMetadata, effort, WebpTransparentColorMode.Preserve, false, 0); + using Vp8LEncoder lossLessEncoder = new( + memoryAllocator, + configuration, + width, + height, + quality, + skipMetadata, + effort, + WebpTransparentColorMode.Preserve, + false, + 0); // The transparency information will be stored in the green channel of the ARGB quadruplet. // The green channel is allowed extra transformation steps in the specification -- unlike the other channels, diff --git a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs index 4ac516f05..354bcdbb4 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs @@ -76,7 +76,11 @@ internal sealed class WebpLossyDecoder Vp8Proba proba = new Vp8Proba(); Vp8SegmentHeader vp8SegmentHeader = this.ParseSegmentHeader(proba); - using (Vp8Decoder decoder = new Vp8Decoder(info.Vp8FrameHeader, pictureHeader, vp8SegmentHeader, proba, + using (Vp8Decoder decoder = new Vp8Decoder( + info.Vp8FrameHeader, + pictureHeader, + vp8SegmentHeader, + proba, this.memoryAllocator)) { Vp8Io io = InitializeVp8Io(decoder, pictureHeader); @@ -102,8 +106,13 @@ internal sealed class WebpLossyDecoder if (info.Features?.Alpha == true) { - using (AlphaDecoder alphaDecoder = new AlphaDecoder(width, height, alphaData, - info.Features.AlphaChunkHeader, this.memoryAllocator, this.configuration)) + using (AlphaDecoder alphaDecoder = new AlphaDecoder( + width, + height, + alphaData, + info.Features.AlphaChunkHeader, + this.memoryAllocator, + this.configuration)) { alphaDecoder.Decode(); DecodePixelValues(width, height, decoder.Pixels.Memory.Span, pixels, alphaDecoder.Alpha); diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs index bb54d99a0..bc875c889 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs @@ -91,8 +91,11 @@ internal sealed class WebpDecoderCore : IImageDecoderInternals, IDisposable { if (this.webImageInfo.Features is { Animation: true }) { - using WebpAnimationDecoder animationDecoder = new WebpAnimationDecoder(this.memoryAllocator, - this.configuration, this.maxFrames, this.backgroundColorHandling); + using WebpAnimationDecoder animationDecoder = new WebpAnimationDecoder( + this.memoryAllocator, + this.configuration, + this.maxFrames, + this.backgroundColorHandling); return animationDecoder.Decode(stream, this.webImageInfo.Features, this.webImageInfo.Width, this.webImageInfo.Height, fileSize); } @@ -100,14 +103,18 @@ internal sealed class WebpDecoderCore : IImageDecoderInternals, IDisposable Buffer2D pixels = image.GetRootFramePixelBuffer(); if (this.webImageInfo.IsLossless) { - WebpLosslessDecoder losslessDecoder = new WebpLosslessDecoder(this.webImageInfo.Vp8LBitReader, - this.memoryAllocator, this.configuration); + WebpLosslessDecoder losslessDecoder = new WebpLosslessDecoder( + this.webImageInfo.Vp8LBitReader, + this.memoryAllocator, + this.configuration); losslessDecoder.Decode(pixels, image.Width, image.Height); } else { - WebpLossyDecoder lossyDecoder = new WebpLossyDecoder(this.webImageInfo.Vp8BitReader, - this.memoryAllocator, this.configuration); + WebpLossyDecoder lossyDecoder = new WebpLossyDecoder( + this.webImageInfo.Vp8BitReader, + this.memoryAllocator, + this.configuration); lossyDecoder.Decode(pixels, image.Width, image.Height, this.webImageInfo, this.alphaData); } diff --git a/src/ImageSharp/Formats/Webp/WebpEncoderCore.cs b/src/ImageSharp/Formats/Webp/WebpEncoderCore.cs index dcff53f3a..d945cc399 100644 --- a/src/ImageSharp/Formats/Webp/WebpEncoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpEncoderCore.cs @@ -129,9 +129,17 @@ internal sealed class WebpEncoderCore : IImageEncoderInternals if (lossless) { - using Vp8LEncoder encoder = new Vp8LEncoder(this.memoryAllocator, this.configuration, image.Width, - image.Height, this.quality, this.skipMetadata, this.method, this.transparentColorMode, - this.nearLossless, this.nearLosslessQuality); + using Vp8LEncoder encoder = new Vp8LEncoder( + this.memoryAllocator, + this.configuration, + image.Width, + image.Height, + this.quality, + this.skipMetadata, + this.method, + this.transparentColorMode, + this.nearLossless, + this.nearLosslessQuality); bool hasAnimation = image.Frames.Count > 1; encoder.EncodeHeader(image, stream, hasAnimation); @@ -139,9 +147,17 @@ internal sealed class WebpEncoderCore : IImageEncoderInternals { foreach (ImageFrame imageFrame in image.Frames) { - using Vp8LEncoder enc = new Vp8LEncoder(this.memoryAllocator, this.configuration, image.Width, - image.Height, this.quality, this.skipMetadata, this.method, this.transparentColorMode, - this.nearLossless, this.nearLosslessQuality); + using Vp8LEncoder enc = new Vp8LEncoder( + this.memoryAllocator, + this.configuration, + image.Width, + image.Height, + this.quality, + this.skipMetadata, + this.method, + this.transparentColorMode, + this.nearLossless, + this.nearLosslessQuality); enc.Encode(imageFrame, stream, true); } @@ -155,18 +171,36 @@ internal sealed class WebpEncoderCore : IImageEncoderInternals } else { - using Vp8Encoder encoder = new Vp8Encoder(this.memoryAllocator, this.configuration, image.Width, - image.Height, this.quality, this.skipMetadata, this.method, this.entropyPasses, this.filterStrength, - this.spatialNoiseShaping, this.alphaCompression); + using Vp8Encoder encoder = new Vp8Encoder( + this.memoryAllocator, + this.configuration, + image.Width, + image.Height, + this.quality, + this.skipMetadata, + this.method, + this.entropyPasses, + this.filterStrength, + this.spatialNoiseShaping, + this.alphaCompression); if (image.Frames.Count > 1) { encoder.EncodeHeader(image, stream, false, true); foreach (ImageFrame imageFrame in image.Frames) { - using Vp8Encoder enc = new Vp8Encoder(this.memoryAllocator, this.configuration, image.Width, - image.Height, this.quality, this.skipMetadata, this.method, this.entropyPasses, - this.filterStrength, this.spatialNoiseShaping, this.alphaCompression); + using Vp8Encoder enc = new Vp8Encoder( + this.memoryAllocator, + this.configuration, + image.Width, + image.Height, + this.quality, + this.skipMetadata, + this.method, + this.entropyPasses, + this.filterStrength, + this.spatialNoiseShaping, + this.alphaCompression); enc.EncodeAnimation(imageFrame, stream); }