diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs
index b1767101d..7cb014563 100644
--- a/src/ImageSharp/Configuration.cs
+++ b/src/ImageSharp/Configuration.cs
@@ -128,9 +128,9 @@ namespace SixLabors.ImageSharp
}
///
- /// Creates a shallow copy of the
+ /// Creates a shallow copy of the .
///
- /// A new configuration instance
+ /// A new configuration instance.
public Configuration Clone()
{
return new Configuration
@@ -147,12 +147,12 @@ namespace SixLabors.ImageSharp
///
/// Creates the default instance with the following s preregistered:
- ///
- ///
- ///
- ///
+ ///
+ ///
+ ///
+ /// .
///
- /// The default configuration of
+ /// The default configuration of .
internal static Configuration CreateDefaultInstance()
{
return new Configuration(
diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs
index 0bc8cfda0..595a7e852 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs
@@ -15,13 +15,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
///
internal static class ResizeHelper
{
- public static unsafe int CalculateResizeWorkerWindowCount(
- int windowDiameter,
+ public static unsafe int CalculateResizeWorkerHeightInWindowBands(
+ int windowBandDiameter,
int width,
int sizeLimitHintInBytes)
{
int sizeLimitHint = sizeLimitHintInBytes / sizeof(Vector4);
- int sizeOfOneWindow = windowDiameter * width;
+ int sizeOfOneWindow = windowBandDiameter * width;
return Math.Max(2, sizeLimitHint / sizeOfOneWindow);
}
diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
index 11b49b863..73dcce58b 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
@@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
private readonly Rectangle destWorkingRect;
- private readonly int diameter;
+ private readonly int windowBandDiameter;
private readonly int windowHeight;
@@ -65,9 +65,14 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
this.destWorkingRect = destWorkingRect;
this.startX = startX;
- this.diameter = verticalKernelMap.MaxDiameter;
+ this.windowBandDiameter = verticalKernelMap.MaxDiameter;
- this.windowHeight = Math.Min(this.sourceRectangle.Height, 2 * this.diameter);
+ int numberOfWindowBands = ResizeHelper.CalculateResizeWorkerHeightInWindowBands(
+ this.windowBandDiameter,
+ destWidth,
+ configuration.WorkingBufferSizeHintInBytes);
+
+ this.windowHeight = Math.Min(this.sourceRectangle.Height, numberOfWindowBands * this.windowBandDiameter);
this.buffer = configuration.MemoryAllocator.Allocate2D(
this.windowHeight,
@@ -143,8 +148,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
public void Slide()
{
- this.CurrentMinY = this.CurrentMinY + this.diameter;
- this.CurrentMaxY = Math.Min(this.CurrentMaxY + this.diameter, this.sourceRectangle.Height);
+ this.CurrentMinY = this.CurrentMinY + this.windowBandDiameter;
+ this.CurrentMaxY = Math.Min(this.CurrentMaxY + this.windowBandDiameter, this.sourceRectangle.Height);
this.CalculateFirstPassValues(this.CurrentMinY, this.CurrentMaxY);
}
diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs
index 1bd909e7e..51680eee0 100644
--- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs
@@ -36,6 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{ nameof(KnownResamplers.Bicubic), 40, 50 },
{ nameof(KnownResamplers.Bicubic), 500, 200 },
{ nameof(KnownResamplers.Bicubic), 200, 500 },
+ { nameof(KnownResamplers.Bicubic), 3032, 400 },
{ nameof(KnownResamplers.Bicubic), 10, 25 },
diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs
index ec0092f34..532558166 100644
--- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs
@@ -44,13 +44,16 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
[InlineData(17, 63, 5*17*63*16, 5)]
[InlineData(17, 63, 5*17*63*16+1, 5)]
[InlineData(17, 63, 6*17*63*16-1, 5)]
- public void CalculateResizeWorkerWindowCount(
+ [InlineData(33, 400, 1*1024*1024, 4)]
+ [InlineData(33, 400, 8*1024*1024, 39)]
+ [InlineData(50, 300, 1*1024*1024, 4)]
+ public void CalculateResizeWorkerHeightInWindowBands(
int windowDiameter,
int width,
int sizeLimitHintInBytes,
int expectedCount)
{
- int actualCount = ResizeHelper.CalculateResizeWorkerWindowCount(windowDiameter, width, sizeLimitHintInBytes);
+ int actualCount = ResizeHelper.CalculateResizeWorkerHeightInWindowBands(windowDiameter, width, sizeLimitHintInBytes);
Assert.Equal(expectedCount, actualCount);
}