diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieLabToCieXyzConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieLabToCieXyzConverter.cs
index 75689d997c..0a5ae3627e 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieLabToCieXyzConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieLabToCieXyzConverter.cs
@@ -1,8 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLabColorSapce
{
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieXyzToCieLabConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieXyzToCieLabConverter.cs
index 33a8dc7c8d..22308260c2 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieXyzToCieLabConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieXyzToCieLabConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CIeLchToCieLabConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CIeLchToCieLabConverter.cs
index 3884d9480a..35fae30e83 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CIeLchToCieLabConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CIeLchToCieLabConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
@@ -20,7 +21,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchColor
// Conversion algorithm described here:
// https://en.wikipedia.org/wiki/Lab_color_space#Cylindrical_representation:_CIELCh_or_CIEHLC
float l = input.L, c = input.C, hDegrees = input.H;
- float hRadians = MathF.DegreeToRadian(hDegrees);
+ float hRadians = MathFExtensions.DegreeToRadian(hDegrees);
float a = c * MathF.Cos(hRadians);
float b = c * MathF.Sin(hRadians);
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CieLabToCieLchConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CieLabToCieLchConverter.cs
index 50332ebdcf..aa4614f9ca 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CieLabToCieLchConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CieLabToCieLchConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
@@ -22,7 +23,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchColor
float l = input.L, a = input.A, b = input.B;
float c = MathF.Sqrt((a * a) + (b * b));
float hRadians = MathF.Atan2(b, a);
- float hDegrees = MathF.RadianToDegree(hRadians);
+ float hDegrees = MathFExtensions.RadianToDegree(hRadians);
// Wrap the angle round at 360.
hDegrees = hDegrees % 360;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLchuvToCieLuvConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLchuvToCieLuvConverter.cs
index ceadb01957..fc6554a905 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLchuvToCieLuvConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLchuvToCieLuvConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
@@ -20,7 +21,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchuvCol
// Conversion algorithm described here:
// https://en.wikipedia.org/wiki/CIELUV#Cylindrical_representation_.28CIELCH.29
float l = input.L, c = input.C, hDegrees = input.H;
- float hRadians = MathF.DegreeToRadian(hDegrees);
+ float hRadians = MathFExtensions.DegreeToRadian(hDegrees);
float u = c * MathF.Cos(hRadians);
float v = c * MathF.Sin(hRadians);
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLuvToCieLchuvConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLuvToCieLchuvConverter.cs
index d301519208..f0d7a80a22 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLuvToCieLchuvConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLuvToCieLchuvConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
@@ -22,7 +23,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchuvCol
float l = input.L, a = input.U, b = input.V;
float c = MathF.Sqrt((a * a) + (b * b));
float hRadians = MathF.Atan2(b, a);
- float hDegrees = MathF.RadianToDegree(hRadians);
+ float hDegrees = MathFExtensions.RadianToDegree(hRadians);
// Wrap the angle round at 360.
hDegrees = hDegrees % 360;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieLuvToCieXyzConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieLuvToCieXyzConverter.cs
index 4fb8fdc809..50e8335ed6 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieLuvToCieXyzConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieLuvToCieXyzConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieXyzToCieLuvConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieXyzToCieLuvConverter.cs
index 82b1b1d3f7..709d8d426e 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieXyzToCieLuvConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieXyzToCieLuvConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs
index 31868ec11a..64fc84b1d4 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs
index 917cd3bf8a..3de3baddd3 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs
index 8905a0a30f..7faf03c9a1 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs
index 2cd379d853..7e7c536e3f 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LCompanding.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LCompanding.cs
index c73a3486ed..132861b476 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LCompanding.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LCompanding.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSapce
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/Rec2020Companding.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/Rec2020Companding.cs
index f393b133ce..11761f0e4d 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/Rec2020Companding.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/Rec2020Companding.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSapce
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/Rec709Companding.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/Rec709Companding.cs
index ba1b1379ef..ccda6bf521 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/Rec709Companding.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/Rec709Companding.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSapce
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/SRgbCompanding.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/SRgbCompanding.cs
index 1e49c11591..ce8ea7c6e5 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/SRgbCompanding.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/SRgbCompanding.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSapce
diff --git a/src/ImageSharp/Common/Extensions/Vector4Extensions.cs b/src/ImageSharp/Common/Extensions/Vector4Extensions.cs
index 5fbc3960a3..7cb193e828 100644
--- a/src/ImageSharp/Common/Extensions/Vector4Extensions.cs
+++ b/src/ImageSharp/Common/Extensions/Vector4Extensions.cs
@@ -1,9 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Numerics;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs
index 8717fa9876..7d781e77fe 100644
--- a/src/ImageSharp/Common/Helpers/ImageMaths.cs
+++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs
@@ -64,6 +64,27 @@ namespace SixLabors.ImageSharp
return left * right;
}
+ ///
+ /// Returns the result of a normalized sine cardinal function for the given value.
+ /// SinC(x) = sin(pi*x)/(pi*x).
+ ///
+ /// A single-precision floating-point number to calculate the result for.
+ ///
+ /// The sine cardinal of .
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static float SinC(float f)
+ {
+ if (MathF.Abs(f) > Constants.Epsilon)
+ {
+ f *= MathF.PI;
+ float result = MathF.Sin(f) / f;
+ return MathF.Abs(result) < Constants.Epsilon ? 0F : result;
+ }
+
+ return 1F;
+ }
+
///
/// Returns the result of a B-C filter against the given value.
///
diff --git a/src/ImageSharp/Common/Helpers/MathF.cs b/src/ImageSharp/Common/Helpers/MathF.cs
deleted file mode 100644
index 7d2f8063fa..0000000000
--- a/src/ImageSharp/Common/Helpers/MathF.cs
+++ /dev/null
@@ -1,291 +0,0 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using System;
-using System.Runtime.CompilerServices;
-
-namespace SixLabors.ImageSharp
-{
- ///
- /// Provides single-precision floating point constants and static methods for trigonometric, logarithmic, and other common mathematical functions.
- ///
- // ReSharper disable InconsistentNaming
- internal static class MathF
- {
- ///
- /// Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π.
- ///
- public const float PI = (float)Math.PI;
-
- ///
- /// Returns the absolute value of a single-precision floating-point number.
- ///
- ///
- /// A number that is greater than or equal to , but less than or equal to .
- ///
- ///
- /// A single-precision floating-point number, x, such that 0 ≤ x ≤.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Abs(float f)
- {
- return Math.Abs(f);
- }
-
- ///
- /// Returns the angle whose tangent is the quotient of two specified numbers.
- ///
- /// The y coordinate of a point.
- /// The x coordinate of a point.
- ///
- /// An angle, θ, measured in radians, such that -π≤θ≤π, and tan(θ) = y / x, where
- /// (x, y) is a point in the Cartesian plane. Observe the following: For (x, y) in
- /// quadrant 1, 0 < θ < π/2.For (x, y) in quadrant 2, π/2 < θ≤π.For (x, y) in quadrant
- /// 3, -π < θ < -π/2.For (x, y) in quadrant 4, -π/2 < θ < 0.For points on the boundaries
- /// of the quadrants, the return value is the following:If y is 0 and x is not negative,
- /// θ = 0.If y is 0 and x is negative, θ = π.If y is positive and x is 0, θ = π/2.If
- /// y is negative and x is 0, θ = -π/2.If y is 0 and x is 0, θ = 0. If x or y is
- /// , or if x and y are either or
- /// , the method returns .
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Atan2(float y, float x)
- {
- return (float)Math.Atan2(y, x);
- }
-
- ///
- /// Returns the smallest integral value that is greater than or equal to the specified single-precision floating-point number.
- ///
- /// A single-precision floating-point number.
- ///
- /// The smallest integral value that is greater than or equal to .
- /// If is equal to , ,
- /// or , that value is returned.
- /// Note that this method returns a instead of an integral type.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Ceiling(float f)
- {
- return (float)Math.Ceiling(f);
- }
-
- ///
- /// Returns the cosine of the specified angle.
- ///
- /// An angle, measured in radians.
- ///
- /// The cosine of . If is equal to , ,
- /// or , this method returns .
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Cos(float f)
- {
- return (float)Math.Cos(f);
- }
-
- ///
- /// Converts a degree (360-periodic) angle to a radian (2*Pi-periodic) angle.
- ///
- /// The angle in degrees.
- ///
- /// The representing the degree as radians.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float DegreeToRadian(float degree)
- {
- return degree * (PI / 180F);
- }
-
- ///
- /// Returns e raised to the specified power.
- ///
- /// A number specifying a power.
- ///
- /// The number e raised to the power .
- /// If equals or , that value is returned.
- /// If equals , 0 is returned.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Exp(float f)
- {
- return (float)Math.Exp(f);
- }
-
- ///
- /// Returns the largest integer less than or equal to the specified single-precision floating-point number.
- ///
- /// A single-precision floating-point number.
- ///
- /// The largest integer less than or equal to .
- /// If is equal to , ,
- /// or , that value is returned.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Floor(float f)
- {
- return (float)Math.Floor(f);
- }
-
- ///
- /// Returns the larger of two single-precision floating-point numbers.
- ///
- /// The first of two single-precision floating-point numbers to compare.
- /// The second of two single-precision floating-point numbers to compare.
- ///
- /// Parameter or , whichever is larger.
- /// If , or , or both and are
- /// equal to , is returned.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Max(float val1, float val2)
- {
- return Math.Max(val1, val2);
- }
-
- ///
- /// Returns the smaller of two single-precision floating-point numbers.
- ///
- /// The first of two single-precision floating-point numbers to compare.
- /// The second of two single-precision floating-point numbers to compare.
- ///
- /// Parameter or , whichever is smaller.
- /// If , , or both and are equal
- /// to , is returned.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Min(float val1, float val2)
- {
- return Math.Min(val1, val2);
- }
-
- ///
- /// Returns a specified number raised to the specified power.
- ///
- /// A single-precision floating-point number to be raised to a power.
- /// A single-precision floating-point number that specifies a power.
- /// The number raised to the power .
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Pow(float x, float y)
- {
- return (float)Math.Pow(x, y);
- }
-
- ///
- /// Converts a radian (2*Pi-periodic) angle to a degree (360-periodic) angle.
- ///
- /// The angle in radians.
- ///
- /// The representing the degree as radians.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float RadianToDegree(float radian)
- {
- return radian / (PI / 180F);
- }
-
- ///
- /// Rounds a single-precision floating-point value to the nearest integral value.
- ///
- /// A single-precision floating-point number to be rounded.
- ///
- /// The integer nearest .
- /// If the fractional component of is halfway between two integers, one of which is even and the other odd, then the even number is returned.
- /// Note that this method returns a instead of an integral type.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Round(float f)
- {
- return (float)Math.Round(f);
- }
-
- ///
- /// Rounds a single-precision floating-point value to the nearest integer.
- /// A parameter specifies how to round the value if it is midway between two numbers.
- ///
- /// A single-precision floating-point number to be rounded.
- /// Specification for how to round if it is midway between two other numbers.
- ///
- /// The integer nearest . If is halfway between two integers, one of which is even
- /// and the other odd, then determines which of the two is returned.
- /// Note that this method returns a instead of an integral type.
- ///
- ///
- /// is not a valid value of .
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Round(float f, MidpointRounding mode)
- {
- return (float)Math.Round(f, mode);
- }
-
- ///
- /// Returns the sine of the specified angle.
- ///
- /// An angle, measured in radians.
- ///
- /// The sine of .
- /// If is equal to , ,
- /// or , this method returns .
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Sin(float f)
- {
- return (float)Math.Sin(f);
- }
-
- ///
- /// Returns the result of a normalized sine cardinal function for the given value.
- /// SinC(x) = sin(pi*x)/(pi*x).
- ///
- /// A single-precision floating-point number to calculate the result for.
- ///
- /// The sine cardinal of .
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float SinC(float f)
- {
- if (Abs(f) > Constants.Epsilon)
- {
- f *= PI;
- return Clean(Sin(f) / f);
- }
-
- return 1F;
- }
-
- ///
- /// Returns the square root of a specified number.
- ///
- /// The number whose square root is to be found.
- ///
- /// One of the values in the following table.
- /// parameter Return value Zero or positive The positive square root of .
- /// Negative Equals
- /// Equals
- ///
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float Sqrt(float f)
- {
- return (float)Math.Sqrt(f);
- }
-
- ///
- /// Ensures that any passed float is correctly rounded to zero
- ///
- /// The value to clean.
- ///
- /// The
- /// .
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static float Clean(float x)
- {
- if (Abs(x) < Constants.Epsilon)
- {
- return 0F;
- }
-
- return x;
- }
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp/Formats/Jpeg/Common/SizeExtensions.cs b/src/ImageSharp/Formats/Jpeg/Common/SizeExtensions.cs
index f6b02bbaf5..978688673f 100644
--- a/src/ImageSharp/Formats/Jpeg/Common/SizeExtensions.cs
+++ b/src/ImageSharp/Formats/Jpeg/Common/SizeExtensions.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Numerics;
using SixLabors.Primitives;
diff --git a/src/ImageSharp/Image/PixelAccessorExtensions.cs b/src/ImageSharp/Image/PixelAccessorExtensions.cs
index 9146ef48da..b628c05f8b 100644
--- a/src/ImageSharp/Image/PixelAccessorExtensions.cs
+++ b/src/ImageSharp/Image/PixelAccessorExtensions.cs
@@ -1,14 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
-using Unsafe = System.Runtime.CompilerServices.Unsafe;
namespace SixLabors.ImageSharp
{
diff --git a/src/ImageSharp/Image/PixelAccessor{TPixel}.cs b/src/ImageSharp/Image/PixelAccessor{TPixel}.cs
index 3abe28aca0..8dcb1f7602 100644
--- a/src/ImageSharp/Image/PixelAccessor{TPixel}.cs
+++ b/src/ImageSharp/Image/PixelAccessor{TPixel}.cs
@@ -7,7 +7,6 @@ using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
-using Unsafe = System.Runtime.CompilerServices.Unsafe;
namespace SixLabors.ImageSharp
{
diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj
index 45d0a70b81..8c22237cf7 100644
--- a/src/ImageSharp/ImageSharp.csproj
+++ b/src/ImageSharp/ImageSharp.csproj
@@ -1,118 +1,120 @@
-
- A cross-platform library for the processing of image files; written in C#
- SixLabors.ImageSharp
- $(packageversion)
- 0.0.1
- Six Labors and contributors
- netstandard1.1;netstandard1.3
- true
- true
- SixLabors.ImageSharp
- SixLabors.ImageSharp
- Image Resize Crop Gif Jpg Jpeg Bitmap Png Core
- https://raw.githubusercontent.com/SixLabors/ImageSharp/master/build/icons/imagesharp-logo-128.png
- https://github.com/SixLabors/ImageSharp
- http://www.apache.org/licenses/LICENSE-2.0
- git
- https://github.com/SixLabors/ImageSharp
- false
- false
- false
- false
- false
- false
- false
- false
- false
- full
- portable
- True
- IOperation
-
-
-
-
-
-
-
-
- All
-
-
-
-
-
-
-
-
-
-
- ..\..\ImageSharp.ruleset
- SixLabors.ImageSharp
-
-
- true
-
-
-
- TextTemplatingFileGenerator
- Block8x8F.Generated.cs
-
-
- TextTemplatingFileGenerator
- Block8x8F.Generated.cs
-
-
- TextTemplatingFileGenerator
- PixelOperations{TPixel}.Generated.cs
-
-
- TextTemplatingFileGenerator
- Rgba32.PixelOperations.Generated.cs
-
-
- PorterDuffFunctions.Generated.cs
- TextTemplatingFileGenerator
-
-
- DefaultPixelBlenders.Generated.cs
- TextTemplatingFileGenerator
-
-
-
-
-
-
-
- True
- True
- Block8x8F.Generated.tt
-
-
- True
- True
- Block8x8F.Generated.tt
-
-
- True
- True
- PixelOperations{TPixel}.Generated.tt
-
-
- True
- True
- Rgba32.PixelOperations.Generated.tt
-
-
- True
- True
- DefaultPixelBlenders.Generated.tt
-
-
- True
- True
- PorterDuffFunctions.Generated.tt
-
-
+
+ A cross-platform library for the processing of image files; written in C#
+ SixLabors.ImageSharp
+ $(packageversion)
+ 0.0.1
+ Six Labors and contributors
+ netstandard1.1;netstandard1.3;netstandard2.0
+ true
+ true
+ SixLabors.ImageSharp
+ SixLabors.ImageSharp
+ Image Resize Crop Gif Jpg Jpeg Bitmap Png Core
+ https://raw.githubusercontent.com/SixLabors/ImageSharp/master/build/icons/imagesharp-logo-128.png
+ https://github.com/SixLabors/ImageSharp
+ http://www.apache.org/licenses/LICENSE-2.0
+ git
+ https://github.com/SixLabors/ImageSharp
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ full
+ portable
+ True
+ IOperation
+
+
+
+
+
+
+
+
+ All
+
+
+
+
+
+
+
+
+
+
+
+
+ ..\..\ImageSharp.ruleset
+ SixLabors.ImageSharp
+
+
+ true
+
+
+
+ TextTemplatingFileGenerator
+ Block8x8F.Generated.cs
+
+
+ TextTemplatingFileGenerator
+ Block8x8F.Generated.cs
+
+
+ TextTemplatingFileGenerator
+ PixelOperations{TPixel}.Generated.cs
+
+
+ TextTemplatingFileGenerator
+ Rgba32.PixelOperations.Generated.cs
+
+
+ PorterDuffFunctions.Generated.cs
+ TextTemplatingFileGenerator
+
+
+ DefaultPixelBlenders.Generated.cs
+ TextTemplatingFileGenerator
+
+
+
+
+
+
+
+ True
+ True
+ Block8x8F.Generated.tt
+
+
+ True
+ True
+ Block8x8F.Generated.tt
+
+
+ True
+ True
+ PixelOperations{TPixel}.Generated.tt
+
+
+ True
+ True
+ Rgba32.PixelOperations.Generated.tt
+
+
+ True
+ True
+ DefaultPixelBlenders.Generated.tt
+
+
+ True
+ True
+ PorterDuffFunctions.Generated.tt
+
+
\ No newline at end of file
diff --git a/src/ImageSharp/Memory/SpanHelper.cs b/src/ImageSharp/Memory/SpanHelper.cs
index 8b9fad5222..73bc5f55d8 100644
--- a/src/ImageSharp/Memory/SpanHelper.cs
+++ b/src/ImageSharp/Memory/SpanHelper.cs
@@ -4,7 +4,6 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
-using Unsafe = System.Runtime.CompilerServices.Unsafe;
namespace SixLabors.ImageSharp.Memory
{
diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs
index efdd275b44..21ae335bee 100644
--- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs
@@ -2,11 +2,13 @@
// Licensed under the Apache License, Version 2.0.
//
+
+using System;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+
namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
{
- using System.Numerics;
- using System.Runtime.CompilerServices;
-
internal static partial class PorterDuffFunctions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt
index e6a2ca3ebe..c92ab6dd62 100644
--- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt
@@ -12,11 +12,13 @@
// Licensed under the Apache License, Version 2.0.
//
+
+using System;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+
namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
{
- using System.Numerics;
- using System.Runtime.CompilerServices;
-
internal static partial class PorterDuffFunctions
{
<#
diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs
index 04c750255f..f09d6d51ca 100644
--- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs
+++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Numerics;
using System.Runtime.CompilerServices;
diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs
index 9a40bfca89..adfdb6a788 100644
--- a/src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
@@ -30,7 +31,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
this.Angle = angle;
- float radians = MathF.DegreeToRadian(angle);
+ float radians = MathFExtensions.DegreeToRadian(angle);
float cosradians = MathF.Cos(radians);
float sinradians = MathF.Sin(radians);
diff --git a/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs b/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs
index 152b451e29..17a0cc428f 100644
--- a/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs
+++ b/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using System.Linq;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs
index deaa0ccb95..29568db021 100644
--- a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs
+++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs
@@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing
if (x < 2F)
{
- return MathF.SinC(x) * MathF.SinC(x / 2F);
+ return ImageMaths.SinC(x) * ImageMaths.SinC(x / 2F);
}
return 0F;
diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs
index 2673c34914..492ef69e4c 100644
--- a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs
+++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs
@@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing
if (x < 3F)
{
- return MathF.SinC(x) * MathF.SinC(x / 3F);
+ return ImageMaths.SinC(x) * ImageMaths.SinC(x / 3F);
}
return 0F;
diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs
index c52670e2d0..cae152a53c 100644
--- a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs
+++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs
@@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing
if (x < 5F)
{
- return MathF.SinC(x) * MathF.SinC(x / 5F);
+ return ImageMaths.SinC(x) * ImageMaths.SinC(x / 5F);
}
return 0F;
diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs
index 552d3065b4..b390c55419 100644
--- a/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs
+++ b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs
@@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing
if (x < 8F)
{
- return MathF.SinC(x) * MathF.SinC(x / 8F);
+ return ImageMaths.SinC(x) * ImageMaths.SinC(x / 8F);
}
return 0F;
diff --git a/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs
index e154d5483b..acb74a8ec4 100644
--- a/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs
+++ b/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs
@@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing
if (x < 3F)
{
- return MathF.SinC(x) * (1F - (x * x / 9F));
+ return ImageMaths.SinC(x) * (1F - (x * x / 9F));
}
return 0F;
diff --git a/src/ImageSharp/Processing/Transforms/Resize.cs b/src/ImageSharp/Processing/Transforms/Resize.cs
index 7897e8f30b..3c7cbca311 100644
--- a/src/ImageSharp/Processing/Transforms/Resize.cs
+++ b/src/ImageSharp/Processing/Transforms/Resize.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;