Browse Source

Revert "Added readonly modifiers to pixel formats"

This reverts commit 85de14f1a9.
pull/1122/head
Sergio Pedri 6 years ago
parent
commit
7de9a2da4d
  1. 14
      src/ImageSharp/PixelFormats/PixelImplementations/A8.cs
  2. 21
      src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
  3. 14
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs
  4. 16
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs
  5. 18
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
  6. 14
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs
  7. 12
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs
  8. 14
      src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs
  9. 14
      src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs
  10. 16
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
  11. 14
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs
  12. 14
      src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
  13. 14
      src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
  14. 17
      src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
  15. 18
      src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
  16. 18
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
  17. 14
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs
  18. 18
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
  19. 14
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs
  20. 16
      src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs
  21. 14
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs
  22. 14
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs
  23. 14
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs
  24. 24
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
  25. 28
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
  26. 16
      src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
  27. 18
      src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
  28. 14
      src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs

14
src/ImageSharp/PixelFormats/PixelImplementations/A8.cs

@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(A8 left, A8 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<A8> CreatePixelOperations() => new PixelOperations<A8>();
public PixelOperations<A8> CreatePixelOperations() => new PixelOperations<A8>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(0, 0, 0, this.PackedValue / 255F);
public Vector4 ToVector4() => new Vector4(0, 0, 0, this.PackedValue / 255F);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <param name="obj">The object to compare.</param>
/// <returns>True if the object is equal to the packed vector.</returns>
public override readonly bool Equals(object obj) => obj is A8 other && this.Equals(other);
public override bool Equals(object obj) => obj is A8 other && this.Equals(other);
/// <summary>
/// Compares another A8 packed vector with the packed vector.
@ -144,17 +144,17 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="other">The A8 packed vector to compare.</param>
/// <returns>True if the packed vectors are equal.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(A8 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(A8 other) => this.PackedValue.Equals(other.PackedValue);
/// <summary>
/// Gets a string representation of the packed vector.
/// </summary>
/// <returns>A string representation of the packed vector.</returns>
public override readonly string ToString() => $"A8({this.PackedValue})";
public override string ToString() => $"A8({this.PackedValue})";
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <summary>
/// Packs a <see cref="float"/> into a byte.

21
src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs

@ -129,7 +129,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public uint Argb
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Argb32, uint>(ref Unsafe.AsRef(this));
get => Unsafe.As<Argb32, uint>(ref this);
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Argb32, uint>(ref this) = value;
@ -138,10 +138,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
public uint PackedValue
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => this.Argb;
[MethodImpl(InliningOptions.ShortMethod)]
get => this.Argb;
set => this.Argb = value;
}
@ -184,7 +181,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Argb32 left, Argb32 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Argb32> CreatePixelOperations() => new PixelOperations();
public PixelOperations<Argb32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -192,7 +189,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -200,7 +197,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A) / MaxBytes;
public Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A) / MaxBytes;
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -323,21 +320,21 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Argb32 argb32 && this.Equals(argb32);
public override bool Equals(object obj) => obj is Argb32 argb32 && this.Equals(argb32);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Argb32 other) => this.Argb == other.Argb;
public bool Equals(Argb32 other) => this.Argb == other.Argb;
/// <summary>
/// Gets a string representation of the packed vector.
/// </summary>
/// <returns>A string representation of the packed vector.</returns>
public override readonly string ToString() => $"Argb({this.A}, {this.R}, {this.G}, {this.B})";
public override string ToString() => $"Argb({this.A}, {this.R}, {this.G}, {this.B})";
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.Argb.GetHashCode();
public override int GetHashCode() => this.Argb.GetHashCode();
/// <summary>
/// Packs the four floats into a color.

14
src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs

@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Bgr24 left, Bgr24 right) => !left.Equals(right);
/// <inheritdoc/>
public readonly PixelOperations<Bgr24> CreatePixelOperations() => new PixelOperations();
public PixelOperations<Bgr24> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Rgba32(this.R, this.G, this.B, byte.MaxValue).ToVector4();
public Vector4 ToVector4() => new Rgba32(this.R, this.G, this.B, byte.MaxValue).ToVector4();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -219,16 +219,16 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Bgr24 other) => this.R.Equals(other.R) && this.G.Equals(other.G) && this.B.Equals(other.B);
public bool Equals(Bgr24 other) => this.R.Equals(other.R) && this.G.Equals(other.G) && this.B.Equals(other.B);
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Bgr24 other && this.Equals(other);
public override bool Equals(object obj) => obj is Bgr24 other && this.Equals(other);
/// <inheritdoc />
public override readonly string ToString() => $"Bgra({this.B}, {this.G}, {this.R})";
public override string ToString() => $"Bgra({this.B}, {this.G}, {this.R})";
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => HashCode.Combine(this.R, this.B, this.G);
public override int GetHashCode() => HashCode.Combine(this.R, this.B, this.G);
}
}

16
src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs

@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Bgr565 left, Bgr565 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Bgr565> CreatePixelOperations() => new PixelOperations<Bgr565>();
public PixelOperations<Bgr565> CreatePixelOperations() => new PixelOperations<Bgr565>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.ToVector3(), 1F);
public Vector4 ToVector4() => new Vector4(this.ToVector3(), 1F);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -144,7 +144,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Vector3"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector3 ToVector3()
public Vector3 ToVector3()
{
return new Vector3(
((this.PackedValue >> 11) & 0x1F) * (1F / 31F),
@ -153,14 +153,14 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Bgr565 other && this.Equals(other);
public override bool Equals(object obj) => obj is Bgr565 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Bgr565 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(Bgr565 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector3();
return FormattableString.Invariant($"Bgr565({vector.Z:#0.##}, {vector.Y:#0.##}, {vector.X:#0.##})");
@ -168,7 +168,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
[MethodImpl(InliningOptions.ShortMethod)]
private static ushort Pack(ref Vector3 vector)

18
src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs

@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public uint Bgra
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Bgra32, uint>(ref Unsafe.AsRef(this));
get => Unsafe.As<Bgra32, uint>(ref this);
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Bgra32, uint>(ref this) = value;
@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
public uint PackedValue
{
readonly get => this.Bgra;
get => this.Bgra;
set => this.Bgra = value;
}
@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Bgra32 left, Bgra32 right) => !left.Equals(right);
/// <inheritdoc/>
public readonly PixelOperations<Bgra32> CreatePixelOperations() => new PixelOperations();
public PixelOperations<Bgra32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -145,7 +145,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A) / MaxBytes;
public Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A) / MaxBytes;
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -276,16 +276,16 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Bgra32 other && this.Equals(other);
public override bool Equals(object obj) => obj is Bgra32 other && this.Equals(other);
/// <inheritdoc/>
public readonly bool Equals(Bgra32 other) => this.Bgra.Equals(other.Bgra);
public bool Equals(Bgra32 other) => this.Bgra.Equals(other.Bgra);
/// <inheritdoc/>
public override readonly int GetHashCode() => this.Bgra.GetHashCode();
public override int GetHashCode() => this.Bgra.GetHashCode();
/// <inheritdoc />
public override readonly string ToString() => $"Bgra32({this.B}, {this.G}, {this.R}, {this.A})";
public override string ToString() => $"Bgra32({this.B}, {this.G}, {this.R}, {this.A})";
/// <summary>
/// Packs a <see cref="Vector4"/> into a color.

14
src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs

@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Bgra4444 left, Bgra4444 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Bgra4444> CreatePixelOperations() => new PixelOperations<Bgra4444>();
public PixelOperations<Bgra4444> CreatePixelOperations() => new PixelOperations<Bgra4444>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
const float Max = 1 / 15F;
@ -142,14 +142,14 @@ namespace SixLabors.ImageSharp.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Bgra4444 other && this.Equals(other);
public override bool Equals(object obj) => obj is Bgra4444 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Bgra4444 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(Bgra4444 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector4();
return FormattableString.Invariant($"Bgra4444({vector.Z:#0.##}, {vector.Y:#0.##}, {vector.X:#0.##}, {vector.W:#0.##})");
@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
[MethodImpl(InliningOptions.ShortMethod)]
private static ushort Pack(ref Vector4 vector)

12
src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs

@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Bgra5551 left, Bgra5551 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Bgra5551> CreatePixelOperations() => new PixelOperations();
public PixelOperations<Bgra5551> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
return new Vector4(
((this.PackedValue >> 10) & 0x1F) / 31F,
@ -147,10 +147,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Bgra5551 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(Bgra5551 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector4();
return FormattableString.Invariant($"Bgra5551({vector.Z:#0.##}, {vector.Y:#0.##}, {vector.X:#0.##}, {vector.W:#0.##})");
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
[MethodImpl(InliningOptions.ShortMethod)]
private static ushort Pack(ref Vector4 vector)

14
src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs

@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Byte4 left, Byte4 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Byte4> CreatePixelOperations() => new PixelOperations<Byte4>();
public PixelOperations<Byte4> CreatePixelOperations() => new PixelOperations<Byte4>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4() / 255F;
public Vector4 ToScaledVector4() => this.ToVector4() / 255F;
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
return new Vector4(
this.PackedValue & 0xFF,
@ -143,18 +143,18 @@ namespace SixLabors.ImageSharp.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Byte4 byte4 && this.Equals(byte4);
public override bool Equals(object obj) => obj is Byte4 byte4 && this.Equals(byte4);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Byte4 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(Byte4 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector4();
return FormattableString.Invariant($"Byte4({vector.X:#0.##}, {vector.Y:#0.##}, {vector.Z:#0.##}, {vector.W:#0.##})");

14
src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs

@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4()
public Vector4 ToScaledVector4()
{
float single = this.ToSingle() + 1F;
single /= 2F;
@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.ToSingle(), 0, 0, 1F);
public Vector4 ToVector4() => new Vector4(this.ToSingle(), 0, 0, 1F);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -136,20 +136,20 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="float"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly float ToSingle() => HalfTypeHelper.Unpack(this.PackedValue);
public float ToSingle() => HalfTypeHelper.Unpack(this.PackedValue);
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is HalfSingle other && this.Equals(other);
public override bool Equals(object obj) => obj is HalfSingle other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(HalfSingle other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(HalfSingle other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly string ToString() => FormattableString.Invariant($"HalfSingle({this.ToSingle():#0.##})");
public override string ToString() => FormattableString.Invariant($"HalfSingle({this.ToSingle():#0.##})");
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
}
}

16
src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs

@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(HalfVector2 left, HalfVector2 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<HalfVector2> CreatePixelOperations() => new PixelOperations<HalfVector2>();
public PixelOperations<HalfVector2> CreatePixelOperations() => new PixelOperations<HalfVector2>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4()
public Vector4 ToScaledVector4()
{
var scaled = this.ToVector2();
scaled += Vector2.One;
@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
var vector = this.ToVector2();
return new Vector4(vector.X, vector.Y, 0F, 1F);
@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Vector2"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector2 ToVector2()
public Vector2 ToVector2()
{
Vector2 vector;
vector.X = HalfTypeHelper.Unpack((ushort)this.PackedValue);
@ -156,14 +156,14 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is HalfVector2 other && this.Equals(other);
public override bool Equals(object obj) => obj is HalfVector2 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(HalfVector2 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(HalfVector2 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector2();
return FormattableString.Invariant($"HalfVector2({vector.X:#0.##}, {vector.Y:#0.##})");
@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
[MethodImpl(InliningOptions.ShortMethod)]
private static uint Pack(float x, float y)

14
src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs

@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(HalfVector4 left, HalfVector4 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<HalfVector4> CreatePixelOperations() => new PixelOperations<HalfVector4>();
public PixelOperations<HalfVector4> CreatePixelOperations() => new PixelOperations<HalfVector4>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4()
public Vector4 ToScaledVector4()
{
var scaled = this.ToVector4();
scaled += Vector4.One;
@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
return new Vector4(
HalfTypeHelper.Unpack((ushort)this.PackedValue),
@ -151,14 +151,14 @@ namespace SixLabors.ImageSharp.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is HalfVector4 other && this.Equals(other);
public override bool Equals(object obj) => obj is HalfVector4 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(HalfVector4 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(HalfVector4 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector4();
return FormattableString.Invariant($"HalfVector4({vector.X:#0.##}, {vector.Y:#0.##}, {vector.Z:#0.##}, {vector.W:#0.##})");
@ -166,7 +166,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <summary>
/// Packs a <see cref="Vector4"/> into a <see cref="ulong"/>.

14
src/ImageSharp/PixelFormats/PixelImplementations/L16.cs

@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(L16 left, L16 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<L16> CreatePixelOperations() => new PixelOperations();
public PixelOperations<L16> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
float scaled = this.PackedValue / Max;
return new Vector4(scaled, scaled, scaled, 1F);
@ -160,18 +160,18 @@ namespace SixLabors.ImageSharp.PixelFormats
public void FromRgba64(Rgba64 source) => this.PackedValue = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B);
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is L16 other && this.Equals(other);
public override bool Equals(object obj) => obj is L16 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(L16 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(L16 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly string ToString() => $"L16({this.PackedValue})";
public override string ToString() => $"L16({this.PackedValue})";
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
[MethodImpl(InliningOptions.ShortMethod)]
internal void ConvertFromRgbaScaledVector4(Vector4 vector)

14
src/ImageSharp/PixelFormats/PixelImplementations/L8.cs

@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(L8 left, L8 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<L8> CreatePixelOperations() => new PixelOperations();
public PixelOperations<L8> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
float rgb = this.PackedValue / 255F;
return new Vector4(rgb, rgb, rgb, 1F);
@ -138,18 +138,18 @@ namespace SixLabors.ImageSharp.PixelFormats
ImageMaths.DownScaleFrom16BitTo8Bit(source.B));
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is L8 other && this.Equals(other);
public override bool Equals(object obj) => obj is L8 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(L8 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(L8 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly string ToString() => $"L8({this.PackedValue})";
public override string ToString() => $"L8({this.PackedValue})";
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
[MethodImpl(InliningOptions.ShortMethod)]
internal void ConvertFromRgbaScaledVector4(Vector4 vector)

17
src/ImageSharp/PixelFormats/PixelImplementations/La16.cs

@ -45,7 +45,8 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
public ushort PackedValue
{
readonly get => Unsafe.As<La16, ushort>(ref Unsafe.AsRef(this));
get => Unsafe.As<La16, ushort>(ref this);
set => Unsafe.As<La16, ushort>(ref this) = value;
}
@ -72,21 +73,21 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(La16 left, La16 right) => !left.Equals(right);
/// <inheritdoc/>
public readonly PixelOperations<La16> CreatePixelOperations() => new PixelOperations();
public PixelOperations<La16> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(La16 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(La16 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is La16 other && this.Equals(other);
public override bool Equals(object obj) => obj is La16 other && this.Equals(other);
/// <inheritdoc />
public override readonly string ToString() => $"La16({this.L}, {this.A})";
public override string ToString() => $"La16({this.L}, {this.A})";
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -203,11 +204,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
const float Max = 255F;
float rgb = this.L / Max;

18
src/ImageSharp/PixelFormats/PixelImplementations/La32.cs

@ -45,10 +45,8 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
public uint PackedValue
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<La32, uint>(ref Unsafe.AsRef(this));
get => Unsafe.As<La32, uint>(ref this);
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<La32, uint>(ref this) = value;
}
@ -75,21 +73,21 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(La32 left, La32 right) => !left.Equals(right);
/// <inheritdoc/>
public readonly PixelOperations<La32> CreatePixelOperations() => new PixelOperations();
public PixelOperations<La32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(La32 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(La32 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is La32 other && this.Equals(other);
public override bool Equals(object obj) => obj is La32 other && this.Equals(other);
/// <inheritdoc />
public override readonly string ToString() => $"La32({this.L}, {this.A})";
public override string ToString() => $"La32({this.L}, {this.A})";
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -220,11 +218,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
float scaled = this.L / Max;
return new Vector4(scaled, scaled, scaled, this.A / Max);

18
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs

@ -60,20 +60,20 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(NormalizedByte2 left, NormalizedByte2 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<NormalizedByte2> CreatePixelOperations() => new PixelOperations<NormalizedByte2>();
public PixelOperations<NormalizedByte2> CreatePixelOperations() => new PixelOperations<NormalizedByte2>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector)
{
Vector2 scaled = new Vector2(vector.X, vector.Y) * 2F;
var scaled = new Vector2(vector.X, vector.Y) * 2F;
scaled -= Vector2.One;
this.PackedValue = Pack(scaled);
}
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4()
public Vector4 ToScaledVector4()
{
var scaled = this.ToVector2();
scaled += Vector2.One;
@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.ToVector2(), 0F, 1F);
public Vector4 ToVector4() => new Vector4(this.ToVector2(), 0F, 1F);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Vector2"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector2 ToVector2()
public Vector2 ToVector2()
{
return new Vector2(
(sbyte)((this.PackedValue >> 0) & 0xFF) / 127F,
@ -159,18 +159,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is NormalizedByte2 other && this.Equals(other);
public override bool Equals(object obj) => obj is NormalizedByte2 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(NormalizedByte2 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(NormalizedByte2 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector2();
return FormattableString.Invariant($"NormalizedByte2({vector.X:#0.##}, {vector.Y:#0.##})");

14
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs

@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(NormalizedByte4 left, NormalizedByte4 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<NormalizedByte4> CreatePixelOperations() => new PixelOperations<NormalizedByte4>();
public PixelOperations<NormalizedByte4> CreatePixelOperations() => new PixelOperations<NormalizedByte4>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4()
public Vector4 ToScaledVector4()
{
var scaled = this.ToVector4();
scaled += Vector4.One;
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
return new Vector4(
(sbyte)((this.PackedValue >> 0) & 0xFF) / 127F,
@ -154,18 +154,18 @@ namespace SixLabors.ImageSharp.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is NormalizedByte4 other && this.Equals(other);
public override bool Equals(object obj) => obj is NormalizedByte4 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(NormalizedByte4 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(NormalizedByte4 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector4();
return FormattableString.Invariant($"NormalizedByte4({vector.X:#0.##}, {vector.Y:#0.##}, {vector.Z:#0.##}, {vector.W:#0.##})");

18
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs

@ -60,20 +60,20 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(NormalizedShort2 left, NormalizedShort2 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<NormalizedShort2> CreatePixelOperations() => new PixelOperations<NormalizedShort2>();
public PixelOperations<NormalizedShort2> CreatePixelOperations() => new PixelOperations<NormalizedShort2>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector)
{
Vector2 scaled = new Vector2(vector.X, vector.Y) * 2F;
var scaled = new Vector2(vector.X, vector.Y) * 2F;
scaled -= Vector2.One;
this.PackedValue = Pack(scaled);
}
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4()
public Vector4 ToScaledVector4()
{
var scaled = this.ToVector2();
scaled += Vector2.One;
@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.ToVector2(), 0, 1);
public Vector4 ToVector4() => new Vector4(this.ToVector2(), 0, 1);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -154,7 +154,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Vector2"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector2 ToVector2()
public Vector2 ToVector2()
{
const float MaxVal = 0x7FFF;
@ -164,18 +164,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is NormalizedShort2 other && this.Equals(other);
public override bool Equals(object obj) => obj is NormalizedShort2 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(NormalizedShort2 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(NormalizedShort2 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector2();
return FormattableString.Invariant($"NormalizedShort2({vector.X:#0.##}, {vector.Y:#0.##})");

14
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs

@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(NormalizedShort4 left, NormalizedShort4 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<NormalizedShort4> CreatePixelOperations() => new PixelOperations<NormalizedShort4>();
public PixelOperations<NormalizedShort4> CreatePixelOperations() => new PixelOperations<NormalizedShort4>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4()
public Vector4 ToScaledVector4()
{
var scaled = this.ToVector4();
scaled += Vector4.One;
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
const float MaxVal = 0x7FFF;
@ -156,18 +156,18 @@ namespace SixLabors.ImageSharp.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is NormalizedShort4 other && this.Equals(other);
public override bool Equals(object obj) => obj is NormalizedShort4 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(NormalizedShort4 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(NormalizedShort4 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector4();
return FormattableString.Invariant($"NormalizedShort4({vector.X:#0.##}, {vector.Y:#0.##}, {vector.Z:#0.##}, {vector.W:#0.##})");

16
src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs

@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Rg32 left, Rg32 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Rg32> CreatePixelOperations() => new PixelOperations<Rg32>();
public PixelOperations<Rg32> CreatePixelOperations() => new PixelOperations<Rg32>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.ToVector2(), 0F, 1F);
public Vector4 ToVector4() => new Vector4(this.ToVector2(), 0F, 1F);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -142,17 +142,17 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Vector2"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector2 ToVector2() => new Vector2(this.PackedValue & 0xFFFF, (this.PackedValue >> 16) & 0xFFFF) / Max;
public Vector2 ToVector2() => new Vector2(this.PackedValue & 0xFFFF, (this.PackedValue >> 16) & 0xFFFF) / Max;
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Rg32 other && this.Equals(other);
public override bool Equals(object obj) => obj is Rg32 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Rg32 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(Rg32 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector2();
return FormattableString.Invariant($"Rg32({vector.X:#0.##}, {vector.Y:#0.##})");
@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
[MethodImpl(InliningOptions.ShortMethod)]
private static uint Pack(Vector2 vector)

14
src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs

@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Rgb24 left, Rgb24 right) => !left.Equals(right);
/// <inheritdoc/>
public readonly PixelOperations<Rgb24> CreatePixelOperations() => new PixelOperations();
public PixelOperations<Rgb24> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Rgba32(this.R, this.G, this.B, byte.MaxValue).ToVector4();
public Vector4 ToVector4() => new Rgba32(this.R, this.G, this.B, byte.MaxValue).ToVector4();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -232,18 +232,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Rgb24 other && this.Equals(other);
public override bool Equals(object obj) => obj is Rgb24 other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Rgb24 other) => this.R.Equals(other.R) && this.G.Equals(other.G) && this.B.Equals(other.B);
public bool Equals(Rgb24 other) => this.R.Equals(other.R) && this.G.Equals(other.G) && this.B.Equals(other.B);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => HashCode.Combine(this.R, this.B, this.G);
public override int GetHashCode() => HashCode.Combine(this.R, this.B, this.G);
/// <inheritdoc/>
public override readonly string ToString() => $"Rgb24({this.R}, {this.G}, {this.B})";
public override string ToString() => $"Rgb24({this.R}, {this.G}, {this.B})";
/// <summary>
/// Packs a <see cref="Vector4"/> into a color.

14
src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs

@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Rgb48 left, Rgb48 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Rgb48> CreatePixelOperations() => new PixelOperations();
public PixelOperations<Rgb48> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.R / Max, this.G / Max, this.B / Max, 1F);
public Vector4 ToVector4() => new Vector4(this.R / Max, this.G / Max, this.B / Max, 1F);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -201,17 +201,17 @@ namespace SixLabors.ImageSharp.PixelFormats
public void FromRgb48(Rgb48 source) => this = source;
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Rgb48 rgb48 && this.Equals(rgb48);
public override bool Equals(object obj) => obj is Rgb48 rgb48 && this.Equals(rgb48);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Rgb48 other) => this.R.Equals(other.R) && this.G.Equals(other.G) && this.B.Equals(other.B);
public bool Equals(Rgb48 other) => this.R.Equals(other.R) && this.G.Equals(other.G) && this.B.Equals(other.B);
/// <inheritdoc />
public override readonly string ToString() => $"Rgb48({this.R}, {this.G}, {this.B})";
public override string ToString() => $"Rgb48({this.R}, {this.G}, {this.B})";
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => HashCode.Combine(this.R, this.G, this.B);
public override int GetHashCode() => HashCode.Combine(this.R, this.G, this.B);
}
}

14
src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs

@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Rgba1010102 left, Rgba1010102 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Rgba1010102> CreatePixelOperations() => new PixelOperations<Rgba1010102>();
public PixelOperations<Rgba1010102> CreatePixelOperations() => new PixelOperations<Rgba1010102>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
return new Vector4(
(this.PackedValue >> 0) & 0x03FF,
@ -143,14 +143,14 @@ namespace SixLabors.ImageSharp.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Rgba1010102 other && this.Equals(other);
public override bool Equals(object obj) => obj is Rgba1010102 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Rgba1010102 other) => this.PackedValue == other.PackedValue;
public bool Equals(Rgba1010102 other) => this.PackedValue == other.PackedValue;
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector4();
return FormattableString.Invariant($"Rgba1010102({vector.X:#0.##}, {vector.Y:#0.##}, {vector.Z:#0.##}, {vector.W:#0.##})");
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
[MethodImpl(InliningOptions.ShortMethod)]
private static uint Pack(ref Vector4 vector)

24
src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs

@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public uint Rgba
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Rgba32, uint>(ref Unsafe.AsRef(this));
get => Unsafe.As<Rgba32, uint>(ref this);
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Rgba32, uint>(ref this) = value;
@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public Rgb24 Rgb
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => new Rgb24(this.R, this.G, this.B);
get => new Rgb24(this.R, this.G, this.B);
[MethodImpl(InliningOptions.ShortMethod)]
set
@ -154,7 +154,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public Bgr24 Bgr
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => new Bgr24(this.R, this.G, this.B);
get => new Bgr24(this.R, this.G, this.B);
[MethodImpl(InliningOptions.ShortMethod)]
set
@ -169,7 +169,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public uint PackedValue
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => this.Rgba;
get => this.Rgba;
[MethodImpl(InliningOptions.ShortMethod)]
set => this.Rgba = value;
@ -287,7 +287,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public readonly PixelOperations<Rgba32> CreatePixelOperations() => new PixelOperations();
public PixelOperations<Rgba32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -295,7 +295,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -303,7 +303,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A) / MaxBytes;
public Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A) / MaxBytes;
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -422,25 +422,25 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Converts the value of this instance to a hexadecimal string.
/// </summary>
/// <returns>A hexadecimal string representation of the value.</returns>
public readonly string ToHex()
public string ToHex()
{
uint hexOrder = (uint)(this.A << 0 | this.B << 8 | this.G << 16 | this.R << 24);
return hexOrder.ToString("X8");
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Rgba32 rgba32 && this.Equals(rgba32);
public override bool Equals(object obj) => obj is Rgba32 rgba32 && this.Equals(rgba32);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Rgba32 other) => this.Rgba.Equals(other.Rgba);
public bool Equals(Rgba32 other) => this.Rgba.Equals(other.Rgba);
/// <inheritdoc/>
public override readonly string ToString() => $"Rgba32({this.R}, {this.G}, {this.B}, {this.A})";
public override string ToString() => $"Rgba32({this.R}, {this.G}, {this.B}, {this.A})";
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.Rgba.GetHashCode();
public override int GetHashCode() => this.Rgba.GetHashCode();
/// <summary>
/// Packs a <see cref="Vector4"/> into a color returning a new instance as a result.

28
src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs

@ -140,7 +140,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public Rgb48 Rgb
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Rgba64, Rgb48>(ref Unsafe.AsRef(this));
get => Unsafe.As<Rgba64, Rgb48>(ref this);
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Rgba64, Rgb48>(ref this) = value;
@ -150,7 +150,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public ulong PackedValue
{
[MethodImpl(InliningOptions.ShortMethod)]
readonly get => Unsafe.As<Rgba64, ulong>(ref Unsafe.AsRef(this));
get => Unsafe.As<Rgba64, ulong>(ref this);
[MethodImpl(InliningOptions.ShortMethod)]
set => Unsafe.As<Rgba64, ulong>(ref this) = value;
@ -195,7 +195,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Rgba64 left, Rgba64 right) => left.PackedValue != right.PackedValue;
/// <inheritdoc />
public readonly PixelOperations<Rgba64> CreatePixelOperations() => new PixelOperations();
public PixelOperations<Rgba64> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -203,7 +203,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -218,7 +218,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A) / Max;
public Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A) / Max;
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -343,7 +343,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Rgba32"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Rgba32 ToRgba32()
public Rgba32 ToRgba32()
{
byte r = ImageMaths.DownScaleFrom16BitTo8Bit(this.R);
byte g = ImageMaths.DownScaleFrom16BitTo8Bit(this.G);
@ -357,7 +357,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Bgra32"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Bgra32 ToBgra32()
public Bgra32 ToBgra32()
{
byte r = ImageMaths.DownScaleFrom16BitTo8Bit(this.R);
byte g = ImageMaths.DownScaleFrom16BitTo8Bit(this.G);
@ -371,7 +371,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Argb32"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Argb32 ToArgb32()
public Argb32 ToArgb32()
{
byte r = ImageMaths.DownScaleFrom16BitTo8Bit(this.R);
byte g = ImageMaths.DownScaleFrom16BitTo8Bit(this.G);
@ -385,7 +385,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Rgb24"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Rgb24 ToRgb24()
public Rgb24 ToRgb24()
{
byte r = ImageMaths.DownScaleFrom16BitTo8Bit(this.R);
byte g = ImageMaths.DownScaleFrom16BitTo8Bit(this.G);
@ -398,7 +398,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Bgr24"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Bgr24 ToBgr24()
public Bgr24 ToBgr24()
{
byte r = ImageMaths.DownScaleFrom16BitTo8Bit(this.R);
byte g = ImageMaths.DownScaleFrom16BitTo8Bit(this.G);
@ -407,17 +407,17 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Rgba64 rgba64 && this.Equals(rgba64);
public override bool Equals(object obj) => obj is Rgba64 rgba64 && this.Equals(rgba64);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Rgba64 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(Rgba64 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly string ToString() => $"Rgba64({this.R}, {this.G}, {this.B}, {this.A})";
public override string ToString() => $"Rgba64({this.R}, {this.G}, {this.B}, {this.A})";
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
}
}

16
src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs

@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static RgbaVector FromHex(string hex) => Color.ParseHex(hex).ToPixel<RgbaVector>();
/// <inheritdoc />
public readonly PixelOperations<RgbaVector> CreatePixelOperations() => new PixelOperations();
public PixelOperations<RgbaVector> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4() => this.ToVector4();
public Vector4 ToScaledVector4() => this.ToVector4();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A);
public Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -178,7 +178,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Converts the value of this instance to a hexadecimal string.
/// </summary>
/// <returns>A hexadecimal string representation of the value.</returns>
public readonly string ToHex()
public string ToHex()
{
// Hex is RRGGBBAA
Vector4 vector = this.ToVector4() * Max;
@ -188,23 +188,23 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is RgbaVector other && this.Equals(other);
public override bool Equals(object obj) => obj is RgbaVector other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(RgbaVector other) =>
public bool Equals(RgbaVector other) =>
this.R.Equals(other.R)
&& this.G.Equals(other.G)
&& this.B.Equals(other.B)
&& this.A.Equals(other.A);
/// <inheritdoc/>
public override readonly string ToString()
public override string ToString()
{
return FormattableString.Invariant($"RgbaVector({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##}, {this.A:#0.##})");
}
/// <inheritdoc/>
public override readonly int GetHashCode() => HashCode.Combine(this.R, this.G, this.B, this.A);
public override int GetHashCode() => HashCode.Combine(this.R, this.G, this.B, this.A);
}
}

18
src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs

@ -66,20 +66,20 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Short2 left, Short2 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Short2> CreatePixelOperations() => new PixelOperations<Short2>();
public PixelOperations<Short2> CreatePixelOperations() => new PixelOperations<Short2>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector)
{
Vector2 scaled = new Vector2(vector.X, vector.Y) * 65534F;
var scaled = new Vector2(vector.X, vector.Y) * 65534F;
scaled -= new Vector2(32767F);
this.PackedValue = Pack(scaled);
}
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4()
public Vector4 ToScaledVector4()
{
var scaled = this.ToVector2();
scaled += new Vector2(32767F);
@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4((short)(this.PackedValue & 0xFFFF), (short)(this.PackedValue >> 0x10), 0, 1);
public Vector4 ToVector4() => new Vector4((short)(this.PackedValue & 0xFFFF), (short)(this.PackedValue >> 0x10), 0, 1);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -157,21 +157,21 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
/// <returns>The <see cref="Vector2"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector2 ToVector2() => new Vector2((short)(this.PackedValue & 0xFFFF), (short)(this.PackedValue >> 0x10));
public Vector2 ToVector2() => new Vector2((short)(this.PackedValue & 0xFFFF), (short)(this.PackedValue >> 0x10));
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Short2 other && this.Equals(other);
public override bool Equals(object obj) => obj is Short2 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Short2 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(Short2 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector2();
return FormattableString.Invariant($"Short2({vector.X:#0.##}, {vector.Y:#0.##})");

14
src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs

@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Short4 left, Short4 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Short4> CreatePixelOperations() => new PixelOperations<Short4>();
public PixelOperations<Short4> CreatePixelOperations() => new PixelOperations<Short4>();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToScaledVector4()
public Vector4 ToScaledVector4()
{
var scaled = this.ToVector4();
scaled += new Vector4(32767F);
@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4()
public Vector4 ToVector4()
{
return new Vector4(
(short)(this.PackedValue & 0xFFFF),
@ -160,21 +160,21 @@ namespace SixLabors.ImageSharp.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Short4 other && this.Equals(other);
public override bool Equals(object obj) => obj is Short4 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public readonly bool Equals(Short4 other) => this.PackedValue.Equals(other);
public bool Equals(Short4 other) => this.PackedValue.Equals(other);
/// <summary>
/// Gets the hash code for the current instance.
/// </summary>
/// <returns>Hash code for the instance.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
public override int GetHashCode() => this.PackedValue.GetHashCode();
/// <inheritdoc />
public override readonly string ToString()
public override string ToString()
{
var vector = this.ToVector4();
return FormattableString.Invariant($"Short4({vector.X:#0.##}, {vector.Y:#0.##}, {vector.Z:#0.##}, {vector.W:#0.##})");

Loading…
Cancel
Save