diff --git a/src/ImageSharp/Common/Extensions/Vector4Extensions.cs b/src/ImageSharp/Common/Extensions/Vector4Extensions.cs
index d91c7e0d1..88712a736 100644
--- a/src/ImageSharp/Common/Extensions/Vector4Extensions.cs
+++ b/src/ImageSharp/Common/Extensions/Vector4Extensions.cs
@@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp
/// The to premultiply
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector4 Premultiply(this ref Vector4 source)
+ public static Vector4 Premultiply(this Vector4 source)
{
float w = source.W;
Vector4 premultiplied = source * w;
@@ -29,12 +29,12 @@ namespace SixLabors.ImageSharp
}
///
- /// Reverses the result of premultiplying a vector via .
+ /// Reverses the result of premultiplying a vector via .
///
/// The to premultiply
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector4 UnPremultiply(this ref Vector4 source)
+ public static Vector4 UnPremultiply(this Vector4 source)
{
float w = source.W;
Vector4 unpremultiplied = source / w;
@@ -50,10 +50,10 @@ namespace SixLabors.ImageSharp
/// The whose signal to compress.
/// The .
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector4 Compress(this ref Vector4 linear)
+ public static Vector4 Compress(this Vector4 linear)
{
// TODO: Is there a faster way to do this?
- return new Vector4(Compress(ref linear.X), Compress(ref linear.Y), Compress(ref linear.Z), linear.W);
+ return new Vector4(Compress(linear.X), Compress(linear.Y), Compress(linear.Z), linear.W);
}
///
@@ -64,10 +64,10 @@ namespace SixLabors.ImageSharp
/// The whose signal to expand.
/// The .
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector4 Expand(this ref Vector4 gamma)
+ public static Vector4 Expand(this Vector4 gamma)
{
// TODO: Is there a faster way to do this?
- return new Vector4(Expand(ref gamma.X), Expand(ref gamma.Y), Expand(ref gamma.Z), gamma.W);
+ return new Vector4(Expand(gamma.X), Expand(gamma.Y), Expand(gamma.Z), gamma.W);
}
///
@@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp
/// The .
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static float Compress(ref float signal)
+ private static float Compress(float signal)
{
if (signal <= 0.0031308F)
{
@@ -100,7 +100,7 @@ namespace SixLabors.ImageSharp
/// The .
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static float Expand(ref float signal)
+ private static float Expand(float signal)
{
if (signal <= 0.04045F)
{
diff --git a/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs
index e07bdcbb9..ebadd2850 100644
--- a/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs
+++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs
@@ -95,8 +95,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors
int offsetX = x + fxr;
offsetX = offsetX.Clamp(0, maxX);
- var currentColor = sourceOffsetRow[offsetX].ToVector4();
- currentColor = currentColor.Premultiply();
+ Vector4 currentColor = sourceOffsetRow[offsetX].ToVector4().Premultiply();
if (fy < kernelXHeight)
{
@@ -121,8 +120,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors
float blue = MathF.Sqrt((bX * bX) + (bY * bY));
ref TPixel pixel = ref targetRow[x];
- var result = new Vector4(red, green, blue, sourceRow[x].ToVector4().W);
- pixel.PackFromVector4(result.UnPremultiply());
+ pixel.PackFromVector4(new Vector4(red, green, blue, sourceRow[x].ToVector4().W).UnPremultiply());
}
});
diff --git a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs
index 05d9198e7..8f96546ae 100644
--- a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs
+++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs
@@ -110,8 +110,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors
offsetX = offsetX.Clamp(0, maxX);
- var currentColor = row[offsetX].ToVector4();
- currentColor = currentColor.Premultiply();
+ Vector4 currentColor = row[offsetX].ToVector4().Premultiply();
destination += kernel[fy, fx] * currentColor;
}
}
diff --git a/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs
index a7e6c0399..8f7a1caab 100644
--- a/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs
+++ b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs
@@ -82,8 +82,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors
offsetX = offsetX.Clamp(0, maxX);
- var currentColor = sourceOffsetRow[offsetX].ToVector4();
- currentColor = currentColor.Premultiply();
+ Vector4 currentColor = sourceOffsetRow[offsetX].ToVector4().Premultiply();
currentColor *= this.KernelXY[fy, fx];
red += currentColor.X;
@@ -93,8 +92,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors
}
ref TPixel pixel = ref targetRow[x];
- var result = new Vector4(red, green, blue, sourceRow[x].ToVector4().W);
- pixel.PackFromVector4(result.UnPremultiply());
+ pixel.PackFromVector4(new Vector4(red, green, blue, sourceRow[x].ToVector4().W).UnPremultiply());
}
});
diff --git a/src/ImageSharp/Processing/Transforms/Processors/WeightsWindow.cs b/src/ImageSharp/Processing/Transforms/Processors/WeightsWindow.cs
index 6bc04c26d..26aaec502 100644
--- a/src/ImageSharp/Processing/Transforms/Processors/WeightsWindow.cs
+++ b/src/ImageSharp/Processing/Transforms/Processors/WeightsWindow.cs
@@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
///
/// Computes the sum of vectors in 'rowSpan' weighted by weight values, pointed by this instance.
- /// Applies to all input vectors.
+ /// Applies to all input vectors.
///
/// The input span of vectors
/// The source row position.
@@ -115,8 +115,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
{
float weight = Unsafe.Add(ref horizontalValues, i);
Vector4 v = Unsafe.Add(ref vecPtr, i);
- v = v.Premultiply();
- result += v.Expand() * weight;
+ result += v.Premultiply().Expand() * weight;
}
return result.UnPremultiply();