mirror of https://github.com/SixLabors/ImageSharp
Browse Source
Former-commit-id: 7190b01b85ed5933e0f5dd276b3eb718a8d78e30 Former-commit-id: 56df11ca6ffb6d0075115dc3b2c714317a379ab8 Former-commit-id: becd320711a19b21267790300429105e071fc5deaf/merge-core
2 changed files with 41 additions and 26 deletions
@ -0,0 +1,34 @@ |
|||
// <copyright file="Lanczos2Resampler.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessorCore |
|||
{ |
|||
/// <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 class Lanczos2Resampler : IResampler |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public float Radius => 2; |
|||
|
|||
/// <inheritdoc/>
|
|||
public float GetValue(float x) |
|||
{ |
|||
if (x < 0F) |
|||
{ |
|||
x = -x; |
|||
} |
|||
|
|||
if (x < 2F) |
|||
{ |
|||
return ImageMaths.SinC(x) * ImageMaths.SinC(x / 2F); |
|||
} |
|||
|
|||
return 0F; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue