diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
index eb3c29dd98..3e320dccc7 100644
--- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
+++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
@@ -36,9 +36,9 @@
-
-
-
+
+
+
All
diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj
index 8c22237cf7..f1bcb2ecda 100644
--- a/src/ImageSharp/ImageSharp.csproj
+++ b/src/ImageSharp/ImageSharp.csproj
@@ -34,7 +34,7 @@
-
+
All
diff --git a/src/ImageSharp/Processing/Processors/Transforms/AffineProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/AffineProcessor.cs
index 4db2aacbac..cffe6674d6 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/AffineProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/AffineProcessor.cs
@@ -1,12 +1,15 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
+using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
@@ -76,6 +79,64 @@ namespace SixLabors.ImageSharp.Processing.Processors
return new Image(source.GetConfiguration(), source.MetaData.Clone(), frames);
}
+ ///
+ protected override void OnApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration)
+ {
+ int height = this.ResizeRectangle.Height;
+ int width = this.ResizeRectangle.Width;
+ Matrix3x2 matrix = this.GetCenteredMatrix(source);
+ Rectangle sourceBounds = source.Bounds();
+
+ if (this.Sampler is NearestNeighborResampler)
+ {
+ Parallel.For(
+ 0,
+ height,
+ configuration.ParallelOptions,
+ y =>
+ {
+ Span destRow = destination.GetPixelRowSpan(y);
+
+ for (int x = 0; x < width; x++)
+ {
+ var transformedPoint = Point.Transform(new Point(x, y), matrix);
+ if (sourceBounds.Contains(transformedPoint.X, transformedPoint.Y))
+ {
+ destRow[x] = source[transformedPoint.X, transformedPoint.Y];
+ }
+ }
+ });
+
+ return;
+ }
+
+ int maxX = source.Width - 1;
+ int maxY = source.Height - 1;
+ int radius = Math.Max((int)this.Sampler.Radius, 1);
+
+ Parallel.For(
+ 0,
+ height,
+ configuration.ParallelOptions,
+ y =>
+ {
+ Span destRow = destination.GetPixelRowSpan(y);
+ for (int x = 0; x < width; x++)
+ {
+ var transformedPoint = Point.Transform(new Point(x, y), matrix);
+ if (sourceBounds.Contains(transformedPoint.X, transformedPoint.Y))
+ {
+ WeightsWindow windowX = this.HorizontalWeights.Weights[transformedPoint.X];
+ WeightsWindow windowY = this.VerticalWeights.Weights[transformedPoint.Y];
+
+ Vector4 dXY = this.ComputeWeightedSumAtPosition(source, maxX, maxY, radius, ref windowX, ref windowY, ref transformedPoint);
+ ref TPixel dest = ref destRow[x];
+ dest.PackFromVector4(dXY);
+ }
+ }
+ });
+ }
+
///
/// Gets a transform matrix adjusted to center upon the target image bounds.
///
diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs
index a1b181e69f..eb6110fa14 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs
@@ -81,59 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
return;
}
- int height = this.ResizeRectangle.Height;
- int width = this.ResizeRectangle.Width;
- Matrix3x2 matrix = this.GetCenteredMatrix(source);
- Rectangle sourceBounds = source.Bounds();
-
- if (this.Sampler is NearestNeighborResampler)
- {
- Parallel.For(
- 0,
- height,
- configuration.ParallelOptions,
- y =>
- {
- Span destRow = destination.GetPixelRowSpan(y);
-
- for (int x = 0; x < width; x++)
- {
- var transformedPoint = Point.Rotate(new Point(x, y), matrix);
- if (sourceBounds.Contains(transformedPoint.X, transformedPoint.Y))
- {
- destRow[x] = source[transformedPoint.X, transformedPoint.Y];
- }
- }
- });
-
- return;
- }
-
- int maxX = source.Width - 1;
- int maxY = source.Height - 1;
- int radius = Math.Max((int)this.Sampler.Radius, 1);
-
- Parallel.For(
- 0,
- height,
- configuration.ParallelOptions,
- y =>
- {
- Span destRow = destination.GetPixelRowSpan(y);
- for (int x = 0; x < width; x++)
- {
- var transformedPoint = Point.Rotate(new Point(x, y), matrix);
- if (sourceBounds.Contains(transformedPoint.X, transformedPoint.Y))
- {
- WeightsWindow windowX = this.HorizontalWeights.Weights[transformedPoint.X];
- WeightsWindow windowY = this.VerticalWeights.Weights[transformedPoint.Y];
-
- Vector4 dXY = this.ComputeWeightedSumAtPosition(source, maxX, maxY, radius, ref windowX, ref windowY, ref transformedPoint);
- ref TPixel dest = ref destRow[x];
- dest.PackFromVector4(dXY);
- }
- }
- });
+ base.OnApply(source, destination, sourceRectangle, configuration);
}
///
diff --git a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs
index 0f67f724ca..fc70330e81 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs
@@ -1,11 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
using System.Numerics;
-using System.Threading.Tasks;
-using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
@@ -49,63 +45,5 @@ namespace SixLabors.ImageSharp.Processing.Processors
return this.transformMatrix;
}
-
- ///
- protected override void OnApply(ImageFrame source, ImageFrame destination, Rectangle sourceRectangle, Configuration configuration)
- {
- int height = this.ResizeRectangle.Height;
- int width = this.ResizeRectangle.Width;
- Matrix3x2 matrix = this.GetCenteredMatrix(source);
- Rectangle sourceBounds = source.Bounds();
-
- if (this.Sampler is NearestNeighborResampler)
- {
- Parallel.For(
- 0,
- height,
- configuration.ParallelOptions,
- y =>
- {
- Span destRow = destination.GetPixelRowSpan(y);
-
- for (int x = 0; x < width; x++)
- {
- var transformedPoint = Point.Skew(new Point(x, y), matrix);
- if (sourceBounds.Contains(transformedPoint.X, transformedPoint.Y))
- {
- destRow[x] = source[transformedPoint.X, transformedPoint.Y];
- }
- }
- });
-
- return;
- }
-
- int maxX = source.Width - 1;
- int maxY = source.Height - 1;
- int radius = Math.Max((int)this.Sampler.Radius, 1);
-
- Parallel.For(
- 0,
- height,
- configuration.ParallelOptions,
- y =>
- {
- Span destRow = destination.GetPixelRowSpan(y);
- for (int x = 0; x < width; x++)
- {
- var transformedPoint = Point.Skew(new Point(x, y), matrix);
- if (sourceBounds.Contains(transformedPoint.X, transformedPoint.Y))
- {
- WeightsWindow windowX = this.HorizontalWeights.Weights[transformedPoint.X];
- WeightsWindow windowY = this.VerticalWeights.Weights[transformedPoint.Y];
-
- Vector4 dXY = this.ComputeWeightedSumAtPosition(source, maxX, maxY, radius, ref windowX, ref windowY, ref transformedPoint);
- ref TPixel dest = ref destRow[x];
- dest.PackFromVector4(dXY);
- }
- }
- });
- }
}
}
\ No newline at end of file