Browse Source

Changed Argb to be a struct instead of a class

pull/33/head
rokleM 9 years ago
parent
commit
33cbd588e8
  1. 53
      src/ImageSharp/Colors/PackedPixel/Argb.cs

53
src/ImageSharp/Colors/PackedPixel/Argb.cs

@ -11,16 +11,16 @@ 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.
/// </remarks>
public class Argb : IPackedPixel<uint>, IEquatable<Argb>
public struct Argb : IPackedPixel<uint>, IEquatable<Argb>
{
const int BlueShift = 0;
const uint BlueMask = 0xFFFFFF00;
const int GreenShift = 8;
const uint GreenMask = 0xFFFF00FF;
const int RedShift = 16;
const uint RedMask = 0xFF00FFFF;
const int AlphaShift = 24;
const uint AlphaMask = 0x00FFFFFF;
const int BlueShift = 0;
const uint BlueMask = 0xFFFFFF00;
const int GreenShift = 8;
const uint GreenMask = 0xFFFF00FF;
const int RedShift = 16;
const uint RedMask = 0xFF00FFFF;
const int AlphaShift = 24;
const uint AlphaMask = 0x00FFFFFF;
/// <summary>
/// The maximum byte value.
@ -257,11 +257,40 @@ namespace ImageSharp
}
}
/// <summary>
/// Compares two <see cref="Color"/> objects for equality.
/// </summary>
/// <param name="left">
/// The <see cref="Color"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="Color"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator ==(Argb left, Argb right)
{
return left.PackedValue == right.PackedValue;
}
/// <summary>
/// Compares two <see cref="Color"/> objects for equality.
/// </summary>
/// <param name="left">The <see cref="Color"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="Color"/> on the right side of the operand.</param>
/// <returns>
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator !=(Argb left, Argb right)
{
return left.PackedValue != right.PackedValue;
}
/// <inheritdoc/>
public override bool Equals(object obj)
public override bool Equals(object obj)
{
var a = obj as Argb;
return (a != null) && Equals(a);
return obj is Argb && Equals((Argb)obj);
}
/// <inheritdoc/>

Loading…
Cancel
Save