diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
index 1cb3f444f0..6341e1771c 100644
--- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
+++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
@@ -5,7 +5,8 @@
$(packageversion)
0.0.1
SixLabors and contributors
- netstandard1.3;netstandard2.0
+
+ netcoreapp2.1
7.3
true
true
diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj
index 29d29d50d8..e2f55e3c6a 100644
--- a/src/ImageSharp/ImageSharp.csproj
+++ b/src/ImageSharp/ImageSharp.csproj
@@ -5,7 +5,8 @@
$(packageversion)
0.0.1
Six Labors and contributors
- netstandard1.3;netstandard2.0;netcoreapp2.1;net472
+
+ netcoreapp2.1
true
true
SixLabors.ImageSharp
diff --git a/src/ImageSharp/Processing/Processors/Transforms/KernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/KernelMap.cs
index 278fd93d82..3f984fef0d 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/KernelMap.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/KernelMap.cs
@@ -19,16 +19,23 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
private readonly ResizeKernel[] kernels;
- ///
- /// Initializes a new instance of the class.
- ///
- /// The to use for allocations.
- /// The size of the destination window
- /// The radius of the kernel
- private KernelMap(MemoryAllocator memoryAllocator, int destinationSize, float kernelRadius)
+ private int period;
+
+ private int radius;
+
+ private int periodicRegionMin;
+
+ private int periodicRegionMax;
+
+ private KernelMap(MemoryAllocator memoryAllocator, int destinationSize, int radius, int period)
{
this.DestinationSize = destinationSize;
- int width = (int)Math.Ceiling(kernelRadius * 2);
+ this.period = period;
+ this.radius = radius;
+ this.periodicRegionMin = period + radius;
+ this.periodicRegionMax = destinationSize - radius;
+
+ int width = radius * 2;
this.data = memoryAllocator.Allocate2D(width, destinationSize, AllocationOptions.Clean);
this.kernels = new ResizeKernel[destinationSize];
}
@@ -71,8 +78,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
scale = 1F;
}
- float radius = MathF.Ceiling(scale * sampler.Radius);
- var result = new KernelMap(memoryAllocator, destinationSize, radius);
+ int period = ImageMaths.LeastCommonMultiple(sourceSize, destinationSize) / sourceSize;
+
+ int radius = (int)MathF.Ceiling(scale * sampler.Radius);
+ var result = new KernelMap(memoryAllocator, destinationSize, radius, period);
for (int i = 0; i < destinationSize; i++)
{
@@ -122,6 +131,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
return result;
}
+ private int ReduceIndex(int destIndex)
+ {
+ return destIndex;
+ }
+
///
/// Slices a weights value at the given positions.
///
diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj
index a705c9bacb..04a4541b21 100644
--- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj
+++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj
@@ -1,6 +1,7 @@
- netcoreapp2.1;net461
+
+ netcoreapp2.1
Exe
True
SixLabors.ImageSharp.Benchmarks
diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj
index 86c1a7a259..75ac7450c8 100644
--- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj
+++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj
@@ -1,6 +1,7 @@
- net462;net472;netcoreapp2.1
+
+ netcoreapp2.1
True
latest
full
diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/KernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/KernelMapTests.cs
index 9f4d53b964..7abc1c3122 100644
--- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/KernelMapTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/KernelMapTests.cs
@@ -20,17 +20,39 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
this.Output = output;
}
-
+
+ ///
+ /// resamplerName, srcSize, destSize
+ ///
+ public static readonly TheoryData KernelMapData = new TheoryData
+ {
+ { nameof(KnownResamplers.Bicubic), 15, 10 },
+ { nameof(KnownResamplers.Bicubic), 10, 15 },
+ { nameof(KnownResamplers.Bicubic), 20, 20 },
+ { nameof(KnownResamplers.Bicubic), 50, 40 },
+ { nameof(KnownResamplers.Bicubic), 40, 50 },
+ { nameof(KnownResamplers.Bicubic), 500, 200 },
+ { nameof(KnownResamplers.Bicubic), 200, 500 },
+
+ { nameof(KnownResamplers.Lanczos3), 16, 12 },
+ { nameof(KnownResamplers.Lanczos3), 12, 16 },
+ { nameof(KnownResamplers.Lanczos3), 12, 9 },
+ { nameof(KnownResamplers.Lanczos3), 9, 12 },
+ { nameof(KnownResamplers.Lanczos3), 6, 8 },
+ { nameof(KnownResamplers.Lanczos3), 8, 6 },
+
+ // TODO: What's wrong here:
+ // { nameof(KnownResamplers.Lanczos3), 20, 12 },
+
+ {nameof(KnownResamplers.Lanczos8), 500, 200 },
+ {nameof(KnownResamplers.Lanczos8), 100, 10 },
+ {nameof(KnownResamplers.Lanczos8), 100, 80 },
+ {nameof(KnownResamplers.Lanczos8), 10, 100 },
+ };
+
[Theory]
- [InlineData(500, 200, nameof(KnownResamplers.Bicubic))]
- [InlineData(50, 40, nameof(KnownResamplers.Bicubic))]
- [InlineData(40, 30, nameof(KnownResamplers.Bicubic))]
- [InlineData(15, 10, nameof(KnownResamplers.Bicubic))]
- [InlineData(500, 200, nameof(KnownResamplers.Lanczos8))]
- [InlineData(100, 80, nameof(KnownResamplers.Lanczos8))]
- [InlineData(100, 10, nameof(KnownResamplers.Lanczos8))]
- [InlineData(10, 100, nameof(KnownResamplers.Lanczos8))]
- public void KernelMapContentIsCorrect(int srcSize, int destSize, string resamplerName)
+ [MemberData(nameof(KernelMapData))]
+ public void KernelMapContentIsCorrect(string resamplerName, int srcSize, int destSize)
{
var resampler = (IResampler)typeof(KnownResamplers).GetProperty(resamplerName).GetValue(null);