diff --git a/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs
index 7822eb7f0..847c68ef4 100644
--- a/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs
+++ b/src/ImageProcessorCore/Samplers/Processors/RotateProcessor.cs
@@ -41,10 +41,6 @@ namespace ImageProcessorCore
}
}
- ///
- /// Gets or sets the center point.
- ///
- public Point Center { get; set; }
///
/// Gets or sets a value indicating whether to expand the canvas to fit the rotated image.
@@ -54,22 +50,12 @@ namespace ImageProcessorCore
///
protected override void OnApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
{
- // If we are expanding we need to pad the bounds of the source rectangle.
- // We can use the resizer in nearest neighbor mode to do this fairly quickly.
if (this.Expand)
{
// First find out how big the target rectangle should be.
- Point centre = this.Center == Point.Empty ? Rectangle.Center(sourceRectangle) : this.Center;
+ Point centre = Rectangle.Center(sourceRectangle);
Matrix3x2 rotation = Point.CreateRotation(centre, -this.angle);
Rectangle rectangle = ImageMaths.GetBoundingRectangle(sourceRectangle, rotation);
- ResizeOptions options = new ResizeOptions
- {
- Size = new Size(rectangle.Width, rectangle.Height),
- Mode = ResizeMode.BoxPad
- };
-
- // Get the padded bounds and resize the image.
- Rectangle bounds = ResizeHelper.CalculateTargetLocationAndBounds(source, options);
target.SetPixels(rectangle.Width, rectangle.Height, new float[rectangle.Width * rectangle.Height * 4]);
}
}
@@ -78,14 +64,10 @@ namespace ImageProcessorCore
protected override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
{
- Point centre = Rectangle.Center(source.Bounds);
- Matrix3x2 rotation = Point.CreateRotation(centre, -this.angle);
-
- rotation = Point.CreateRotation(new Point(0,0), -this.angle);
-
- Matrix3x2 tran =Matrix3x2.CreateTranslation(-target.Width/2, -target.Height/2);
+ Matrix3x2 rotation = Point.CreateRotation(new Point(0,0), -this.angle);
+ Matrix3x2 tran =Matrix3x2.CreateTranslation(-target.Width/2f, -target.Height/2f);
rotation = tran* rotation;
- Matrix3x2 tran2 = Matrix3x2.CreateTranslation(source.Width / 2, source.Height / 2);
+ Matrix3x2 tran2 = Matrix3x2.CreateTranslation(source.Width / 2f, source.Height / 2f);
rotation = rotation*tran2;
diff --git a/src/ImageProcessorCore/Samplers/Rotate.cs b/src/ImageProcessorCore/Samplers/Rotate.cs
index 49441fbb5..09c49e588 100644
--- a/src/ImageProcessorCore/Samplers/Rotate.cs
+++ b/src/ImageProcessorCore/Samplers/Rotate.cs
@@ -33,7 +33,7 @@ namespace ImageProcessorCore
/// The
public static Image Rotate(this Image source, float degrees, Point center, bool expand, ProgressEventHandler progressHandler = null)
{
- RotateProcessor processor = new RotateProcessor { Angle = degrees, Center = center, Expand = expand };
+ RotateProcessor processor = new RotateProcessor { Angle = degrees, Expand = expand };
processor.OnProgress += progressHandler;
try
diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/SamplerTests.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/SamplerTests.cs
index ac610746e..29ab3be26 100644
--- a/tests/ImageProcessorCore.Tests/Processors/Samplers/SamplerTests.cs
+++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/SamplerTests.cs
@@ -471,7 +471,7 @@
using (Image image = new Image(stream))
using (FileStream output = File.OpenWrite($"TestOutput/Rotate/{filename}"))
{
- image.Rotate(63, this.ProgressUpdate)
+ image.Rotate(20, this.ProgressUpdate)
.Save(output);
}