diff --git a/src/ImageSharp/Colors/Color.Transforms.cs b/src/ImageSharp/Colors/Color.Transforms.cs
index 31b4aa5be..15935afc4 100644
--- a/src/ImageSharp/Colors/Color.Transforms.cs
+++ b/src/ImageSharp/Colors/Color.Transforms.cs
@@ -6,9 +6,10 @@
namespace ImageSharp
{
using System.Numerics;
+ using System.Runtime.CompilerServices;
///
- /// Unpacked pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255.
+ /// Packed pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255.
/// The color components are stored in red, green, blue, and alpha order.
///
///
@@ -25,10 +26,11 @@ namespace ImageSharp
///
/// The .
///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Color operator +(Color left, Color right)
{
Vector4 add = left.ToVector4() + right.ToVector4();
- return Pack(ref add);
+ return PackNew(ref add);
}
///
@@ -39,10 +41,11 @@ namespace ImageSharp
///
/// The .
///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Color operator -(Color left, Color right)
{
Vector4 sub = left.ToVector4() - right.ToVector4();
- return Pack(ref sub);
+ return PackNew(ref sub);
}
///
@@ -56,7 +59,7 @@ namespace ImageSharp
public static Color Normal(Color backdrop, Color source)
{
Vector4 normal = Vector4BlendTransforms.Normal(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref normal);
+ return PackNew(ref normal);
}
///
@@ -76,7 +79,7 @@ namespace ImageSharp
public static Color Multiply(Color backdrop, Color source)
{
Vector4 multiply = Vector4BlendTransforms.Multiply(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref multiply);
+ return PackNew(ref multiply);
}
///
@@ -95,7 +98,7 @@ namespace ImageSharp
public static Color Screen(Color backdrop, Color source)
{
Vector4 subtract = Vector4BlendTransforms.Screen(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref subtract);
+ return PackNew(ref subtract);
}
///
@@ -110,7 +113,7 @@ namespace ImageSharp
public static Color HardLight(Color backdrop, Color source)
{
Vector4 hardlight = Vector4BlendTransforms.HardLight(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref hardlight);
+ return PackNew(ref hardlight);
}
///
@@ -129,7 +132,7 @@ namespace ImageSharp
public static Color Overlay(Color backdrop, Color source)
{
Vector4 overlay = Vector4BlendTransforms.Overlay(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref overlay);
+ return PackNew(ref overlay);
}
///
@@ -144,7 +147,7 @@ namespace ImageSharp
public static Color Darken(Color backdrop, Color source)
{
Vector4 darken = Vector4BlendTransforms.Darken(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref darken);
+ return PackNew(ref darken);
}
///
@@ -159,7 +162,7 @@ namespace ImageSharp
public static Color Lighten(Color backdrop, Color source)
{
Vector4 lighten = Vector4BlendTransforms.Lighten(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref lighten);
+ return PackNew(ref lighten);
}
///
@@ -174,7 +177,7 @@ namespace ImageSharp
public static Color SoftLight(Color backdrop, Color source)
{
Vector4 softlight = Vector4BlendTransforms.SoftLight(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref softlight);
+ return PackNew(ref softlight);
}
///
@@ -188,7 +191,7 @@ namespace ImageSharp
public static Color ColorDodge(Color backdrop, Color source)
{
Vector4 dodge = Vector4BlendTransforms.Dodge(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref dodge);
+ return PackNew(ref dodge);
}
///
@@ -202,7 +205,7 @@ namespace ImageSharp
public static Color ColorBurn(Color backdrop, Color source)
{
Vector4 burn = Vector4BlendTransforms.Burn(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref burn);
+ return PackNew(ref burn);
}
///
@@ -217,7 +220,7 @@ namespace ImageSharp
public static Color Difference(Color backdrop, Color source)
{
Vector4 difference = Vector4BlendTransforms.Difference(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref difference);
+ return PackNew(ref difference);
}
///
@@ -232,7 +235,7 @@ namespace ImageSharp
public static Color Exclusion(Color backdrop, Color source)
{
Vector4 exclusion = Vector4BlendTransforms.Exclusion(backdrop.ToVector4(), source.ToVector4());
- return Pack(ref exclusion);
+ return PackNew(ref exclusion);
}
///
@@ -249,7 +252,8 @@ namespace ImageSharp
///
public static Color Lerp(Color from, Color to, float amount)
{
- return new Color(Vector4.Lerp(from.ToVector4(), to.ToVector4(), amount));
+ Vector4 lerp = Vector4.Lerp(from.ToVector4(), to.ToVector4(), amount);
+ return PackNew(ref lerp);
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Colors/ColorspaceTransforms.cs b/src/ImageSharp/Colors/ColorspaceTransforms.cs
index cbf40724e..480caab33 100644
--- a/src/ImageSharp/Colors/ColorspaceTransforms.cs
+++ b/src/ImageSharp/Colors/ColorspaceTransforms.cs
@@ -10,7 +10,7 @@ namespace ImageSharp
using Colors.Spaces;
///
- /// Unpacked pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255.
+ /// Packed pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255.
/// The color components are stored in red, green, blue, and alpha order.
///
///
diff --git a/src/ImageSharp/Colors/PackedPixel/Argb.cs b/src/ImageSharp/Colors/PackedPixel/Argb32.cs
similarity index 87%
rename from src/ImageSharp/Colors/PackedPixel/Argb.cs
rename to src/ImageSharp/Colors/PackedPixel/Argb32.cs
index d03c098cd..64255a53b 100644
--- a/src/ImageSharp/Colors/PackedPixel/Argb.cs
+++ b/src/ImageSharp/Colors/PackedPixel/Argb32.cs
@@ -1,4 +1,4 @@
-//
+//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
@@ -17,7 +17,7 @@ namespace ImageSharp
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations.
///
- public struct Argb : IPixel, IPackedVector
+ public struct Argb32 : IPixel, IPackedVector
{
///
/// The shift count for the blue component
@@ -50,58 +50,58 @@ namespace ImageSharp
private static readonly Vector4 Half = new Vector4(0.5F);
///
- /// Initializes a new instance of the struct.
+ /// Initializes a new instance of the struct.
///
/// The red component.
/// The green component.
/// The blue component.
/// The alpha component.
- public Argb(byte r, byte g, byte b, byte a = 255)
+ public Argb32(byte r, byte g, byte b, byte a = 255)
{
this.PackedValue = Pack(r, g, b, a);
}
///
- /// Initializes a new instance of the struct.
+ /// Initializes a new instance of the struct.
///
/// The red component.
/// The green component.
/// The blue component.
/// The alpha component.
- public Argb(float r, float g, float b, float a = 1)
+ public Argb32(float r, float g, float b, float a = 1)
{
this.PackedValue = Pack(r, g, b, a);
}
///
- /// Initializes a new instance of the struct.
+ /// Initializes a new instance of the struct.
///
///
/// The vector containing the components for the packed vector.
///
- public Argb(Vector3 vector)
+ public Argb32(Vector3 vector)
{
this.PackedValue = Pack(ref vector);
}
///
- /// Initializes a new instance of the struct.
+ /// Initializes a new instance of the struct.
///
///
/// The vector containing the components for the packed vector.
///
- public Argb(Vector4 vector)
+ public Argb32(Vector4 vector)
{
this.PackedValue = Pack(ref vector);
}
///
- /// Initializes a new instance of the struct.
+ /// Initializes a new instance of the struct.
///
///
/// The packed value.
///
- public Argb(uint packed = 0)
+ public Argb32(uint packed = 0)
{
this.PackedValue = packed;
}
@@ -182,33 +182,33 @@ namespace ImageSharp
}
///
- /// Compares two objects for equality.
+ /// Compares two objects for equality.
///
///
- /// The on the left side of the operand.
+ /// The on the left side of the operand.
///
///
- /// The on the right side of the operand.
+ /// The on the right side of the operand.
///
///
/// True if the parameter is equal to the parameter; otherwise, false.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator ==(Argb left, Argb right)
+ public static bool operator ==(Argb32 left, Argb32 right)
{
return left.PackedValue == right.PackedValue;
}
///
- /// Compares two objects for equality.
+ /// Compares two objects for equality.
///
- /// The on the left side of the operand.
- /// The on the right side of the operand.
+ /// The on the left side of the operand.
+ /// The on the right side of the operand.
///
/// True if the parameter is not equal to the parameter; otherwise, false.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator !=(Argb left, Argb right)
+ public static bool operator !=(Argb32 left, Argb32 right)
{
return left.PackedValue != right.PackedValue;
}
@@ -221,7 +221,7 @@ namespace ImageSharp
}
///
- public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations();
+ public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations();
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -278,12 +278,12 @@ namespace ImageSharp
///
public override bool Equals(object obj)
{
- return obj is Argb && this.Equals((Argb)obj);
+ return obj is Argb32 && this.Equals((Argb32)obj);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public bool Equals(Argb other)
+ public bool Equals(Argb32 other)
{
return this.PackedValue == other.PackedValue;
}
diff --git a/src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs b/src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs
index 949e44cc0..13727870c 100644
--- a/src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs
+++ b/src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs
@@ -300,7 +300,7 @@ namespace ImageSharp
private static bool IsStandardNormalizedType(Type type)
{
return type == typeof(Color)
- || type == typeof(Argb)
+ || type == typeof(Argb32)
|| type == typeof(Alpha8)
|| type == typeof(Bgr565)
|| type == typeof(Bgra4444)
diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs
index 05fc4094e..f23ca3e5c 100644
--- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs
+++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs
@@ -64,7 +64,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
{
}
- public class ToXyzw_Argb : ToXyzw
+ public class ToXyzw_Argb : ToXyzw
{
}
}
diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs
index 0b1e6dc7b..d4b9f6f3a 100644
--- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs
+++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs
@@ -58,7 +58,7 @@ namespace ImageSharp.Tests.Colors
}
}
- public class Argb : BulkPixelOperationsTests
+ public class Argb : BulkPixelOperationsTests
{
// For 4.6 test runner MemberData does not work without redeclaring the public field in the derived test class:
public Argb(ITestOutputHelper output)
diff --git a/tests/ImageSharp.Tests/Colors/ColorConstructorTests.cs b/tests/ImageSharp.Tests/Colors/ColorConstructorTests.cs
index 83c02635a..d2c5cf845 100644
--- a/tests/ImageSharp.Tests/Colors/ColorConstructorTests.cs
+++ b/tests/ImageSharp.Tests/Colors/ColorConstructorTests.cs
@@ -30,7 +30,7 @@ namespace ImageSharp.Tests.Colors
// using float array to work around a bug in xunit corruptint the state of any Vector4 passed as MemberData
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W };
- yield return new object[] { new Argb(vector4), vector4Components };
+ yield return new object[] { new Argb32(vector4), vector4Components };
yield return new object[] { new Bgra4444(vector4), vector4Components };
yield return new object[] { new Bgra5551(vector4), vector4Components };
yield return new object[] { new Byte4(vector4), vector4Components };
@@ -63,7 +63,7 @@ namespace ImageSharp.Tests.Colors
// using float array to work around a bug in xunit corruptint the state of any Vector4 passed as MemberData
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W };
- yield return new object[] { new Argb(vector3), vector4Components };
+ yield return new object[] { new Argb32(vector3), vector4Components };
yield return new object[] { new Bgr565(vector3), vector4Components };
}
}
@@ -88,7 +88,7 @@ namespace ImageSharp.Tests.Colors
// using float array to work around a bug in xunit corruptint the state of any Vector4 passed as MemberData
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W };
- yield return new object[] { new Argb(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components };
+ yield return new object[] { new Argb32(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components };
yield return new object[] { new Bgra4444(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components };
yield return new object[] { new Bgra5551(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components };
yield return new object[] { new Byte4(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components };
@@ -121,7 +121,7 @@ namespace ImageSharp.Tests.Colors
// using float array to work around a bug in xunit corruptint the state of any Vector4 passed as MemberData
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W };
- yield return new object[] { new Argb(vector3.X, vector3.Y, vector3.Z), vector4Components };
+ yield return new object[] { new Argb32(vector3.X, vector3.Y, vector3.Z), vector4Components };
yield return new object[] { new Bgr565(vector3.X, vector3.Y, vector3.Z), vector4Components };
}
}
diff --git a/tests/ImageSharp.Tests/Colors/ColorEqualityTests.cs b/tests/ImageSharp.Tests/Colors/ColorEqualityTests.cs
index 42481799f..ffb04e8b2 100644
--- a/tests/ImageSharp.Tests/Colors/ColorEqualityTests.cs
+++ b/tests/ImageSharp.Tests/Colors/ColorEqualityTests.cs
@@ -19,7 +19,7 @@ namespace ImageSharp.Tests.Colors
new TheoryData