Browse Source

renamed NonAffineTransformProcessor to ProjectiveTransformProcessor

af/merge-core
Anton Firszov 8 years ago
parent
commit
22d212de09
  1. 6
      src/ImageSharp/Processing/Processors/Transforms/CenteredProjectiveTransformProcessor.cs
  2. 15
      src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs
  3. 8
      src/ImageSharp/Processing/Transforms/Transform.cs

6
src/ImageSharp/Processing/Processors/Transforms/CenteredNonAffineTransformProcessor.cs → src/ImageSharp/Processing/Processors/Transforms/CenteredProjectiveTransformProcessor.cs

@ -11,15 +11,15 @@ namespace SixLabors.ImageSharp.Processing.Processors
/// A base class that provides methods to allow the automatic centering of non-affine transforms
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal abstract class CenteredNonAffineTransformProcessor<TPixel> : NonAffineTransformProcessor<TPixel>
internal abstract class CenteredProjectiveTransformProcessor<TPixel> : ProjectiveTransformProcessor<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Initializes a new instance of the <see cref="CenteredNonAffineTransformProcessor{TPixel}"/> class.
/// Initializes a new instance of the <see cref="CenteredProjectiveTransformProcessor{TPixel}"/> class.
/// </summary>
/// <param name="matrix">The transform matrix</param>
/// <param name="sampler">The sampler to perform the transform operation.</param>
protected CenteredNonAffineTransformProcessor(Matrix4x4 matrix, IResampler sampler)
protected CenteredProjectiveTransformProcessor(Matrix4x4 matrix, IResampler sampler)
: base(matrix, sampler)
{
}

15
src/ImageSharp/Processing/Processors/Transforms/NonAffineTransformProcessor.cs → src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs

@ -16,39 +16,40 @@ namespace SixLabors.ImageSharp.Processing.Processors
{
/// <summary>
/// Provides the base methods to perform non-affine transforms on an image.
/// TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal class NonAffineTransformProcessor<TPixel> : InterpolatedTransformProcessorBase<TPixel>
internal class ProjectiveTransformProcessor<TPixel> : InterpolatedTransformProcessorBase<TPixel>
where TPixel : struct, IPixel<TPixel>
{
private Rectangle targetRectangle;
/// <summary>
/// Initializes a new instance of the <see cref="NonAffineTransformProcessor{TPixel}"/> class.
/// Initializes a new instance of the <see cref="ProjectiveTransformProcessor{TPixel}"/> class.
/// </summary>
/// <param name="matrix">The transform matrix</param>
public NonAffineTransformProcessor(Matrix4x4 matrix)
public ProjectiveTransformProcessor(Matrix4x4 matrix)
: this(matrix, KnownResamplers.Bicubic)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="NonAffineTransformProcessor{TPixel}"/> class.
/// Initializes a new instance of the <see cref="ProjectiveTransformProcessor{TPixel}"/> class.
/// </summary>
/// <param name="matrix">The transform matrix</param>
/// <param name="sampler">The sampler to perform the transform operation.</param>
public NonAffineTransformProcessor(Matrix4x4 matrix, IResampler sampler)
public ProjectiveTransformProcessor(Matrix4x4 matrix, IResampler sampler)
: this(matrix, sampler, Rectangle.Empty)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="NonAffineTransformProcessor{TPixel}"/> class.
/// Initializes a new instance of the <see cref="ProjectiveTransformProcessor{TPixel}"/> class.
/// </summary>
/// <param name="matrix">The transform matrix</param>
/// <param name="sampler">The sampler to perform the transform operation.</param>
/// <param name="rectangle">The rectangle to constrain the transformed image to.</param>
public NonAffineTransformProcessor(Matrix4x4 matrix, IResampler sampler, Rectangle rectangle)
public ProjectiveTransformProcessor(Matrix4x4 matrix, IResampler sampler, Rectangle rectangle)
: base(sampler)
{
// Tansforms are inverted else the output is the opposite of the expected.

8
src/ImageSharp/Processing/Transforms/Transform.cs

@ -89,7 +89,8 @@ namespace SixLabors.ImageSharp
=> Transform(source, matrix, KnownResamplers.NearestNeighbor);
/// <summary>
/// Transforms an image by the given matrix using the specified sampling algorithm.
/// Applies a projective transform to the image by the given matrix using the specified sampling algorithm.
/// TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to transform.</param>
@ -101,7 +102,8 @@ namespace SixLabors.ImageSharp
=> Transform(source, matrix, sampler, Rectangle.Empty);
/// <summary>
/// Transforms an image by the given matrix using the specified sampling algorithm.
/// Applies a projective transform to the image by the given matrix using the specified sampling algorithm.
/// TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to transform.</param>
@ -111,6 +113,6 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel}"/></returns>
internal static IImageProcessingContext<TPixel> Transform<TPixel>(this IImageProcessingContext<TPixel> source, Matrix4x4 matrix, IResampler sampler, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new NonAffineTransformProcessor<TPixel>(matrix, sampler, rectangle));
=> source.ApplyProcessor(new ProjectiveTransformProcessor<TPixel>(matrix, sampler, rectangle));
}
}
Loading…
Cancel
Save