diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 6045a9c6a4..eb3c29dd98 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -1,54 +1,54 @@  - - An extension to ImageSharp that allows the drawing of images, paths, and text. - SixLabors.ImageSharp.Drawing - $(packageversion) - 0.0.1 - Six Labor and contributors - netstandard1.1 - true - true - SixLabors.ImageSharp.Drawing - SixLabors.ImageSharp.Drawing - Image Draw Shape Path Font - 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 - - - - - - - - - - - - - - All - - - - ..\..\ImageSharp.ruleset - SixLabors.ImageSharp.Drawing - - - true - + + An extension to ImageSharp that allows the drawing of images, paths, and text. + SixLabors.ImageSharp.Drawing + $(packageversion) + 0.0.1 + SixLabors and contributors + netstandard1.1;netstandard2.0 + true + true + SixLabors.ImageSharp.Drawing + SixLabors.ImageSharp.Drawing + Image Draw Shape Path Font + 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 + + + + + + + + + + + + + + All + + + + ..\..\ImageSharp.ruleset + SixLabors.ImageSharp.Drawing + + + true + \ No newline at end of file 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 @@ public CieLab Convert(CieLch input) // 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 @@ public CieLch Convert(CieLab input) 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 @@ public CieLuv Convert(CieLchuv input) // 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 @@ public CieLchuv Convert(CieLuv input) 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 @@ public static float Gaussian(float x, float sigma) 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 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 @@ public HueProcessor(float angle) 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 @@ public float GetValue(float x) 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 @@ public float GetValue(float x) 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 @@ public float GetValue(float x) 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 @@ public float GetValue(float x) 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 @@ public float GetValue(float x) 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; diff --git a/tests/ImageSharp.Benchmarks/General/Block8x8F_Round.cs b/tests/ImageSharp.Benchmarks/General/Block8x8F_Round.cs index 2739877a6e..d101bf0509 100644 --- a/tests/ImageSharp.Benchmarks/General/Block8x8F_Round.cs +++ b/tests/ImageSharp.Benchmarks/General/Block8x8F_Round.cs @@ -37,7 +37,7 @@ public void ScalarRound() for (int i = 0; i < Block8x8F.Size; i++) { ref float v = ref Unsafe.Add(ref b, i); - v = MathF.Round(v); + v = (float)Math.Round(v); } } diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index 884ae35017..1f88c4fbfa 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -83,7 +83,7 @@ protected override void OnApply(ImageFrame source, Rectangle sourceRecta int endX = sourceRectangle.Right; TPixel glowColor = this.GlowColor; Vector2 centre = Rectangle.Center(sourceRectangle); - float maxDistance = this.Radius > 0 ? MathF.Min(this.Radius, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; + float maxDistance = this.Radius > 0 ? Math.Min(this.Radius, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; // Align start/end positions. int minX = Math.Max(0, startX); @@ -136,13 +136,13 @@ public static Vector4 PremultipliedLerp(Vector4 backdrop, Vector4 source, float amount = amount.Clamp(0, 1); // Santize on zero alpha - if (MathF.Abs(backdrop.W) < Constants.Epsilon) + if (Math.Abs(backdrop.W) < Constants.Epsilon) { source.W *= amount; return source; } - if (MathF.Abs(source.W) < Constants.Epsilon) + if (Math.Abs(source.W) < Constants.Epsilon) { return backdrop; } diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index 15a7941444..8014925e23 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -22,9 +22,9 @@ public SimdUtilsTests(ITestOutputHelper output) this.Output = output; } - private static int R(float f) => (int)MathF.Round(f, MidpointRounding.AwayFromZero); + private static int R(float f) => (int)Math.Round(f, MidpointRounding.AwayFromZero); - private static int Re(float f) => (int)MathF.Round(f, MidpointRounding.ToEven); + private static int Re(float f) => (int)Math.Round(f, MidpointRounding.ToEven); // TODO: Move this to a proper test class! [Theory] @@ -168,7 +168,7 @@ public void BulkConvertNormalizedFloatToByte_WithNonRoundedData(int seed, int co Assert.Equal(expected, dest); } - private static float Clamp255(float x) => MathF.Min(255f, MathF.Max(0f, x)); + private static float Clamp255(float x) => Math.Min(255f, Math.Max(0f, x)); [Theory] [InlineData(1, 0)] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs index bf5507676c..8c12b00505 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs @@ -335,7 +335,7 @@ public void RoundInplaceSlow(int seed) for (int i = 0; i < 64; i++) { - float expected = MathF.Round(s[i]); + float expected = (float)Math.Round(s[i]); float actual = d[i]; Assert.Equal(expected, actual); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index 46f137f810..7e0dc915ce 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -236,11 +236,11 @@ public void ConvertFromYcck(int inputBufferLength, int resultBufferLength, int s float cr = values.Component2[i] - 128F; float k = values.Component3[i] / 255F; - v.X = (255F - MathF.Round(y + (1.402F * cr), MidpointRounding.AwayFromZero)) * k; - v.Y = (255F - MathF.Round( + v.X = (255F - (float)Math.Round(y + (1.402F * cr), MidpointRounding.AwayFromZero)) * k; + v.Y = (255F - (float)Math.Round( y - (0.344136F * cb) - (0.714136F * cr), MidpointRounding.AwayFromZero)) * k; - v.Z = (255F - MathF.Round(y + (1.772F * cb), MidpointRounding.AwayFromZero)) * k; + v.Z = (255F - (float)Math.Round(y + (1.772F * cb), MidpointRounding.AwayFromZero)) * k; v.W = 1F; v *= scale; diff --git a/tests/ImageSharp.Tests/Helpers/MathFTests.cs b/tests/ImageSharp.Tests/Helpers/MathFTests.cs deleted file mode 100644 index f865353c4d..0000000000 --- a/tests/ImageSharp.Tests/Helpers/MathFTests.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using Xunit; - -namespace SixLabors.ImageSharp.Tests.Helpers -{ - public class MathFTests - { - [Fact] - public void MathF_PI_Is_Equal() - { - Assert.Equal(MathF.PI, (float)Math.PI); - } - - [Fact] - public void MathF_Ceililng_Is_Equal() - { - Assert.Equal(MathF.Ceiling(0.3333F), (float)Math.Ceiling(0.3333F)); - } - - [Fact] - public void MathF_Cos_Is_Equal() - { - Assert.Equal(MathF.Cos(0.3333F), (float)Math.Cos(0.3333F)); - } - - [Fact] - public void MathF_Abs_Is_Equal() - { - Assert.Equal(MathF.Abs(-0.3333F), (float)Math.Abs(-0.3333F)); - } - - [Fact] - public void MathF_Atan2_Is_Equal() - { - Assert.Equal(MathF.Atan2(1.2345F, 1.2345F), (float)Math.Atan2(1.2345F, 1.2345F)); - } - - [Fact] - public void MathF_Exp_Is_Equal() - { - Assert.Equal(MathF.Exp(1.2345F), (float)Math.Exp(1.2345F)); - } - - [Fact] - public void MathF_Floor_Is_Equal() - { - Assert.Equal(MathF.Floor(1.2345F), (float)Math.Floor(1.2345F)); - } - - [Fact] - public void MathF_Min_Is_Equal() - { - Assert.Equal(MathF.Min(1.2345F, 5.4321F), (float)Math.Min(1.2345F, 5.4321F)); - } - - [Fact] - public void MathF_Max_Is_Equal() - { - Assert.Equal(MathF.Max(1.2345F, 5.4321F), (float)Math.Max(1.2345F, 5.4321F)); - } - - [Fact] - public void MathF_Pow_Is_Equal() - { - Assert.Equal(MathF.Pow(1.2345F, 5.4321F), (float)Math.Pow(1.2345F, 5.4321F)); - } - - [Fact] - public void MathF_Round_Is_Equal() - { - Assert.Equal(MathF.Round(1.2345F), (float)Math.Round(1.2345F)); - } - - [Fact] - public void MathF_Round_With_Midpoint_Is_Equal() - { - Assert.Equal(MathF.Round(1.2345F, MidpointRounding.AwayFromZero), (float)Math.Round(1.2345F, MidpointRounding.AwayFromZero)); - } - - [Fact] - public void MathF_Sin_Is_Equal() - { - Assert.Equal(MathF.Sin(1.2345F), (float)Math.Sin(1.2345F)); - } - - [Fact] - public void MathF_SinC_Is_Equal() - { - float f = 1.2345F; - float expected = 1F; - if (Math.Abs(f) > Constants.Epsilon) - { - f *= (float)Math.PI; - float sinC = (float)Math.Sin(f) / f; - - expected = Math.Abs(sinC) < Constants.Epsilon ? 0F : sinC; - } - - Assert.Equal(MathF.SinC(1.2345F), expected); - } - - [Fact] - public void MathF_Sqrt_Is_Equal() - { - Assert.Equal(MathF.Sqrt(2F), (float)Math.Sqrt(2F)); - } - - [Fact] - public void Convert_Degree_To_Radian() - { - Assert.Equal((float)(Math.PI / 2D), MathF.DegreeToRadian(90F), new FloatRoundingComparer(6)); - } - - [Fact] - public void Convert_Radian_To_Degree() - { - Assert.Equal(60F, MathF.RadianToDegree((float)(Math.PI / 3D)), new FloatRoundingComparer(5)); - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index ed643c8208..a5e21b8ef3 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -1,6 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using System; + using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; @@ -245,7 +247,7 @@ public void ResizeWithMinMode(TestImageProvider provider) { var options = new ResizeOptions { - Size = new Size((int)MathF.Round(image.Width * .75F), (int)MathF.Round(image.Height * .95F)), + Size = new Size((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)), Mode = ResizeMode.Min };