diff --git a/src/ImageSharp.Drawing/Paths/ShapeRegion.cs b/src/ImageSharp.Drawing/Paths/ShapeRegion.cs
index 51093c5d9c..a7a72c4f3c 100644
--- a/src/ImageSharp.Drawing/Paths/ShapeRegion.cs
+++ b/src/ImageSharp.Drawing/Paths/ShapeRegion.cs
@@ -8,6 +8,7 @@ namespace ImageSharp.Drawing
using System;
using System.Buffers;
using System.Numerics;
+ using ImageSharp.Memory;
using SixLabors.Primitives;
using SixLabors.Shapes;
@@ -45,24 +46,20 @@ namespace ImageSharp.Drawing
///
public override int Scan(float y, Span buffer)
{
- PointF start = new PointF(this.Bounds.Left - 1, y);
- PointF end = new PointF(this.Bounds.Right + 1, y);
- PointF[] innerbuffer = ArrayPool.Shared.Rent(buffer.Length);
- try
+ var start = new PointF(this.Bounds.Left - 1, y);
+ var end = new PointF(this.Bounds.Right + 1, y);
+ using (var innerBuffer = new Buffer(buffer.Length))
{
- int count = this.Shape.FindIntersections(start, end, innerbuffer);
+ var span = innerBuffer.Span;
+ int count = this.Shape.FindIntersections(start, end, span);
for (int i = 0; i < count; i++)
{
- buffer[i] = innerbuffer[i].X;
+ buffer[i] = span[i].X;
}
return count;
}
- finally
- {
- ArrayPool.Shared.Return(innerbuffer);
- }
}
}
-}
+}
\ No newline at end of file