diff --git a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
index a451e111d2..e2c4258e2a 100644
--- a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
+++ b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
@@ -76,6 +76,15 @@ public static void AcceptVisitor(this Image source, IImageVisitor visitor)
public static Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor, CancellationToken cancellationToken = default)
=> source.AcceptAsync(visitor, cancellationToken);
+ ///
+ /// Accepts a to implement a double-dispatch pattern in order to
+ /// apply pixel-specific operations on non-generic instances
+ ///
+ /// The source image frame.
+ /// The image visitor.
+ public static void AcceptVisitor(this ImageFrame source, IImageFrameVisitor visitor)
+ => source.Accept(visitor);
+
///
/// Gets the representation of the pixels as a containing the backing pixel data of the image
/// stored in row major order, as a list of contiguous blocks in the source image's pixel format.
diff --git a/src/ImageSharp/Advanced/IImageFrameVisitor.cs b/src/ImageSharp/Advanced/IImageFrameVisitor.cs
new file mode 100644
index 0000000000..f2522110d5
--- /dev/null
+++ b/src/ImageSharp/Advanced/IImageFrameVisitor.cs
@@ -0,0 +1,21 @@
+// Copyright (c) Six Labors.
+// Licensed under the Six Labors Split License.
+
+using SixLabors.ImageSharp.PixelFormats;
+
+namespace SixLabors.ImageSharp.Advanced;
+
+///
+/// A visitor to implement a double-dispatch pattern in order to apply pixel-specific operations
+/// on non-generic instances.
+///
+public interface IImageFrameVisitor
+{
+ ///
+ /// Provides a pixel-specific implementation for a given operation.
+ ///
+ /// The image frame.
+ /// The pixel type.
+ public void Visit(ImageFrame frame)
+ where TPixel : unmanaged, IPixel;
+}
diff --git a/src/ImageSharp/Advanced/IImageVisitor.cs b/src/ImageSharp/Advanced/IImageVisitor.cs
index 5e8a4e4512..aee6909675 100644
--- a/src/ImageSharp/Advanced/IImageVisitor.cs
+++ b/src/ImageSharp/Advanced/IImageVisitor.cs
@@ -16,7 +16,7 @@ public interface IImageVisitor
///
/// The image.
/// The pixel type.
- void Visit(Image image)
+ public void Visit(Image image)
where TPixel : unmanaged, IPixel;
}
@@ -33,6 +33,6 @@ public interface IImageVisitorAsync
/// The token to monitor for cancellation requests.
/// The pixel type.
/// A representing the asynchronous operation.
- Task VisitAsync(Image image, CancellationToken cancellationToken)
+ public Task VisitAsync(Image image, CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel;
}
diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
index d2883e2811..49640fae08 100644
--- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
+++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
@@ -303,7 +303,7 @@ private void EncodeFirstFrame(
this.WriteGraphicalControlExtension(metadata, stream);
Buffer2D indices = ((IPixelSource)quantized).PixelBuffer;
- Rectangle interest = indices.FullRectangle();
+ Rectangle interest = indices.Bounds;
bool useLocal = this.colorTableMode == FrameColorTableMode.Local || (metadata.ColorTableMode == FrameColorTableMode.Local);
int bitDepth = ColorNumerics.GetBitsNeededForColorDepth(quantized.Palette.Length);
diff --git a/src/ImageSharp/ImageFrame.cs b/src/ImageSharp/ImageFrame.cs
index cd6fa6d98a..2d726dc4a0 100644
--- a/src/ImageSharp/ImageFrame.cs
+++ b/src/ImageSharp/ImageFrame.cs
@@ -71,6 +71,19 @@ public void Dispose()
/// Whether to dispose of managed and unmanaged objects.
protected abstract void Dispose(bool disposing);
+ ///
+ /// Accepts a .
+ /// Implemented by invoking
+ /// with the pixel type of the image.
+ ///
+ /// The visitor.
+ internal abstract void Accept(IImageFrameVisitor visitor);
+
+ ///
+ /// Copies the pixel data of the image frame to a of a specific pixel type.
+ ///
+ /// The pixel type of the destination buffer.
+ /// The buffer to copy the pixel data to.
internal abstract void CopyPixelsTo(Buffer2D destination)
where TDestinationPixel : unmanaged, IPixel;
diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs
index 4e25c4e581..9029d3eec2 100644
--- a/src/ImageSharp/ImageFrame{TPixel}.cs
+++ b/src/ImageSharp/ImageFrame{TPixel}.cs
@@ -339,6 +339,10 @@ public bool DangerousTryGetSinglePixelMemory(out Memory memory)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal ref TPixel GetPixelReference(int x, int y) => ref this.PixelBuffer[x, y];
+ ///
+ internal override void Accept(IImageFrameVisitor visitor)
+ => visitor.Visit(this);
+
///
/// Copies the pixels to a of the same size.
///
@@ -346,7 +350,7 @@ public bool DangerousTryGetSinglePixelMemory(out Memory memory)
/// ImageFrame{TPixel}.CopyTo(): target must be of the same size!
internal void CopyTo(Buffer2D target)
{
- if (this.Size != target.Size())
+ if (this.Size != target.Size)
{
throw new ArgumentException("ImageFrame.CopyTo(): target must be of the same size!", nameof(target));
}
@@ -363,8 +367,8 @@ internal void SwapOrCopyPixelsBufferFrom(ImageFrame source)
{
Guard.NotNull(source, nameof(source));
- Buffer2D.SwapOrCopyContent(this.PixelBuffer, source.PixelBuffer);
- this.UpdateSize(this.PixelBuffer.Size());
+ _ = Buffer2D.SwapOrCopyContent(this.PixelBuffer, source.PixelBuffer);
+ this.UpdateSize(this.PixelBuffer.Size);
}
///
@@ -475,10 +479,7 @@ internal ImageFrame CloneAs(Configuration configuration)
/// Clears the bitmap.
///
/// The value to initialize the bitmap with.
- internal void Clear(TPixel value)
- {
- this.PixelBuffer.Clear(value);
- }
+ internal void Clear(TPixel value) => this.PixelBuffer.Clear(value);
[MethodImpl(InliningOptions.ShortMethod)]
private void VerifyCoords(int x, int y)
diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs
index 18db343563..4881518c9c 100644
--- a/src/ImageSharp/Image{TPixel}.cs
+++ b/src/ImageSharp/Image{TPixel}.cs
@@ -2,7 +2,6 @@
// Licensed under the Six Labors Split License.
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Metadata;
diff --git a/src/ImageSharp/Memory/Buffer2DExtensions.cs b/src/ImageSharp/Memory/Buffer2DExtensions.cs
index 96b9bc172f..290d978d0b 100644
--- a/src/ImageSharp/Memory/Buffer2DExtensions.cs
+++ b/src/ImageSharp/Memory/Buffer2DExtensions.cs
@@ -104,60 +104,40 @@ internal static unsafe void DangerousCopyColumns(
}
///
- /// Returns a representing the full area of the buffer.
- ///
- /// The element type
- /// The
- /// The
- internal static Rectangle FullRectangle(this Buffer2D buffer)
- where T : struct
- => new(0, 0, buffer.Width, buffer.Height);
-
- ///
- /// Return a to the subregion represented by 'rectangle'
+ /// Return a to the subregion represented by .
///
/// The element type
/// The
/// The rectangle subregion
/// The
- internal static Buffer2DRegion GetRegion(this Buffer2D buffer, Rectangle rectangle)
+ public static Buffer2DRegion GetRegion(this Buffer2D buffer, Rectangle rectangle)
where T : unmanaged =>
new(buffer, rectangle);
- internal static Buffer2DRegion GetRegion(this Buffer2D buffer, int x, int y, int width, int height)
+ ///
+ /// Return a to the specified area of .
+ ///
+ /// The element type.
+ /// The .
+ /// The X coordinate of the region.
+ /// The Y coordinate of the region.
+ /// The region width.
+ /// The region height.
+ /// The .
+ public static Buffer2DRegion GetRegion(this Buffer2D buffer, int x, int y, int width, int height)
where T : unmanaged =>
new(buffer, new Rectangle(x, y, width, height));
///
- /// Return a to the whole area of 'buffer'
+ /// Return a to the whole area of .
///
/// The element type
/// The
/// The
- internal static Buffer2DRegion GetRegion(this Buffer2D buffer)
+ public static Buffer2DRegion GetRegion(this Buffer2D buffer)
where T : unmanaged =>
new(buffer);
- ///
- /// Returns the size of the buffer.
- ///
- /// The element type
- /// The
- /// The of the buffer
- internal static Size Size(this Buffer2D buffer)
- where T : struct =>
- new(buffer.Width, buffer.Height);
-
- ///
- /// Gets the bounds of the buffer.
- ///
- /// The element type
- /// The
- /// The
- internal static Rectangle Bounds(this Buffer2D buffer)
- where T : struct =>
- new(0, 0, buffer.Width, buffer.Height);
-
[Conditional("DEBUG")]
private static void CheckColumnRegionsDoNotOverlap(
Buffer2D buffer,
diff --git a/src/ImageSharp/Memory/Buffer2DRegion{T}.cs b/src/ImageSharp/Memory/Buffer2DRegion{T}.cs
index 7bfb6f5731..c78c4ce9ee 100644
--- a/src/ImageSharp/Memory/Buffer2DRegion{T}.cs
+++ b/src/ImageSharp/Memory/Buffer2DRegion{T}.cs
@@ -15,17 +15,17 @@ public readonly struct Buffer2DRegion
/// Initializes a new instance of the struct.
///
/// The .
- /// The defining a rectangular area within the buffer.
+ /// The defining a rectangular area within the buffer.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Buffer2DRegion(Buffer2D buffer, Rectangle rectangle)
+ public Buffer2DRegion(Buffer2D buffer, Rectangle bounds)
{
- DebugGuard.MustBeGreaterThanOrEqualTo(rectangle.X, 0, nameof(rectangle));
- DebugGuard.MustBeGreaterThanOrEqualTo(rectangle.Y, 0, nameof(rectangle));
- DebugGuard.MustBeLessThanOrEqualTo(rectangle.Width, buffer.Width, nameof(rectangle));
- DebugGuard.MustBeLessThanOrEqualTo(rectangle.Height, buffer.Height, nameof(rectangle));
+ DebugGuard.MustBeGreaterThanOrEqualTo(bounds.X, 0, nameof(bounds));
+ DebugGuard.MustBeGreaterThanOrEqualTo(bounds.Y, 0, nameof(bounds));
+ DebugGuard.MustBeLessThanOrEqualTo(bounds.Width, buffer.Width, nameof(bounds));
+ DebugGuard.MustBeLessThanOrEqualTo(bounds.Height, buffer.Height, nameof(bounds));
this.Buffer = buffer;
- this.Rectangle = rectangle;
+ this.Bounds = bounds;
}
///
@@ -34,15 +34,10 @@ public Buffer2DRegion(Buffer2D buffer, Rectangle rectangle)
/// The .
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Buffer2DRegion(Buffer2D buffer)
- : this(buffer, buffer.FullRectangle())
+ : this(buffer, buffer.Bounds)
{
}
- ///
- /// Gets the rectangle specifying the boundaries of the area in .
- ///
- public Rectangle Rectangle { get; }
-
///
/// Gets the being pointed by this instance.
///
@@ -51,12 +46,12 @@ public Buffer2DRegion(Buffer2D buffer)
///
/// Gets the width
///
- public int Width => this.Rectangle.Width;
+ public int Width => this.Bounds.Width;
///
/// Gets the height
///
- public int Height => this.Rectangle.Height;
+ public int Height => this.Bounds.Height;
///
/// Gets the number of elements between row starts in .
@@ -66,12 +61,17 @@ public Buffer2DRegion(Buffer2D buffer)
///
/// Gets the size of the area.
///
- internal Size Size => this.Rectangle.Size;
+ public Size Size => this.Bounds.Size;
+
+ ///
+ /// Gets the rectangle specifying the boundaries of the area in .
+ ///
+ public Rectangle Bounds { get; }
///
/// Gets a value indicating whether the area refers to the entire
///
- internal bool IsFullBufferArea => this.Size == this.Buffer.Size();
+ internal bool IsFullBufferArea => this.Size == this.Buffer.Size;
///
/// Gets or sets a value at the given index.
@@ -79,7 +79,7 @@ public Buffer2DRegion(Buffer2D buffer)
/// The position inside a row
/// The row index
/// The reference to the value
- internal ref T this[int x, int y] => ref this.Buffer[x + this.Rectangle.X, y + this.Rectangle.Y];
+ internal ref T this[int x, int y] => ref this.Buffer[x + this.Bounds.X, y + this.Bounds.Y];
///
/// Gets a span to row 'y' inside this area.
@@ -89,9 +89,9 @@ public Buffer2DRegion(Buffer2D buffer)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span DangerousGetRowSpan(int y)
{
- int yy = this.Rectangle.Y + y;
- int xx = this.Rectangle.X;
- int width = this.Rectangle.Width;
+ int yy = this.Bounds.Y + y;
+ int xx = this.Bounds.X;
+ int width = this.Bounds.Width;
return this.Buffer.DangerousGetRowSpan(yy).Slice(xx, width);
}
@@ -114,16 +114,16 @@ public Buffer2DRegion GetSubRegion(int x, int y, int width, int height)
///
/// Returns a subregion as . (Similar to .)
///
- /// The specifying the boundaries of the subregion
+ /// The specifying the boundaries of the subregion
/// The subregion
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Buffer2DRegion GetSubRegion(Rectangle rectangle)
{
- DebugGuard.MustBeLessThanOrEqualTo(rectangle.Width, this.Rectangle.Width, nameof(rectangle));
- DebugGuard.MustBeLessThanOrEqualTo(rectangle.Height, this.Rectangle.Height, nameof(rectangle));
+ DebugGuard.MustBeLessThanOrEqualTo(rectangle.Width, this.Bounds.Width, nameof(rectangle));
+ DebugGuard.MustBeLessThanOrEqualTo(rectangle.Height, this.Bounds.Height, nameof(rectangle));
- int x = this.Rectangle.X + rectangle.X;
- int y = this.Rectangle.Y + rectangle.Y;
+ int x = this.Bounds.X + rectangle.X;
+ int y = this.Bounds.Y + rectangle.Y;
rectangle = new Rectangle(x, y, rectangle.Width, rectangle.Height);
return new Buffer2DRegion(this.Buffer, rectangle);
}
@@ -135,8 +135,8 @@ public Buffer2DRegion GetSubRegion(Rectangle rectangle)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal ref T GetReferenceToOrigin()
{
- int y = this.Rectangle.Y;
- int x = this.Rectangle.X;
+ int y = this.Bounds.Y;
+ int x = this.Bounds.X;
return ref this.Buffer.DangerousGetRowSpan(y)[x];
}
@@ -152,7 +152,7 @@ internal void Clear()
return;
}
- for (int y = 0; y < this.Rectangle.Height; y++)
+ for (int y = 0; y < this.Bounds.Height; y++)
{
Span row = this.DangerousGetRowSpan(y);
row.Clear();
@@ -172,7 +172,7 @@ internal void Fill(T value)
return;
}
- for (int y = 0; y < this.Rectangle.Height; y++)
+ for (int y = 0; y < this.Bounds.Height; y++)
{
Span row = this.DangerousGetRowSpan(y);
row.Fill(value);
diff --git a/src/ImageSharp/Memory/Buffer2D{T}.cs b/src/ImageSharp/Memory/Buffer2D{T}.cs
index fe997a4fbf..cfd7664f01 100644
--- a/src/ImageSharp/Memory/Buffer2D{T}.cs
+++ b/src/ImageSharp/Memory/Buffer2D{T}.cs
@@ -39,20 +39,30 @@ internal Buffer2D(MemoryGroup memoryGroup, int width, int height, int rowStri
Guard.MustBeGreaterThanOrEqualTo(rowStride, width, nameof(rowStride));
this.FastMemoryGroup = memoryGroup;
- this.Width = width;
- this.Height = height;
+ this.Size = new Size(width, height);
this.RowStride = rowStride;
}
///
/// Gets the width.
///
- public int Width { get; private set; }
+ public int Width => this.Size.Width;
///
/// Gets the height.
///
- public int Height { get; private set; }
+ public int Height => this.Size.Height;
+
+ ///
+ /// Gets the size of the buffer.
+ ///
+ public Size Size { get; private set; }
+
+ ///
+ /// Gets the bounds of the buffer.
+ ///
+ /// The
+ public Rectangle Bounds => new(0, 0, this.Width, this.Height);
///
/// Gets the number of elements between row starts in the backing memory.
@@ -402,8 +412,7 @@ internal static bool SwapOrCopyContent(Buffer2D destination, Buffer2D sour
source.CopyTo(destination);
}
- (destination.Width, source.Width) = (source.Width, destination.Width);
- (destination.Height, source.Height) = (source.Height, destination.Height);
+ (destination.Size, source.Size) = (source.Size, destination.Size);
(destination.RowStride, source.RowStride) = (source.RowStride, destination.RowStride);
return swapped;
}
diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
index 0a4d386550..a0a8c2173e 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
@@ -59,7 +59,7 @@ public ResizeWorker(
{
this.configuration = configuration;
this.source = source;
- this.sourceRectangle = source.Rectangle;
+ this.sourceRectangle = source.Bounds;
this.conversionModifiers = conversionModifiers;
this.horizontalKernelMap = horizontalKernelMap;
this.verticalKernelMap = verticalKernelMap;
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
index 903a6b0762..1610df6eb4 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
@@ -119,7 +119,7 @@ private void VerifySpectralCorrectnessImpl(
this.Output.WriteLine($"Component{i}: [total: {total} | average: {average}]");
averageDifference += average;
totalDifference += total;
- Size s = libJpegComponent.SpectralBlocks.Size();
+ Size s = libJpegComponent.SpectralBlocks.Size;
tolerance += s.Width * s.Height;
}
diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs
index caf935cc47..6e9069a45e 100644
--- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs
+++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Memory;
@@ -15,26 +15,24 @@ public class SwapOrCopyContent
[Fact]
public void SwapOrCopyContent_WhenBothAllocated()
{
- using (Buffer2D a = this.memoryAllocator.Allocate2D(10, 5, AllocationOptions.Clean))
- using (Buffer2D b = this.memoryAllocator.Allocate2D(3, 7, AllocationOptions.Clean))
- {
- a[1, 3] = 666;
- b[1, 3] = 444;
+ using Buffer2D a = this.memoryAllocator.Allocate2D(10, 5, AllocationOptions.Clean);
+ using Buffer2D b = this.memoryAllocator.Allocate2D(3, 7, AllocationOptions.Clean);
+ a[1, 3] = 666;
+ b[1, 3] = 444;
- Memory aa = a.FastMemoryGroup.Single();
- Memory bb = b.FastMemoryGroup.Single();
+ Memory aa = a.FastMemoryGroup.Single();
+ Memory bb = b.FastMemoryGroup.Single();
- Buffer2D.SwapOrCopyContent(a, b);
+ Buffer2D.SwapOrCopyContent(a, b);
- Assert.Equal(bb, a.FastMemoryGroup.Single());
- Assert.Equal(aa, b.FastMemoryGroup.Single());
+ Assert.Equal(bb, a.FastMemoryGroup.Single());
+ Assert.Equal(aa, b.FastMemoryGroup.Single());
- Assert.Equal(new Size(3, 7), a.Size());
- Assert.Equal(new Size(10, 5), b.Size());
+ Assert.Equal(new Size(3, 7), a.Size);
+ Assert.Equal(new Size(10, 5), b.Size);
- Assert.Equal(666, b[1, 3]);
- Assert.Equal(444, a[1, 3]);
- }
+ Assert.Equal(666, b[1, 3]);
+ Assert.Equal(444, a[1, 3]);
}
[Fact]
@@ -171,7 +169,7 @@ public void WhenDestIsNotMemoryOwner_DifferentSizeSameTotal_PackedLayout_ShouldC
bool swap = Buffer2D.SwapOrCopyContent(dest, source);
Assert.False(swap);
- Assert.Equal(new Size(3, 2), dest.Size());
+ Assert.Equal(new Size(3, 2), dest.Size);
Assert.Equal(6, dest[2, 1]);
}
@@ -191,7 +189,7 @@ public void WhenDestIsNotMemoryOwner_DifferentSizeSameTotal_StridedLayout_Should
bool swap = Buffer2D.SwapOrCopyContent(dest, source);
Assert.False(swap);
- Assert.Equal(new Size(1, 5), dest.Size());
+ Assert.Equal(new Size(1, 5), dest.Size);
Assert.Equal(1, dest[0, 0]);
Assert.Equal(2, dest[0, 1]);
Assert.Equal(3, dest[0, 2]);
@@ -215,7 +213,7 @@ public void WhenDestIsNotMemoryOwner_DifferentSizeDifferentTotal_ButBothLayoutsF
bool swap = Buffer2D.SwapOrCopyContent(dest, source);
Assert.False(swap);
- Assert.Equal(new Size(2, 2), dest.Size());
+ Assert.Equal(new Size(2, 2), dest.Size);
Assert.Equal(1, dest[0, 0]);
Assert.Equal(2, dest[1, 0]);
Assert.Equal(3, dest[0, 1]);
diff --git a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs
index be7edbacca..a44d6ce1a1 100644
--- a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs
+++ b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs
@@ -17,7 +17,7 @@ public void Construct()
Buffer2DRegion area = new(buffer, rectangle);
Assert.Equal(buffer, area.Buffer);
- Assert.Equal(rectangle, area.Rectangle);
+ Assert.Equal(rectangle, area.Bounds);
}
private Buffer2D CreateTestBuffer(int w, int h)
@@ -90,7 +90,7 @@ public void GetSubArea()
Rectangle expectedRect = new(10, 12, 5, 5);
Assert.Equal(buffer, area1.Buffer);
- Assert.Equal(expectedRect, area1.Rectangle);
+ Assert.Equal(expectedRect, area1.Bounds);
int value00 = (12 * 100) + 10;
Assert.Equal(value00, area1[0, 0]);
@@ -147,9 +147,9 @@ public void Clear_SubArea(int bufferCapacity)
Assert.Equal(0, buffer[5, 5]);
Assert.Equal(0, buffer[14, 14]);
- for (int y = region.Rectangle.Y; y < region.Rectangle.Bottom; y++)
+ for (int y = region.Bounds.Y; y < region.Bounds.Bottom; y++)
{
- Span span = buffer.DangerousGetRowSpan(y).Slice(region.Rectangle.X, region.Width);
+ Span span = buffer.DangerousGetRowSpan(y).Slice(region.Bounds.X, region.Width);
Assert.True(span.SequenceEqual(new int[region.Width]));
}
}
diff --git a/tests/ImageSharp.Tests/Processing/IntegralImageTests.cs b/tests/ImageSharp.Tests/Processing/IntegralImageTests.cs
index 81ba1693d2..a0ea99a9d0 100644
--- a/tests/ImageSharp.Tests/Processing/IntegralImageTests.cs
+++ b/tests/ImageSharp.Tests/Processing/IntegralImageTests.cs
@@ -76,7 +76,7 @@ private static void VerifySumValues(
Buffer2D integralBuffer,
Func getPixel)
where TPixel : unmanaged, IPixel
- => VerifySumValues(provider, integralBuffer, integralBuffer.Bounds(), getPixel);
+ => VerifySumValues(provider, integralBuffer, integralBuffer.Bounds, getPixel);
private static void VerifySumValues(
TestImageProvider provider,
diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs
index 4a34529dd3..be2356d657 100644
--- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs
@@ -505,7 +505,7 @@ public static void CompareBuffers(Span expected, Span actual)
public static void CompareBuffers(Buffer2D expected, Buffer2D actual)
where T : struct, IEquatable
{
- Assert.True(expected.Size() == actual.Size(), "Buffer sizes are not equal!");
+ Assert.True(expected.Size == actual.Size, "Buffer sizes are not equal!");
for (int y = 0; y < expected.Height; y++)
{