Browse Source

fix rotate and skew processors

af/merge-core
Anton Firszov 7 years ago
parent
commit
f9f58fa570
  1. 10
      src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs
  2. 10
      src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs

10
src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs

@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0.
using System;
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.ParallelUtils;
@ -34,12 +36,18 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
/// <param name="sampler">The sampler to perform the rotating operation.</param>
/// <param name="sourceSize">The source image size</param>
public RotateProcessor(float degrees, IResampler sampler, Size sourceSize)
: base(
: this(
TransformUtils.CreateRotationMatrixDegrees(degrees, sourceSize),
sampler,
sourceSize)
=> this.Degrees = degrees;
// Helper constructor
private RotateProcessor(Matrix3x2 rotationMatrix, IResampler sampler, Size sourceSize)
: base(rotationMatrix, sampler, TransformUtils.GetTransformedSize(sourceSize, rotationMatrix))
{
}
/// <summary>
/// Gets the angle of rotation in degrees.
/// </summary>

10
src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs

@ -1,6 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
@ -32,7 +34,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
/// <param name="sampler">The sampler to perform the skew operation.</param>
/// <param name="sourceSize">The source image size</param>
public SkewProcessor(float degreesX, float degreesY, IResampler sampler, Size sourceSize)
: base(
: this(
TransformUtils.CreateSkewMatrixDegrees(degreesX, degreesY, sourceSize),
sampler,
sourceSize)
@ -41,6 +43,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
this.DegreesY = degreesY;
}
// Helper constructor:
private SkewProcessor(Matrix3x2 skewMatrix, IResampler sampler, Size sourceSize)
: base(skewMatrix, sampler, TransformUtils.GetTransformedSize(sourceSize, skewMatrix))
{
}
/// <summary>
/// Gets the angle of rotation along the x-axis in degrees.
/// </summary>

Loading…
Cancel
Save