Browse Source

better variable naming and docs

af/merge-core
Anton Firszov 8 years ago
parent
commit
f6bf0fef94
  1. 1
      src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs
  2. 18
      src/ImageSharp/Processing/Transforms/Transform.cs

1
src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor.cs

@ -22,6 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
internal class ProjectiveTransformProcessor<TPixel> : InterpolatedTransformProcessorBase<TPixel>
where TPixel : struct, IPixel<TPixel>
{
// TODO: We should use a Size instead! (See AffineTransformProcessor<T>)
private Rectangle targetRectangle;
/// <summary>

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

@ -38,34 +38,38 @@ namespace SixLabors.ImageSharp
=> Transform(source, matrix, sampler, Size.Empty);
/// <summary>
/// Transforms an image by the given matrix using the specified sampling algorithm.
/// Transforms an image by the given matrix using the specified sampling algorithm
/// and a rectangle defining the transform origin in the source image and the size of the result image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to transform.</param>
/// <param name="matrix">The transformation matrix.</param>
/// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
/// <param name="sourceRectangle">The rectangle defining the source pixel area to transform. 'sourceRectangle.Location' becomes the origo of the transformed image.</param>
/// <param name="rectangle">
/// The rectangle defining the transform origin in the source image, and the size of the result image.
/// </param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Transform<TPixel>(
this IImageProcessingContext<TPixel> source,
Matrix3x2 matrix,
IResampler sampler,
Rectangle sourceRectangle)
Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{
var t = Matrix3x2.CreateTranslation(-sourceRectangle.Location);
var t = Matrix3x2.CreateTranslation(-rectangle.Location);
Matrix3x2 combinedMatrix = t * matrix;
return source.ApplyProcessor(new AffineTransformProcessor<TPixel>(combinedMatrix, sampler, sourceRectangle.Size));
return source.ApplyProcessor(new AffineTransformProcessor<TPixel>(combinedMatrix, sampler, rectangle.Size));
}
/// <summary>
/// Transforms an image by the given matrix using the specified sampling algorithm.
/// Transforms an image by the given matrix using the specified sampling algorithm,
/// cropping or extending the image according to <paramref name="destinationSize"/>.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to transform.</param>
/// <param name="matrix">The transformation matrix.</param>
/// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
/// <param name="destinationSize">The dimensions to constrain the transformed image to.</param>
/// <param name="destinationSize">The size of the destination image.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Transform<TPixel>(
this IImageProcessingContext<TPixel> source,

Loading…
Cancel
Save