mirror of https://github.com/SixLabors/ImageSharp
13 changed files with 196 additions and 752 deletions
@ -1,77 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|||
{ |
|||
/// <summary>
|
|||
/// The Catmull-Rom filter is a well known standard Cubic Filter often used as a interpolation function.
|
|||
/// This filter produces a reasonably sharp edge, but without a the pronounced gradient change on large
|
|||
/// scale image enlargements that a 'Lagrange' filter can produce.
|
|||
/// <see href="http://www.imagemagick.org/Usage/filter/#cubic_bc"/>
|
|||
/// </summary>
|
|||
public readonly struct CatmullRomResampler : IResampler |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public float Radius => 2; |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public float GetValue(float x) |
|||
{ |
|||
const float B = 0; |
|||
const float C = 0.5F; |
|||
|
|||
return ImageMaths.GetBcValue(x, B, C); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyResizeTransform<TPixel>( |
|||
Configuration configuration, |
|||
Image<TPixel> source, |
|||
Image<TPixel> destination, |
|||
Rectangle sourceRectangle, |
|||
Rectangle destinationRectangle, |
|||
bool compand) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyResizeTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
sourceRectangle, |
|||
destinationRectangle, |
|||
compand); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyAffineTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix3x2 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyAffineTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyProjectiveTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix4x4 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyProjectiveTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
} |
|||
} |
|||
@ -0,0 +1,153 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|||
{ |
|||
/// <summary>
|
|||
/// Cubic filters contain a collection of different filters of varying B-Spline and
|
|||
/// Cardinal values. With these two values you can generate any smoothly fitting
|
|||
/// (continuious first derivative) piece-wise cubic filter.
|
|||
/// <see href="http://www.imagemagick.org/Usage/filter/#cubic_bc"/>
|
|||
/// <see href="https://www.cs.utexas.edu/~fussell/courses/cs384g-fall2013/lectures/mitchell/Mitchell.pdf"/>
|
|||
/// </summary>
|
|||
public readonly struct CubicResampler : IResampler |
|||
{ |
|||
private readonly float bspline; |
|||
private readonly float cardinal; |
|||
|
|||
/// <summary>
|
|||
/// The Catmull-Rom filter is a well known standard Cubic Filter often used as a interpolation function.
|
|||
/// This filter produces a reasonably sharp edge, but without a the pronounced gradient change on large
|
|||
/// scale image enlargements that a 'Lagrange' filter can produce.
|
|||
/// </summary>
|
|||
public static CubicResampler CatmullRom = new CubicResampler(2, 0, .5F); |
|||
|
|||
/// <summary>
|
|||
/// The Hermite filter is type of smoothed triangular interpolation Filter,
|
|||
/// This filter rounds off strong edges while preserving flat 'color levels' in the original image.
|
|||
/// </summary>
|
|||
public static CubicResampler Hermite = new CubicResampler(2, 0, 0); |
|||
|
|||
/// <summary>
|
|||
/// The function implements the Mitchell-Netravali algorithm as described on
|
|||
/// <see href="https://de.wikipedia.org/wiki/Mitchell-Netravali-Filter">Wikipedia</see>
|
|||
/// </summary>
|
|||
public static CubicResampler MitchellNetravali = new CubicResampler(2, .3333333F, .3333333F); |
|||
|
|||
/// <summary>
|
|||
/// The function implements the Robidoux algorithm.
|
|||
/// <see href="http://www.imagemagick.org/Usage/filter/#robidoux"/>
|
|||
/// </summary>
|
|||
public static CubicResampler Robidoux = new CubicResampler(2, .37821575509399867F, .31089212245300067F); |
|||
|
|||
/// <summary>
|
|||
/// The function implements the Robidoux Sharp algorithm.
|
|||
/// <see href="http://www.imagemagick.org/Usage/filter/#robidoux"/>
|
|||
/// </summary>
|
|||
public static CubicResampler RobidouxSharp = new CubicResampler(2, .2620145123990142F, .3689927438004929F); |
|||
|
|||
/// <summary>
|
|||
/// The function implements the spline algorithm.
|
|||
/// <see href="http://www.imagemagick.org/Usage/filter/#cubic_bc"/>
|
|||
/// </summary>
|
|||
/// <summary>
|
|||
/// The function implements the Robidoux Sharp algorithm.
|
|||
/// <see href="http://www.imagemagick.org/Usage/filter/#robidoux"/>
|
|||
/// </summary>
|
|||
public static CubicResampler Spline = new CubicResampler(2, 1, 0); |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="CubicResampler"/> struct.
|
|||
/// </summary>
|
|||
/// <param name="radius">The sampling radius.</param>
|
|||
/// <param name="bspline">The B-Spline value.</param>
|
|||
/// <param name="cardinal">The Cardinal cubic value.</param>
|
|||
public CubicResampler(float radius, float bspline, float cardinal) |
|||
{ |
|||
this.Radius = radius; |
|||
this.bspline = bspline; |
|||
this.cardinal = cardinal; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public float Radius { get; } |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public float GetValue(float x) |
|||
{ |
|||
float b = this.bspline; |
|||
float c = this.cardinal; |
|||
|
|||
if (x < 0F) |
|||
{ |
|||
x = -x; |
|||
} |
|||
|
|||
float temp = x * x; |
|||
if (x < 1F) |
|||
{ |
|||
x = ((12 - (9 * b) - (6 * c)) * (x * temp)) + ((-18 + (12 * b) + (6 * c)) * temp) + (6 - (2 * b)); |
|||
return x / 6F; |
|||
} |
|||
|
|||
if (x < 2F) |
|||
{ |
|||
x = ((-b - (6 * c)) * (x * temp)) + (((6 * b) + (30 * c)) * temp) + (((-12 * b) - (48 * c)) * x) + ((8 * b) + (24 * c)); |
|||
return x / 6F; |
|||
} |
|||
|
|||
return 0F; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyResizeTransform<TPixel>( |
|||
Configuration configuration, |
|||
Image<TPixel> source, |
|||
Image<TPixel> destination, |
|||
Rectangle sourceRectangle, |
|||
Rectangle destinationRectangle, |
|||
bool compand) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyResizeTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
sourceRectangle, |
|||
destinationRectangle, |
|||
compand); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyAffineTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix3x2 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyAffineTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyProjectiveTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix4x4 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyProjectiveTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
} |
|||
} |
|||
@ -1,76 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|||
{ |
|||
/// <summary>
|
|||
/// The Hermite filter is type of smoothed triangular interpolation Filter,
|
|||
/// This filter rounds off strong edges while preserving flat 'color levels' in the original image.
|
|||
/// <see href="http://www.imagemagick.org/Usage/filter/#cubic_bc"/>
|
|||
/// </summary>
|
|||
public readonly struct HermiteResampler : IResampler |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public float Radius => 2; |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public float GetValue(float x) |
|||
{ |
|||
const float B = 0F; |
|||
const float C = 0F; |
|||
|
|||
return ImageMaths.GetBcValue(x, B, C); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyResizeTransform<TPixel>( |
|||
Configuration configuration, |
|||
Image<TPixel> source, |
|||
Image<TPixel> destination, |
|||
Rectangle sourceRectangle, |
|||
Rectangle destinationRectangle, |
|||
bool compand) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyResizeTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
sourceRectangle, |
|||
destinationRectangle, |
|||
compand); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyAffineTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix3x2 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyAffineTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyProjectiveTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix4x4 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyProjectiveTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
} |
|||
} |
|||
@ -1,83 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|||
{ |
|||
/// <summary>
|
|||
/// The function implements the Lanczos kernel algorithm as described on
|
|||
/// <see href="https://en.wikipedia.org/wiki/Lanczos_resampling#Algorithm">Wikipedia</see>
|
|||
/// with a radius of 2 pixels.
|
|||
/// </summary>
|
|||
public readonly struct Lanczos2Resampler : IResampler |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public float Radius => 2; |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public float GetValue(float x) |
|||
{ |
|||
if (x < 0F) |
|||
{ |
|||
x = -x; |
|||
} |
|||
|
|||
if (x < 2F) |
|||
{ |
|||
return ImageMaths.SinC(x) * ImageMaths.SinC(x / 2F); |
|||
} |
|||
|
|||
return 0F; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyResizeTransform<TPixel>( |
|||
Configuration configuration, |
|||
Image<TPixel> source, |
|||
Image<TPixel> destination, |
|||
Rectangle sourceRectangle, |
|||
Rectangle destinationRectangle, |
|||
bool compand) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyResizeTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
sourceRectangle, |
|||
destinationRectangle, |
|||
compand); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyAffineTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix3x2 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyAffineTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyProjectiveTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix4x4 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyProjectiveTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
} |
|||
} |
|||
@ -1,83 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|||
{ |
|||
/// <summary>
|
|||
/// The function implements the Lanczos kernel algorithm as described on
|
|||
/// <see href="https://en.wikipedia.org/wiki/Lanczos_resampling#Algorithm">Wikipedia</see>
|
|||
/// with a radius of 3 pixels.
|
|||
/// </summary>
|
|||
public readonly struct Lanczos3Resampler : IResampler |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public float Radius => 3; |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public float GetValue(float x) |
|||
{ |
|||
if (x < 0F) |
|||
{ |
|||
x = -x; |
|||
} |
|||
|
|||
if (x < 3F) |
|||
{ |
|||
return ImageMaths.SinC(x) * ImageMaths.SinC(x / 3F); |
|||
} |
|||
|
|||
return 0F; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyResizeTransform<TPixel>( |
|||
Configuration configuration, |
|||
Image<TPixel> source, |
|||
Image<TPixel> destination, |
|||
Rectangle sourceRectangle, |
|||
Rectangle destinationRectangle, |
|||
bool compand) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyResizeTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
sourceRectangle, |
|||
destinationRectangle, |
|||
compand); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyAffineTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix3x2 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyAffineTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyProjectiveTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix4x4 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyProjectiveTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
} |
|||
} |
|||
@ -1,83 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|||
{ |
|||
/// <summary>
|
|||
/// The function implements the Lanczos kernel algorithm as described on
|
|||
/// <see href="https://en.wikipedia.org/wiki/Lanczos_resampling#Algorithm">Wikipedia</see>
|
|||
/// with a radius of 8 pixels.
|
|||
/// </summary>
|
|||
public readonly struct Lanczos8Resampler : IResampler |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public float Radius => 8; |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public float GetValue(float x) |
|||
{ |
|||
if (x < 0F) |
|||
{ |
|||
x = -x; |
|||
} |
|||
|
|||
if (x < 8F) |
|||
{ |
|||
return ImageMaths.SinC(x) * ImageMaths.SinC(x / 8F); |
|||
} |
|||
|
|||
return 0F; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyResizeTransform<TPixel>( |
|||
Configuration configuration, |
|||
Image<TPixel> source, |
|||
Image<TPixel> destination, |
|||
Rectangle sourceRectangle, |
|||
Rectangle destinationRectangle, |
|||
bool compand) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyResizeTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
sourceRectangle, |
|||
destinationRectangle, |
|||
compand); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyAffineTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix3x2 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyAffineTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyProjectiveTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix4x4 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyProjectiveTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
} |
|||
} |
|||
@ -1,74 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|||
{ |
|||
/// <summary>
|
|||
/// The function implements the mitchell algorithm as described on
|
|||
/// <see href="https://de.wikipedia.org/wiki/Mitchell-Netravali-Filter">Wikipedia</see>
|
|||
/// </summary>
|
|||
public readonly struct MitchellNetravaliResampler : IResampler |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public float Radius => 2; |
|||
|
|||
/// <inheritdoc/>
|
|||
public float GetValue(float x) |
|||
{ |
|||
const float B = 0.3333333F; |
|||
const float C = 0.3333333F; |
|||
|
|||
return ImageMaths.GetBcValue(x, B, C); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyResizeTransform<TPixel>( |
|||
Configuration configuration, |
|||
Image<TPixel> source, |
|||
Image<TPixel> destination, |
|||
Rectangle sourceRectangle, |
|||
Rectangle destinationRectangle, |
|||
bool compand) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyResizeTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
sourceRectangle, |
|||
destinationRectangle, |
|||
compand); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyAffineTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix3x2 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyAffineTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyProjectiveTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix4x4 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyProjectiveTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
} |
|||
} |
|||
@ -1,75 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|||
{ |
|||
/// <summary>
|
|||
/// The function implements the Robidoux algorithm.
|
|||
/// <see href="http://www.imagemagick.org/Usage/filter/#robidoux"/>
|
|||
/// </summary>
|
|||
public readonly struct RobidouxResampler : IResampler |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public float Radius => 2; |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public float GetValue(float x) |
|||
{ |
|||
const float B = 0.37821575509399867F; |
|||
const float C = 0.31089212245300067F; |
|||
|
|||
return ImageMaths.GetBcValue(x, B, C); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyResizeTransform<TPixel>( |
|||
Configuration configuration, |
|||
Image<TPixel> source, |
|||
Image<TPixel> destination, |
|||
Rectangle sourceRectangle, |
|||
Rectangle destinationRectangle, |
|||
bool compand) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyResizeTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
sourceRectangle, |
|||
destinationRectangle, |
|||
compand); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyAffineTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix3x2 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyAffineTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyProjectiveTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix4x4 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyProjectiveTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
} |
|||
} |
|||
@ -1,75 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|||
{ |
|||
/// <summary>
|
|||
/// The function implements the Robidoux Sharp algorithm.
|
|||
/// <see href="http://www.imagemagick.org/Usage/filter/#robidoux"/>
|
|||
/// </summary>
|
|||
public readonly struct RobidouxSharpResampler : IResampler |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public float Radius => 2; |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public float GetValue(float x) |
|||
{ |
|||
const float B = 0.2620145123990142F; |
|||
const float C = 0.3689927438004929F; |
|||
|
|||
return ImageMaths.GetBcValue(x, B, C); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyResizeTransform<TPixel>( |
|||
Configuration configuration, |
|||
Image<TPixel> source, |
|||
Image<TPixel> destination, |
|||
Rectangle sourceRectangle, |
|||
Rectangle destinationRectangle, |
|||
bool compand) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyResizeTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
sourceRectangle, |
|||
destinationRectangle, |
|||
compand); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyAffineTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix3x2 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyAffineTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyProjectiveTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix4x4 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyProjectiveTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
} |
|||
} |
|||
@ -1,75 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|||
{ |
|||
/// <summary>
|
|||
/// The function implements the spline algorithm.
|
|||
/// <see href="http://www.imagemagick.org/Usage/filter/#cubic_bc"/>
|
|||
/// </summary>
|
|||
public readonly struct SplineResampler : IResampler |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public float Radius => 2; |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public float GetValue(float x) |
|||
{ |
|||
const float B = 1F; |
|||
const float C = 0F; |
|||
|
|||
return ImageMaths.GetBcValue(x, B, C); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyResizeTransform<TPixel>( |
|||
Configuration configuration, |
|||
Image<TPixel> source, |
|||
Image<TPixel> destination, |
|||
Rectangle sourceRectangle, |
|||
Rectangle destinationRectangle, |
|||
bool compand) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyResizeTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
sourceRectangle, |
|||
destinationRectangle, |
|||
compand); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyAffineTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix3x2 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyAffineTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void ApplyProjectiveTransform<TPixel>( |
|||
Configuration configuration, |
|||
ImageFrame<TPixel> source, |
|||
ImageFrame<TPixel> destination, |
|||
Matrix4x4 matrix) |
|||
where TPixel : struct, IPixel<TPixel> => ResamplerExtensions.ApplyProjectiveTransform( |
|||
configuration, |
|||
in this, |
|||
source, |
|||
destination, |
|||
matrix); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue