diff --git a/src/ImageProcessorCore/Common/Helpers/ImageMaths.cs b/src/ImageProcessorCore/Common/Helpers/ImageMaths.cs
index 384d3973a8..6ec45549bc 100644
--- a/src/ImageProcessorCore/Common/Helpers/ImageMaths.cs
+++ b/src/ImageProcessorCore/Common/Helpers/ImageMaths.cs
@@ -55,31 +55,31 @@ namespace ImageProcessorCore
/// The B-Spline curve variable.
/// The Cardinal curve variable.
///
- /// The .
+ /// The .
///
- public static double GetBcValue(double x, double b, double c)
+ public static float GetBcValue(float x, float b, float c)
{
- double temp;
+ float temp;
- if (x < 0)
+ if (x < 0F)
{
x = -x;
}
temp = x * x;
- if (x < 1)
+ if (x < 1F)
{
x = ((12 - (9 * b) - (6 * c)) * (x * temp)) + ((-18 + (12 * b) + (6 * c)) * temp) + (6 - (2 * b));
- return x / 6;
+ return x / 6F;
}
- if (x < 2)
+ 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 / 6;
+ return x / 6F;
}
- return 0;
+ return 0F;
}
///
@@ -87,16 +87,16 @@ namespace ImageProcessorCore
///
/// The value to calculate the result for.
///
- /// The .
+ /// The .
///
- public static double SinC(double x)
+ public static float SinC(float x)
{
- const double Epsilon = .00001d;
+ const float Epsilon = .00001F;
if (Math.Abs(x) > Epsilon)
{
- x *= (double)Math.PI;
- return Clean((double)Math.Sin(x) / x);
+ x *= (float)Math.PI;
+ return Clean((float)Math.Sin(x) / x);
}
return 1.0f;
@@ -272,15 +272,15 @@ namespace ImageProcessorCore
///
/// The value to clean.
///
- /// The
+ /// The
/// .
- private static double Clean(double x)
+ private static float Clean(float x)
{
- const double Epsilon = .00001d;
+ const float Epsilon = .00001F;
if (Math.Abs(x) < Epsilon)
{
- return 0f;
+ return 0F;
}
return x;
diff --git a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs
index 0dcafd7b0b..a01fd92402 100644
--- a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs
+++ b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs
@@ -141,7 +141,7 @@ namespace ImageProcessorCore.Processors
Weight xw = horizontalValues[i];
int originX = xw.Index;
Vector4 sourceColor = sourcePixels[originX, y].ToVector4();
- destination += sourceColor * (float)xw.Value;
+ destination += sourceColor * xw.Value;
}
//if (compand)
@@ -179,7 +179,7 @@ namespace ImageProcessorCore.Processors
Weight yw = verticalValues[i];
int originY = yw.Index;
Vector4 sourceColor = firstPassPixels[x, originY].ToVector4();
- destination += sourceColor * (float)yw.Value;
+ destination += sourceColor * yw.Value;
}
//if (compand)
@@ -219,12 +219,12 @@ namespace ImageProcessorCore.Processors
///
protected Weights[] PrecomputeWeights(int destinationSize, int sourceSize)
{
- double scale = (double)destinationSize / sourceSize;
+ float scale = (float)destinationSize / sourceSize;
IResampler sampler = this.Sampler;
- double radius = sampler.Radius;
+ float radius = sampler.Radius;
double left;
double right;
- double weight;
+ float weight;
int index;
int sum;
@@ -234,13 +234,13 @@ namespace ImageProcessorCore.Processors
// visit every source pixel.
if (scale < 1)
{
- double width = radius / scale;
- double filterScale = 1 / scale;
+ float width = radius / scale;
+ float filterScale = 1 / scale;
// Make the weights slices, one source for each column or row.
for (int i = 0; i < destinationSize; i++)
{
- double centre = i / scale;
+ float centre = i / scale;
left = Math.Ceiling(centre - width);
right = Math.Floor(centre + width);
@@ -251,7 +251,7 @@ namespace ImageProcessorCore.Processors
for (double j = left; j <= right; j++)
{
- weight = sampler.GetValue((centre - j) / filterScale) / filterScale;
+ weight = sampler.GetValue((float)((centre - j) / filterScale)) / filterScale;
if (j < 0)
{
index = (int)-j;
@@ -275,7 +275,7 @@ namespace ImageProcessorCore.Processors
// Make the weights slices, one source for each column or row.
for (int i = 0; i < destinationSize; i++)
{
- double centre = i / scale;
+ float centre = i / scale;
left = Math.Ceiling(centre - radius);
right = Math.Floor(centre + radius);
result[i] = new Weights
@@ -285,7 +285,7 @@ namespace ImageProcessorCore.Processors
for (double j = left; j <= right; j++)
{
- weight = sampler.GetValue(centre - j);
+ weight = sampler.GetValue((float)(centre - j));
if (j < 0)
{
index = (int)-j;
@@ -318,7 +318,7 @@ namespace ImageProcessorCore.Processors
///
/// The index.
/// The value.
- public Weight(int index, double value)
+ public Weight(int index, float value)
{
this.Index = index;
this.Value = value;
@@ -332,7 +332,7 @@ namespace ImageProcessorCore.Processors
///
/// Gets the result of the interpolation algorithm.
///
- public double Value { get; }
+ public float Value { get; }
}
///
@@ -348,7 +348,7 @@ namespace ImageProcessorCore.Processors
///
/// Gets or sets the sum.
///
- public double Sum { get; set; }
+ public float Sum { get; set; }
}
}
}
\ No newline at end of file
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/BicubicResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/BicubicResampler.cs
index 041434cdc2..33120b0663 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/BicubicResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/BicubicResampler.cs
@@ -13,28 +13,28 @@ namespace ImageProcessorCore
public class BicubicResampler : IResampler
{
///
- public double Radius => 2;
+ public float Radius => 2;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
// The coefficient.
- double a = -0.5d;
+ float a = -0.5F;
- if (x < 0)
+ if (x < 0F)
{
x = -x;
}
- double result = 0;
+ float result = 0;
- if (x <= 1)
+ if (x <= 1F)
{
- result = (((1.5d * x) - 2.5d) * x * x) + 1;
+ result = (((1.5F * x) - 2.5F) * x * x) + 1;
}
- else if (x < 2)
+ else if (x < 2F)
{
- result = (((((a * x) + 2.5d) * x) - 4) * x) + 2;
+ result = (((((a * x) + 2.5F) * x) - 4) * x) + 2;
}
return result;
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/BoxResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/BoxResampler.cs
index 89a6d8acd0..49a3ad4678 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/BoxResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/BoxResampler.cs
@@ -12,12 +12,12 @@ namespace ImageProcessorCore
public class BoxResampler : IResampler
{
///
- public double Radius => 0.5d;
+ public float Radius => 0.5F;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- if (x > -0.5 && x <= 0.5)
+ if (x > -0.5F && x <= 0.5F)
{
return 1;
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/CatmullRomResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/CatmullRomResampler.cs
index 39dd56129c..281d0190ac 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/CatmullRomResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/CatmullRomResampler.cs
@@ -14,13 +14,13 @@ namespace ImageProcessorCore
public class CatmullRomResampler : IResampler
{
///
- public double Radius => 2;
+ public float Radius => 2;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- const double B = 0;
- const double C = 0.5d;
+ const float B = 0;
+ const float C = 0.5F;
return ImageMaths.GetBcValue(x, B, C);
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/HermiteResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/HermiteResampler.cs
index 3714471171..43d05fc880 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/HermiteResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/HermiteResampler.cs
@@ -13,13 +13,13 @@ namespace ImageProcessorCore.Processors
public class HermiteResampler : IResampler
{
///
- public double Radius => 2;
+ public float Radius => 2;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- const double B = 0;
- const double C = 0;
+ const float B = 0F;
+ const float C = 0F;
return ImageMaths.GetBcValue(x, B, C);
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/IResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/IResampler.cs
index d72e448390..0dea58440c 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/IResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/IResampler.cs
@@ -13,15 +13,15 @@ namespace ImageProcessorCore
///
/// Gets the radius in which to sample pixels.
///
- double Radius { get; }
+ float Radius { get; }
///
/// Gets the result of the interpolation algorithm.
///
/// The value to process.
///
- /// The
+ /// The
///
- double GetValue(double x);
+ float GetValue(float x);
}
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/Lanczos3Resampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/Lanczos3Resampler.cs
index 6240226f6f..6ed82afc09 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/Lanczos3Resampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/Lanczos3Resampler.cs
@@ -13,22 +13,22 @@ namespace ImageProcessorCore
public class Lanczos3Resampler : IResampler
{
///
- public double Radius => 3;
+ public float Radius => 3;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- if (x < 0)
+ if (x < 0F)
{
x = -x;
}
- if (x < 3)
+ if (x < 3F)
{
- return ImageMaths.SinC(x) * ImageMaths.SinC(x / 3d);
+ return ImageMaths.SinC(x) * ImageMaths.SinC(x / 3F);
}
- return 0;
+ return 0F;
}
}
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/Lanczos5Resampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/Lanczos5Resampler.cs
index 4cd75066ee..c0d1d2fdd7 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/Lanczos5Resampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/Lanczos5Resampler.cs
@@ -13,22 +13,22 @@ namespace ImageProcessorCore
public class Lanczos5Resampler : IResampler
{
///
- public double Radius => 5;
+ public float Radius => 5;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- if (x < 0)
+ if (x < 0F)
{
x = -x;
}
- if (x < 5)
+ if (x < 5F)
{
- return ImageMaths.SinC(x) * ImageMaths.SinC(x / 5d);
+ return ImageMaths.SinC(x) * ImageMaths.SinC(x / 5F);
}
- return 0;
+ return 0F;
}
}
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/Lanczos8Resampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/Lanczos8Resampler.cs
index 3db31b1fe3..e0f2917c27 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/Lanczos8Resampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/Lanczos8Resampler.cs
@@ -13,22 +13,22 @@ namespace ImageProcessorCore
public class Lanczos8Resampler : IResampler
{
///
- public double Radius => 8;
+ public float Radius => 8;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- if (x < 0)
+ if (x < 0F)
{
x = -x;
}
- if (x < 8)
+ if (x < 8F)
{
- return ImageMaths.SinC(x) * ImageMaths.SinC(x / 8d);
+ return ImageMaths.SinC(x) * ImageMaths.SinC(x / 8F);
}
- return 0;
+ return 0F;
}
}
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/MitchellNetravaliResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/MitchellNetravaliResampler.cs
index c3f98a9fff..cacd35f0a1 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/MitchellNetravaliResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/MitchellNetravaliResampler.cs
@@ -12,13 +12,13 @@ namespace ImageProcessorCore
public class MitchellNetravaliResampler : IResampler
{
///
- public double Radius => 2;
+ public float Radius => 2;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- const double B = 0.333333333333333D;
- const double C = 0.333333333333333D;
+ const float B = 0.3333333F;
+ const float C = 0.3333333F;
return ImageMaths.GetBcValue(x, B, C);
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/NearestNeighborResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/NearestNeighborResampler.cs
index 6cd5c53cff..58b6a9d584 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/NearestNeighborResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/NearestNeighborResampler.cs
@@ -12,10 +12,10 @@ namespace ImageProcessorCore
public class NearestNeighborResampler : IResampler
{
///
- public double Radius => 1;
+ public float Radius => 1;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
return x;
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/RobidouxResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/RobidouxResampler.cs
index 200c727341..85f68c531e 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/RobidouxResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/RobidouxResampler.cs
@@ -12,13 +12,13 @@ namespace ImageProcessorCore
public class RobidouxResampler : IResampler
{
///
- public double Radius => 2;
+ public float Radius => 2;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- const double B = 0.37821575509399867D;
- const double C = 0.31089212245300067D;
+ const float B = 0.37821575509399867F;
+ const float C = 0.31089212245300067F;
return ImageMaths.GetBcValue(x, B, C);
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/RobidouxSharpResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/RobidouxSharpResampler.cs
index 3612d5b1d5..eb8e07ade5 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/RobidouxSharpResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/RobidouxSharpResampler.cs
@@ -12,13 +12,13 @@ namespace ImageProcessorCore
public class RobidouxSharpResampler : IResampler
{
///
- public double Radius => 2;
+ public float Radius => 2;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- const double B = 0.2620145123990142D;
- const double C = 0.3689927438004929D;
+ const float B = 0.2620145123990142F;
+ const float C = 0.3689927438004929F;
return ImageMaths.GetBcValue(x, B, C);
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/SplineResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/SplineResampler.cs
index d4b4982949..f88f9abef3 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/SplineResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/SplineResampler.cs
@@ -12,13 +12,13 @@ namespace ImageProcessorCore
public class SplineResampler : IResampler
{
///
- public double Radius => 2;
+ public float Radius => 2;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- const double B = 1;
- const double C = 0;
+ const float B = 1F;
+ const float C = 0F;
return ImageMaths.GetBcValue(x, B, C);
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/TriangleResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/TriangleResampler.cs
index 9a7bb1bff9..2269bb251d 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/TriangleResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/TriangleResampler.cs
@@ -13,22 +13,22 @@ namespace ImageProcessorCore
public class TriangleResampler : IResampler
{
///
- public double Radius => 1;
+ public float Radius => 1;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- if (x < 0)
+ if (x < 0F)
{
x = -x;
}
- if (x < 1)
+ if (x < 1F)
{
- return 1 - x;
+ return 1F - x;
}
- return 0;
+ return 0F;
}
}
}
diff --git a/src/ImageProcessorCore/Samplers/Resamplers/WelchResampler.cs b/src/ImageProcessorCore/Samplers/Resamplers/WelchResampler.cs
index 3bd0d36cff..ef0ab9cea1 100644
--- a/src/ImageProcessorCore/Samplers/Resamplers/WelchResampler.cs
+++ b/src/ImageProcessorCore/Samplers/Resamplers/WelchResampler.cs
@@ -12,22 +12,22 @@ namespace ImageProcessorCore
public class WelchResampler : IResampler
{
///
- public double Radius => 3;
+ public float Radius => 3;
///
- public double GetValue(double x)
+ public float GetValue(float x)
{
- if (x < 0)
+ if (x < 0F)
{
x = -x;
}
- if (x < 3)
+ if (x < 3F)
{
- return ImageMaths.SinC(x) * (1.0d - (x * x / 9.0d));
+ return ImageMaths.SinC(x) * (1F - (x * x / 9.0F));
}
- return 0;
+ return 0F;
}
}
}