From 96a22c40ad938783b8c41d054871c83955eeb6b5 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 15 Jan 2023 17:47:19 +1000 Subject: [PATCH] Remove IImageInfo, IImage and use inheritance. --- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 18 +++--- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 4 +- src/ImageSharp/Formats/ImageDecoder.cs | 2 +- src/ImageSharp/Formats/Pbm/PbmEncoderCore.cs | 2 +- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 2 +- src/ImageSharp/IImage.cs | 11 ---- src/ImageSharp/IImageInfo.cs | 34 ----------- src/ImageSharp/Image.cs | 32 +++-------- src/ImageSharp/ImageInfo.cs | 56 ++++++++++++++----- src/ImageSharp/ImageInfoExtensions.cs | 24 -------- src/ImageSharp/Image{TPixel}.cs | 2 +- .../DefaultImageProcessorContext{TPixel}.cs | 2 +- .../DrawImageProcessor{TPixelBg,TPixelFg}.cs | 2 +- .../EntropyCropProcessor{TPixel}.cs | 38 ++++--------- .../Resize/ResizeProcessor{TPixel}.cs | 2 +- .../Codecs/Png/DecodeFilteredPng.cs | 4 +- .../Codecs/Png/DecodePng.cs | 17 ++---- .../Codecs/Tiff/DecodeTiff.cs | 16 ++---- .../Processing/Diffuse.cs | 8 +-- .../Processing/Rotate.cs | 4 +- .../ImageSharp.Benchmarks/Processing/Skew.cs | 4 +- .../Advanced/AdvancedImageExtensionsTests.cs | 12 ++-- .../Formats/Jpg/JpegDecoderTests.Metadata.cs | 2 +- .../Image/ImageRotationTests.cs | 12 ++-- .../Image/ImageTests.Identify.cs | 10 ++-- .../Image/ImageTests.ImageLoadTestBase.cs | 12 +--- ..._FileSystemPath_UseDefaultConfiguration.cs | 2 +- ...s.Load_FromBytes_UseGlobalConfiguration.cs | 2 +- ...Load_FromStream_UseDefaultConfiguration.cs | 2 +- tests/ImageSharp.Tests/ImageInfoTests.cs | 24 ++++---- .../BaseImageOperationsExtensionTest.cs | 2 +- .../Processing/FakeImageOperationsProvider.cs | 2 +- .../Processors/Convolution/BokehBlurTest.cs | 33 +++++------ .../Transforms/AffineTransformTests.cs | 2 +- .../Processors/Transforms/ResizeTests.cs | 8 +-- .../LoadResizeSaveProfilingBenchmarks.cs | 2 +- .../ImageComparison/ImageComparer.cs | 8 +-- 37 files changed, 160 insertions(+), 259 deletions(-) delete mode 100644 src/ImageSharp/IImage.cs delete mode 100644 src/ImageSharp/IImageInfo.cs delete mode 100644 src/ImageSharp/ImageInfoExtensions.cs diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index 53cb066f0d..9f1e856393 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -215,15 +215,15 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals BmpInfoHeader infoHeader = new( headerSize: infoHeaderSize, - height: height, width: width, - bitsPerPixel: bpp, + height: height, planes: 1, + bitsPerPixel: bpp, imageSize: height * bytesPerLine, - clrUsed: 0, - clrImportant: 0, xPelsPerMeter: hResolution, - yPelsPerMeter: vResolution); + yPelsPerMeter: vResolution, + clrUsed: 0, + clrImportant: 0); if ((this.infoHeaderType is BmpInfoHeaderType.WinVersion4 or BmpInfoHeaderType.WinVersion5) && this.bitsPerPixel == BmpBitsPerPixel.Pixel32) { @@ -470,7 +470,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(this.configuration); frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image); - using IndexedImageFrame quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds()); + using IndexedImageFrame quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds); ReadOnlySpan quantizedColorPalette = quantized.Palette.Span; this.WriteColorPalette(stream, quantizedColorPalette, colorPalette); @@ -541,7 +541,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image); - using IndexedImageFrame quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds()); + using IndexedImageFrame quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds); using IMemoryOwner colorPaletteBuffer = this.memoryAllocator.Allocate(ColorPaletteSize4Bit, AllocationOptions.Clean); Span colorPalette = colorPaletteBuffer.GetSpan(); @@ -588,7 +588,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image); - using IndexedImageFrame quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds()); + using IndexedImageFrame quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds); using IMemoryOwner colorPaletteBuffer = this.memoryAllocator.Allocate(ColorPaletteSize2Bit, AllocationOptions.Clean); Span colorPalette = colorPaletteBuffer.GetSpan(); @@ -644,7 +644,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image); - using IndexedImageFrame quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds()); + using IndexedImageFrame quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds); using IMemoryOwner colorPaletteBuffer = this.memoryAllocator.Allocate(ColorPaletteSize1Bit, AllocationOptions.Clean); Span colorPalette = colorPaletteBuffer.GetSpan(); diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index c35ee9985f..9cc045d45e 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -99,12 +99,12 @@ internal sealed class GifEncoderCore : IImageEncoderInternals if (useGlobalTable) { frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image); - quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds()); + quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds); } else { frameQuantizer.BuildPalette(this.pixelSamplingStrategy, image.Frames.RootFrame); - quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds()); + quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds); } } diff --git a/src/ImageSharp/Formats/ImageDecoder.cs b/src/ImageSharp/Formats/ImageDecoder.cs index 715c2f5416..ebb45d7013 100644 --- a/src/ImageSharp/Formats/ImageDecoder.cs +++ b/src/ImageSharp/Formats/ImageDecoder.cs @@ -172,7 +172,7 @@ public abstract class ImageDecoder : IImageDecoder } Size targetSize = options.TargetSize.Value; - Size currentSize = image.Size(); + Size currentSize = image.Size; return currentSize.Width != targetSize.Width && currentSize.Height != targetSize.Height; } diff --git a/src/ImageSharp/Formats/Pbm/PbmEncoderCore.cs b/src/ImageSharp/Formats/Pbm/PbmEncoderCore.cs index 7c7860c58e..4a07173a14 100644 --- a/src/ImageSharp/Formats/Pbm/PbmEncoderCore.cs +++ b/src/ImageSharp/Formats/Pbm/PbmEncoderCore.cs @@ -68,7 +68,7 @@ internal sealed class PbmEncoderCore : IImageEncoderInternals this.SanitizeAndSetEncoderOptions(image); byte signature = this.DeduceSignature(); - this.WriteHeader(stream, signature, image.Size()); + this.WriteHeader(stream, signature, image.Size); this.WritePixels(stream, image.Frames.RootFrame); diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 8b3dcc1593..5a66fc7d4b 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -1300,7 +1300,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(image.GetConfiguration()); frameQuantizer.BuildPalette(encoder.PixelSamplingStrategy, image); - return frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds()); + return frameQuantizer.QuantizeFrame(image.Frames.RootFrame, image.Bounds); } /// diff --git a/src/ImageSharp/IImage.cs b/src/ImageSharp/IImage.cs deleted file mode 100644 index 9940a7954c..0000000000 --- a/src/ImageSharp/IImage.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -namespace SixLabors.ImageSharp; - -/// -/// Encapsulates the properties and methods that describe an image. -/// -public interface IImage : IImageInfo, IDisposable -{ -} diff --git a/src/ImageSharp/IImageInfo.cs b/src/ImageSharp/IImageInfo.cs deleted file mode 100644 index 411b8f1b03..0000000000 --- a/src/ImageSharp/IImageInfo.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -using SixLabors.ImageSharp.Formats; -using SixLabors.ImageSharp.Metadata; - -namespace SixLabors.ImageSharp; - -/// -/// Encapsulates properties that describe basic image information including dimensions, pixel type information -/// and additional metadata. -/// -public interface IImageInfo -{ - /// - /// Gets information about the image pixels. - /// - PixelTypeInfo PixelType { get; } - - /// - /// Gets the width. - /// - int Width { get; } - - /// - /// Gets the height. - /// - int Height { get; } - - /// - /// Gets the metadata of the image. - /// - ImageMetadata Metadata { get; } -} diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index 2df86b1097..65b2d68b0a 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -14,11 +14,9 @@ namespace SixLabors.ImageSharp; /// For the non-generic type, the pixel type is only known at runtime. /// is always implemented by a pixel-specific instance. /// -public abstract partial class Image : IImage, IConfigurationProvider +public abstract partial class Image : ImageInfo, IDisposable, IConfigurationProvider { private bool isDisposed; - - private Size size; private readonly Configuration configuration; /// @@ -27,16 +25,12 @@ public abstract partial class Image : IImage, IConfigurationProvider /// /// The configuration which allows altering default behaviour or extending the library. /// - /// The . - /// The . - /// The . + /// The pixel type information. + /// The image metadata. + /// The size in px units. protected Image(Configuration configuration, PixelTypeInfo pixelType, ImageMetadata metadata, Size size) - { - this.configuration = configuration ?? Configuration.Default; - this.PixelType = pixelType; - this.size = size; - this.Metadata = metadata ?? new ImageMetadata(); - } + : base(pixelType, size, metadata) + => this.configuration = configuration ?? Configuration.Default; /// /// Initializes a new instance of the class. @@ -61,18 +55,6 @@ public abstract partial class Image : IImage, IConfigurationProvider /// protected abstract ImageFrameCollection NonGenericFrameCollection { get; } - /// - public PixelTypeInfo PixelType { get; } - - /// - public int Width => this.size.Width; - - /// - public int Height => this.size.Height; - - /// - public ImageMetadata Metadata { get; } - /// /// Gets the frames of the image as (non-generic) . /// @@ -148,7 +130,7 @@ public abstract partial class Image : IImage, IConfigurationProvider /// Update the size of the image after mutation. /// /// The . - protected void UpdateSize(Size size) => this.size = size; + protected void UpdateSize(Size size) => this.Size = size; /// /// Disposes the object and frees resources for the Garbage Collector. diff --git a/src/ImageSharp/ImageInfo.cs b/src/ImageSharp/ImageInfo.cs index 5b10440bef..9a6452ab89 100644 --- a/src/ImageSharp/ImageInfo.cs +++ b/src/ImageSharp/ImageInfo.cs @@ -9,32 +9,60 @@ namespace SixLabors.ImageSharp; /// /// Contains information about the image including dimensions, pixel type information and additional metadata /// -public sealed class ImageInfo : IImageInfo +public class ImageInfo { /// /// Initializes a new instance of the class. /// - /// The image pixel type information. - /// The width of the image in pixels. - /// The height of the image in pixels. - /// The images metadata. + /// The pixel type information. + /// The width of the image in px units. + /// The height of the image in px units. + /// The image metadata. public ImageInfo(PixelTypeInfo pixelType, int width, int height, ImageMetadata metadata) + : this(pixelType, new(width, height), metadata) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The pixel type information. + /// The size of the image in px units. + /// The image metadata. + public ImageInfo(PixelTypeInfo pixelType, Size size, ImageMetadata metadata) { this.PixelType = pixelType; - this.Width = width; - this.Height = height; - this.Metadata = metadata; + this.Metadata = metadata ?? new ImageMetadata(); + this.Size = size; } - /// + /// + /// Gets information about the image pixels. + /// public PixelTypeInfo PixelType { get; } - /// - public int Width { get; } + /// + /// Gets the image width in px units. + /// + public int Width => this.Size.Width; - /// - public int Height { get; } + /// + /// Gets the image height in px units. + /// + public int Height => this.Size.Height; - /// + /// + /// Gets any metadata associated wit The image. + /// public ImageMetadata Metadata { get; } + + /// + /// Gets the size of the image in px units. + /// + public Size Size { get; internal set; } + + /// + /// Gets the bounds of the image. + /// + public Rectangle Bounds => new(0, 0, this.Width, this.Height); } diff --git a/src/ImageSharp/ImageInfoExtensions.cs b/src/ImageSharp/ImageInfoExtensions.cs deleted file mode 100644 index 0f47c8896a..0000000000 --- a/src/ImageSharp/ImageInfoExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -namespace SixLabors.ImageSharp; - -/// -/// Extension methods that allow the addition of geometry calculating methods to the type -/// -public static class ImageInfoExtensions -{ - /// - /// Gets the bounds of the image. - /// - /// The image info - /// The - public static Size Size(this IImageInfo info) => new(info.Width, info.Height); - - /// - /// Gets the bounds of the image. - /// - /// The image info - /// The - public static Rectangle Bounds(this IImageInfo info) => new(0, 0, info.Width, info.Height); -} diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 31fd015096..9e3cc065c0 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -411,7 +411,7 @@ public sealed class Image : Image this.frames[i].SwapOrCopyPixelsBufferFrom(sourceFrames[i]); } - this.UpdateSize(pixelSource.Size()); + this.UpdateSize(pixelSource.Size); } private static Size ValidateFramesAndGetSize(IEnumerable> frames) diff --git a/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs b/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs index 9893bceab2..208455b902 100644 --- a/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs +++ b/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs @@ -95,5 +95,5 @@ internal class DefaultImageProcessorContext : IInternalImageProcessingCo return this; } - private Rectangle GetCurrentBounds() => this.destination?.Bounds() ?? this.source.Bounds(); + private Rectangle GetCurrentBounds() => this.destination?.Bounds ?? this.source.Bounds; } diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs index ac0d367515..82e639f1bd 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs @@ -78,7 +78,7 @@ internal class DrawImageProcessor : ImageProcessor int locationY = this.Location.Y; // Align start/end positions. - Rectangle bounds = targetImage.Bounds(); + Rectangle bounds = targetImage.Bounds; int minX = Math.Max(this.Location.X, sourceRectangle.X); int maxX = Math.Min(this.Location.X + bounds.Width, sourceRectangle.Right); diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs index 1ba62aa9eb..9afc852b58 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs @@ -27,9 +27,7 @@ internal class EntropyCropProcessor : ImageProcessor /// The source area to process for the current processor instance. public EntropyCropProcessor(Configuration configuration, EntropyCropProcessor definition, Image source, Rectangle sourceRectangle) : base(configuration, source, sourceRectangle) - { - this.definition = definition; - } + => this.definition = definition; /// protected override void BeforeImageApply() @@ -38,7 +36,7 @@ internal class EntropyCropProcessor : ImageProcessor // TODO: This is clunky. We should add behavior enum to ExtractFrame. // All frames have be the same size so we only need to calculate the correct dimensions for the first frame - using (var temp = new Image(this.Configuration, this.Source.Metadata.DeepClone(), new[] { this.Source.Frames.RootFrame.Clone() })) + using (Image temp = new(this.Configuration, this.Source.Metadata.DeepClone(), new[] { this.Source.Frames.RootFrame.Clone() })) { Configuration configuration = this.Source.GetConfiguration(); @@ -52,7 +50,7 @@ internal class EntropyCropProcessor : ImageProcessor rectangle = GetFilteredBoundingRectangle(temp.Frames.RootFrame, 0); } - new CropProcessor(rectangle, this.Source.Size()).Execute(this.Configuration, this.Source, this.SourceRectangle); + new CropProcessor(rectangle, this.Source.Size).Execute(this.Configuration, this.Source, this.SourceRectangle); base.BeforeImageApply(); } @@ -77,7 +75,7 @@ internal class EntropyCropProcessor : ImageProcessor /// [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Rectangle GetBoundingRectangle(Point topLeft, Point bottomRight) - => new Rectangle( + => new( topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, @@ -99,29 +97,13 @@ internal class EntropyCropProcessor : ImageProcessor int height = bitmap.Height; Point topLeft = default; Point bottomRight = default; - - Func, int, int, float, bool> delegateFunc; - - // Determine which channel to check against - switch (channel) + Func, int, int, float, bool> delegateFunc = channel switch { - case RgbaComponent.R: - delegateFunc = (pixels, x, y, b) => MathF.Abs(pixels[x, y].ToVector4().X - b) > Constants.Epsilon; - break; - - case RgbaComponent.G: - delegateFunc = (pixels, x, y, b) => MathF.Abs(pixels[x, y].ToVector4().Y - b) > Constants.Epsilon; - break; - - case RgbaComponent.B: - delegateFunc = (pixels, x, y, b) => MathF.Abs(pixels[x, y].ToVector4().Z - b) > Constants.Epsilon; - break; - - default: - delegateFunc = (pixels, x, y, b) => MathF.Abs(pixels[x, y].ToVector4().W - b) > Constants.Epsilon; - break; - } - + RgbaComponent.R => (pixels, x, y, b) => MathF.Abs(pixels[x, y].ToVector4().X - b) > Constants.Epsilon, + RgbaComponent.G => (pixels, x, y, b) => MathF.Abs(pixels[x, y].ToVector4().Y - b) > Constants.Epsilon, + RgbaComponent.B => (pixels, x, y, b) => MathF.Abs(pixels[x, y].ToVector4().Z - b) > Constants.Epsilon, + _ => (pixels, x, y, b) => MathF.Abs(pixels[x, y].ToVector4().W - b) > Constants.Epsilon, + }; int GetMinY(ImageFrame pixels) { for (int y = 0; y < height; y++) diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs index 4fbd7cfd27..ba96e76ae0 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs @@ -82,7 +82,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling return; } - var interest = Rectangle.Intersect(destinationRectangle, destination.Bounds()); + var interest = Rectangle.Intersect(destinationRectangle, destination.Bounds); if (sampler is NearestNeighborResampler) { diff --git a/tests/ImageSharp.Benchmarks/Codecs/Png/DecodeFilteredPng.cs b/tests/ImageSharp.Benchmarks/Codecs/Png/DecodeFilteredPng.cs index 74f5006668..986c1431c9 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Png/DecodeFilteredPng.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Png/DecodeFilteredPng.cs @@ -56,8 +56,8 @@ public class DecodeFilteredPng [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Size LoadPng(byte[] bytes) { - using var image = Image.Load(bytes); - return image.Size(); + using Image image = Image.Load(bytes); + return image.Size; } private static string TestImageFullPath(string path) diff --git a/tests/ImageSharp.Benchmarks/Codecs/Png/DecodePng.cs b/tests/ImageSharp.Benchmarks/Codecs/Png/DecodePng.cs index a73d62859c..c23fa25cca 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Png/DecodePng.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Png/DecodePng.cs @@ -22,26 +22,21 @@ public class DecodePng [GlobalSetup] public void ReadImages() - { - if (this.pngBytes == null) - { - this.pngBytes = File.ReadAllBytes(this.TestImageFullPath); - } - } + => this.pngBytes ??= File.ReadAllBytes(this.TestImageFullPath); [Benchmark(Baseline = true, Description = "System.Drawing Png")] public SDSize PngSystemDrawing() { - using var memoryStream = new MemoryStream(this.pngBytes); - using var image = SDImage.FromStream(memoryStream); + using MemoryStream memoryStream = new(this.pngBytes); + using SDImage image = SDImage.FromStream(memoryStream); return image.Size; } [Benchmark(Description = "ImageSharp Png")] public Size PngImageSharp() { - using var memoryStream = new MemoryStream(this.pngBytes); - using var image = Image.Load(memoryStream); - return image.Size(); + using MemoryStream memoryStream = new(this.pngBytes); + using Image image = Image.Load(memoryStream); + return image.Size; } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Tiff/DecodeTiff.cs b/tests/ImageSharp.Benchmarks/Codecs/Tiff/DecodeTiff.cs index 4edb251fa7..83f5fdd213 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Tiff/DecodeTiff.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Tiff/DecodeTiff.cs @@ -69,20 +69,16 @@ public class DecodeTiff [Benchmark(Baseline = true, Description = "System.Drawing Tiff")] public SDSize TiffSystemDrawing() { - using (var memoryStream = new MemoryStream(this.data)) - using (var image = SDImage.FromStream(memoryStream)) - { - return image.Size; - } + using MemoryStream memoryStream = new(this.data); + using SDImage image = SDImage.FromStream(memoryStream); + return image.Size; } [Benchmark(Description = "ImageSharp Tiff")] public Size TiffCore() { - using (var ms = new MemoryStream(this.data)) - using (var image = Image.Load(ms)) - { - return image.Size(); - } + using MemoryStream ms = new(this.data); + using Image image = Image.Load(ms); + return image.Size; } } diff --git a/tests/ImageSharp.Benchmarks/Processing/Diffuse.cs b/tests/ImageSharp.Benchmarks/Processing/Diffuse.cs index 7d6a52af25..c74c4a858a 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Diffuse.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Diffuse.cs @@ -13,19 +13,19 @@ public class Diffuse [Benchmark] public Size DoDiffuse() { - using var image = new Image(Configuration.Default, 800, 800, Color.BlanchedAlmond); + using Image image = new(Configuration.Default, 800, 800, Color.BlanchedAlmond); image.Mutate(x => x.Dither(KnownDitherings.FloydSteinberg)); - return image.Size(); + return image.Size; } [Benchmark] public Size DoDither() { - using var image = new Image(Configuration.Default, 800, 800, Color.BlanchedAlmond); + using Image image = new(Configuration.Default, 800, 800, Color.BlanchedAlmond); image.Mutate(x => x.Dither()); - return image.Size(); + return image.Size; } } diff --git a/tests/ImageSharp.Benchmarks/Processing/Rotate.cs b/tests/ImageSharp.Benchmarks/Processing/Rotate.cs index c392d99644..b9b0f6b3df 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Rotate.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Rotate.cs @@ -13,10 +13,10 @@ public class Rotate [Benchmark] public Size DoRotate() { - using var image = new Image(Configuration.Default, 400, 400, Color.BlanchedAlmond); + using Image image = new(Configuration.Default, 400, 400, Color.BlanchedAlmond); image.Mutate(x => x.Rotate(37.5F)); - return image.Size(); + return image.Size; } } diff --git a/tests/ImageSharp.Benchmarks/Processing/Skew.cs b/tests/ImageSharp.Benchmarks/Processing/Skew.cs index bc64382c19..26f2e7d2d6 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Skew.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Skew.cs @@ -13,10 +13,10 @@ public class Skew [Benchmark] public Size DoSkew() { - using var image = new Image(Configuration.Default, 400, 400, Color.BlanchedAlmond); + using Image image = new(Configuration.Default, 400, 400, Color.BlanchedAlmond); image.Mutate(x => x.Skew(20, 10)); - return image.Size(); + return image.Size; } } diff --git a/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs b/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs index 03e062cc0d..57a90c77b8 100644 --- a/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs @@ -30,7 +30,7 @@ public class AdvancedImageExtensionsTests IMemoryGroup memoryGroup = image.GetPixelMemoryGroup(); // Assert: - VerifyMemoryGroupDataMatchesTestPattern(provider, memoryGroup, image.Size()); + VerifyMemoryGroupDataMatchesTestPattern(provider, memoryGroup, image.Size); } [Theory] @@ -57,23 +57,23 @@ public class AdvancedImageExtensionsTests where TPixel : unmanaged, IPixel { using Image image0 = provider.GetImage(); - var targetBuffer = new TPixel[image0.Width * image0.Height]; + TPixel[] targetBuffer = new TPixel[image0.Width * image0.Height]; Assert.True(image0.DangerousTryGetSinglePixelMemory(out Memory sourceBuffer)); sourceBuffer.CopyTo(targetBuffer); - var managerOfExternalMemory = new TestMemoryManager(targetBuffer); + TestMemoryManager managerOfExternalMemory = new(targetBuffer); Memory externalMemory = managerOfExternalMemory.Memory; - using (var image1 = Image.WrapMemory(externalMemory, image0.Width, image0.Height)) + using (Image image1 = Image.WrapMemory(externalMemory, image0.Width, image0.Height)) { - VerifyMemoryGroupDataMatchesTestPattern(provider, image1.GetPixelMemoryGroup(), image1.Size()); + VerifyMemoryGroupDataMatchesTestPattern(provider, image1.GetPixelMemoryGroup(), image1.Size); } // Make sure externalMemory works after destruction: - VerifyMemoryGroupDataMatchesTestPattern(provider, image0.GetPixelMemoryGroup(), image0.Size()); + VerifyMemoryGroupDataMatchesTestPattern(provider, image0.GetPixelMemoryGroup(), image0.Size); } private static void VerifyMemoryGroupDataMatchesTestPattern( diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs index 5fecb2f9fd..7e0b1de82b 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs @@ -174,7 +174,7 @@ public partial class JpegDecoderTests Assert.Equal(expectedColorType, meta.ColorType); } - private static void TestImageInfo(string imagePath, IImageDecoder decoder, bool useIdentify, Action test) + private static void TestImageInfo(string imagePath, IImageDecoder decoder, bool useIdentify, Action test) { TestFile testFile = TestFile.Create(imagePath); using MemoryStream stream = new(testFile.Bytes, false); diff --git a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs index 978e0921ce..e7d3b548bc 100644 --- a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs @@ -45,12 +45,10 @@ public class ImageRotationTests private static (Size Original, Size Rotated) Rotate(int angle) { - var file = TestFile.Create(TestImages.Bmp.Car); - using (var image = Image.Load(file.FullPath)) - { - Size original = image.Size(); - image.Mutate(x => x.Rotate(angle)); - return (original, image.Size()); - } + TestFile file = TestFile.Create(TestImages.Bmp.Car); + using Image image = Image.Load(file.FullPath); + Size original = image.Size; + image.Mutate(x => x.Rotate(angle)); + return (original, image.Size); } } diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs index 0cda1c1fb0..7f6651d909 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs @@ -34,7 +34,7 @@ public partial class ImageTests public void FromBytes_GlobalConfiguration() { ImageInfo info = Image.Identify(ActualImageBytes); - Assert.Equal(ExpectedImageSize, info.Size()); + Assert.Equal(ExpectedImageSize, info.Size); Assert.Equal(ExpectedGlobalFormat, info.Metadata.DecodedImageFormat); } @@ -176,7 +176,7 @@ public partial class ImageTests AsyncStreamWrapper asyncStream = new(stream, () => false); ImageInfo info = await Image.IdentifyAsync(asyncStream); - Assert.Equal(ExpectedImageSize, info.Size()); + Assert.Equal(ExpectedImageSize, info.Size); Assert.Equal(ExpectedGlobalFormat, info.Metadata.DecodedImageFormat); } @@ -201,7 +201,7 @@ public partial class ImageTests AsyncStreamWrapper asyncStream = new(nonSeekableStream, () => false); ImageInfo info = await Image.IdentifyAsync(asyncStream); - Assert.Equal(ExpectedImageSize, info.Size()); + Assert.Equal(ExpectedImageSize, info.Size); Assert.Equal(ExpectedGlobalFormat, info.Metadata.DecodedImageFormat); } @@ -253,7 +253,7 @@ public partial class ImageTests { ImageInfo info = await Image.IdentifyAsync(ActualImagePath); - Assert.Equal(ExpectedImageSize, info.Size()); + Assert.Equal(ExpectedImageSize, info.Size); Assert.Equal(ExpectedGlobalFormat, info.Metadata.DecodedImageFormat); } @@ -262,7 +262,7 @@ public partial class ImageTests { ImageInfo info = await Image.IdentifyAsync(ActualImagePath); - Assert.Equal(ExpectedImageSize, info.Size()); + Assert.Equal(ExpectedImageSize, info.Size); } [Fact] diff --git a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs index 4d3e4128fa..a8f9981b44 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs @@ -5,6 +5,7 @@ using Moq; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.IO; +using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Tests; @@ -25,8 +26,6 @@ public partial class ImageTests protected Mock localImageFormatMock; - protected Mock localImageInfoMock; - protected readonly string MockFilePath = Guid.NewGuid().ToString(); internal readonly Mock LocalFileSystemMock = new(); @@ -58,14 +57,7 @@ public partial class ImageTests // TODO: Remove all this mocking. It's too complicated and we can now use fakes. this.localStreamReturnImageRgba32 = new Image(1, 1); this.localStreamReturnImageAgnostic = new Image(1, 1); - - this.localImageInfoMock = new Mock(); - - this.LocalImageInfo = new( - this.localImageInfoMock.Object.PixelType, - this.localImageInfoMock.Object.Width, - this.localImageInfoMock.Object.Height, - this.localImageInfoMock.Object.Metadata); + this.LocalImageInfo = new(new PixelTypeInfo(8), new(1, 1), new ImageMetadata()); this.localImageFormatMock = new Mock(); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs index b355c42a6c..3e488be9a3 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs @@ -12,7 +12,7 @@ public partial class ImageTests { private string Path { get; } = TestFile.GetInputFileFullPath(TestImages.Bmp.Bit8); - private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size()); + private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size); [Fact] public void Path_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs index a3d8605964..00ec985ac2 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs @@ -14,7 +14,7 @@ public partial class ImageTests private static Span ByteSpan => new(ByteArray); - private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size()); + private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size); [Fact] public void Bytes_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs index 682ec2a41c..7a5bd186b7 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs @@ -26,7 +26,7 @@ public partial class ImageTests } private static void VerifyDecodedImage(Image img) - => Assert.Equal(new Size(127, 64), img.Size()); + => Assert.Equal(new Size(127, 64), img.Size); [Fact] public void Stream_Specific() diff --git a/tests/ImageSharp.Tests/ImageInfoTests.cs b/tests/ImageSharp.Tests/ImageInfoTests.cs index 48b982e1ad..39091281d3 100644 --- a/tests/ImageSharp.Tests/ImageInfoTests.cs +++ b/tests/ImageSharp.Tests/ImageInfoTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.Formats; @@ -11,20 +11,20 @@ public class ImageInfoTests [Fact] public void ImageInfoInitializesCorrectly() { - const int Width = 50; - const int Height = 60; - var size = new Size(Width, Height); - var rectangle = new Rectangle(0, 0, Width, Height); - var pixelType = new PixelTypeInfo(8); - var meta = new ImageMetadata(); + const int width = 50; + const int height = 60; + Size size = new(width, height); + Rectangle rectangle = new(0, 0, width, height); + PixelTypeInfo pixelType = new(8); + ImageMetadata meta = new(); - var info = new ImageInfo(pixelType, Width, Height, meta); + ImageInfo info = new(pixelType, width, height, meta); Assert.Equal(pixelType, info.PixelType); - Assert.Equal(Width, info.Width); - Assert.Equal(Height, info.Height); - Assert.Equal(size, info.Size()); - Assert.Equal(rectangle, info.Bounds()); + Assert.Equal(width, info.Width); + Assert.Equal(height, info.Height); + Assert.Equal(size, info.Size); + Assert.Equal(rectangle, info.Bounds); Assert.Equal(meta, info.Metadata); } } diff --git a/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs b/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs index 9070b81583..98b5c8e980 100644 --- a/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs +++ b/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs @@ -15,7 +15,7 @@ public abstract class BaseImageOperationsExtensionTest : IDisposable protected readonly GraphicsOptions options; private readonly Image source; - public Rectangle SourceBounds() => this.source.Bounds(); + public Rectangle SourceBounds() => this.source.Bounds; public BaseImageOperationsExtensionTest() { diff --git a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs index 071c2fa68f..17f63384e0 100644 --- a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs @@ -64,7 +64,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public Size GetCurrentSize() { - return this.Source.Size(); + return this.Source.Size; } public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs index 175e31633e..0e53856dac 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs @@ -48,7 +48,7 @@ public class BokehBlurTest public void VerifyComplexComponents() { // Get the saved components - var components = new List(); + List components = new(); foreach (Match match in Regex.Matches(Components10x2, @"\[\[(.*?)\]\]", RegexOptions.Singleline)) { string[] values = match.Groups[1].Value.Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); @@ -64,23 +64,20 @@ public class BokehBlurTest } // Make sure the kernel components are the same - using (var image = new Image(1, 1)) + using Image image = new(1, 1); + Configuration configuration = image.GetConfiguration(); + BokehBlurProcessor definition = new(10, BokehBlurProcessor.DefaultComponents, BokehBlurProcessor.DefaultGamma); + + using BokehBlurProcessor processor = (BokehBlurProcessor)definition.CreatePixelSpecificProcessor(configuration, image, image.Bounds); + Assert.Equal(components.Count, processor.Kernels.Count); + foreach ((Complex64[] a, Complex64[] b) in components.Zip(processor.Kernels, (a, b) => (a, b))) { - Configuration configuration = image.GetConfiguration(); - var definition = new BokehBlurProcessor(10, BokehBlurProcessor.DefaultComponents, BokehBlurProcessor.DefaultGamma); - using (var processor = (BokehBlurProcessor)definition.CreatePixelSpecificProcessor(configuration, image, image.Bounds())) + Span spanA = a.AsSpan(), spanB = b.AsSpan(); + Assert.Equal(spanA.Length, spanB.Length); + for (int i = 0; i < spanA.Length; i++) { - Assert.Equal(components.Count, processor.Kernels.Count); - foreach ((Complex64[] a, Complex64[] b) in components.Zip(processor.Kernels, (a, b) => (a, b))) - { - Span spanA = a.AsSpan(), spanB = b.AsSpan(); - Assert.Equal(spanA.Length, spanB.Length); - for (int i = 0; i < spanA.Length; i++) - { - Assert.True(Math.Abs(Math.Abs(spanA[i].Real) - Math.Abs(spanB[i].Real)) < 0.0001f); - Assert.True(Math.Abs(Math.Abs(spanA[i].Imaginary) - Math.Abs(spanB[i].Imaginary)) < 0.0001f); - } - } + Assert.True(Math.Abs(Math.Abs(spanA[i].Real) - Math.Abs(spanB[i].Real)) < 0.0001f); + Assert.True(Math.Abs(Math.Abs(spanA[i].Imaginary) - Math.Abs(spanB[i].Imaginary)) < 0.0001f); } } } @@ -110,7 +107,7 @@ public class BokehBlurTest public override string ToString() => $"R{this.Radius}_C{this.Components}_G{this.Gamma}"; } - public static readonly TheoryData BokehBlurValues = new TheoryData + public static readonly TheoryData BokehBlurValues = new() { new BokehBlurInfo { Radius = 8, Components = 1, Gamma = 1 }, new BokehBlurInfo { Radius = 16, Components = 1, Gamma = 3 }, @@ -167,7 +164,7 @@ public class BokehBlurTest x => { Size size = x.GetCurrentSize(); - var bounds = new Rectangle(10, 10, size.Width / 2, size.Height / 2); + Rectangle bounds = new(10, 10, size.Width / 2, size.Height / 2); x.BokehBlur(value.Radius, value.Components, value.Gamma, bounds); }, testOutputDetails: value.ToString(), diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs index a8182bd07d..0fc5e286da 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs @@ -106,7 +106,7 @@ public class AffineTransformTests .AppendScale(new SizeF(sx, sy)) .AppendTranslation(new PointF(tx, ty)); - this.PrintMatrix(builder.BuildMatrix(image.Size())); + this.PrintMatrix(builder.BuildMatrix(image.Size)); image.Mutate(i => i.Transform(builder, KnownResamplers.Bicubic)); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index 86b9223c2e..d8ce88dc3b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -39,7 +39,7 @@ public class ResizeTests string filePath = TestFile.GetInputFileFullPath(TestImages.Jpeg.Baseline.Calliphora); using Image image = Image.Load(filePath); - image.Mutate(x => x.Resize(image.Size() / 2)); + image.Mutate(x => x.Resize(image.Size / 2)); string path = Path.Combine( TestEnvironment.CreateOutputDirectory(nameof(ResizeTests)), nameof(this.Resize_PixelAgnostic) + ".png"); @@ -101,7 +101,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image0 = provider.GetImage(); - Size destSize = image0.Size() / 4; + Size destSize = image0.Size / 4; Configuration configuration = Configuration.CreateDefaultInstance(); @@ -155,7 +155,7 @@ public class ResizeTests { using Image expected = provider.GetImage(); int width = expected.Width; - Size destSize = expected.Size() / 4; + Size destSize = expected.Size / 4; expected.Mutate(c => c.Resize(destSize, KnownResamplers.Bicubic, false)); // Replace configuration: @@ -179,7 +179,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - image.Mutate(x => x.Resize(image.Size() / 2, true)); + image.Mutate(x => x.Resize(image.Size / 2, true)); image.DebugSave(provider); image.CompareToReferenceOutput(ValidatorComparer, provider); diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs index 3aa879cf4d..a1d7e358b6 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs @@ -35,7 +35,7 @@ public class LoadResizeSaveProfilingBenchmarks : MeasureFixture { using (var image = Image.Load(options, imageBytes)) { - image.Mutate(x => x.Resize(image.Size() / 4)); + image.Mutate(x => x.Resize(image.Size / 4)); image.SaveAsJpeg(ms); } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs index 3de525964c..29f9d1626d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs @@ -76,9 +76,9 @@ public static class ImageComparerExtensions where TPixelA : unmanaged, IPixel where TPixelB : unmanaged, IPixel { - if (expected.Size() != actual.Size()) + if (expected.Size != actual.Size) { - throw new ImageDimensionsMismatchException(expected.Size(), actual.Size()); + throw new ImageDimensionsMismatchException(expected.Size, actual.Size); } if (expected.Frames.Count != actual.Frames.Count) @@ -101,9 +101,9 @@ public static class ImageComparerExtensions where TPixelA : unmanaged, IPixel where TPixelB : unmanaged, IPixel { - if (expected.Size() != actual.Size()) + if (expected.Size != actual.Size) { - throw new ImageDimensionsMismatchException(expected.Size(), actual.Size()); + throw new ImageDimensionsMismatchException(expected.Size, actual.Size); } if (expected.Frames.Count != actual.Frames.Count)