Browse Source

Cleanup

pull/1790/head
Brian Popow 4 years ago
parent
commit
49e57722b8
  1. 2
      src/ImageSharp/PixelFormats/PixelImplementations/A8.cs
  2. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
  3. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs
  4. 12
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs
  5. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
  6. 5
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs
  7. 10
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs
  8. 10
      src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs
  9. 7
      src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs
  10. 5
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
  11. 10
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs
  12. 25
      src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
  13. 4
      src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
  14. 6
      src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
  15. 2
      src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
  16. 11
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
  17. 14
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs
  18. 12
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
  19. 12
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs
  20. 9
      src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs
  21. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs
  22. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs
  23. 12
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs
  24. 19
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
  25. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
  26. 13
      src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
  27. 8
      src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
  28. 3
      tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs
  29. 11
      tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs
  30. 24
      tests/ImageSharp.Tests/PixelFormats/L8Tests.cs
  31. 24
      tests/ImageSharp.Tests/PixelFormats/La16Tests.cs
  32. 6
      tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs
  33. 42
      tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.cs
  34. 4
      tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs
  35. 2
      tests/ImageSharp.Tests/PixelFormats/UnPackedPixelTests.cs

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

@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(0, 0, 0, this.PackedValue / 255F); public readonly Vector4 ToVector4() => new(0, 0, 0, this.PackedValue / 255F);
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -44,12 +44,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.
/// </summary> /// </summary>
private static readonly Vector4 MaxBytes = new Vector4(255); private static readonly Vector4 MaxBytes = new(255);
/// <summary> /// <summary>
/// The half vector value. /// The half vector value.
/// </summary> /// </summary>
private static readonly Vector4 Half = new Vector4(0.5F); private static readonly Vector4 Half = new(0.5F);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Argb32"/> struct. /// Initializes a new instance of the <see cref="Argb32"/> struct.
@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="source">The <see cref="Argb32"/>.</param> /// <param name="source">The <see cref="Argb32"/>.</param>
/// <returns>The <see cref="Color"/>.</returns> /// <returns>The <see cref="Color"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public static implicit operator Color(Argb32 source) => new Color(source); public static implicit operator Color(Argb32 source) => new(source);
/// <summary> /// <summary>
/// Converts a <see cref="Color"/> to <see cref="Argb32"/>. /// Converts a <see cref="Color"/> to <see cref="Argb32"/>.

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

@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="source">The <see cref="Bgr24"/>.</param> /// <param name="source">The <see cref="Bgr24"/>.</param>
/// <returns>The <see cref="Color"/>.</returns> /// <returns>The <see cref="Color"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public static implicit operator Color(Bgr24 source) => new Color(source); public static implicit operator Color(Bgr24 source) => new(source);
/// <summary> /// <summary>
/// Converts a <see cref="Color"/> to <see cref="Bgr24"/>. /// Converts a <see cref="Color"/> to <see cref="Bgr24"/>.
@ -225,7 +225,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public override readonly bool Equals(object obj) => obj is Bgr24 other && this.Equals(other); public override readonly bool Equals(object obj) => obj is Bgr24 other && this.Equals(other);
/// <inheritdoc /> /// <inheritdoc />
public override readonly string ToString() => $"Bgra({this.B}, {this.G}, {this.R})"; public override readonly string ToString() => $"Bgr24({this.B}, {this.G}, {this.R})";
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.ToVector3(), 1F); public readonly Vector4 ToVector4() => new(this.ToVector3(), 1F);
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -125,10 +125,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -144,13 +141,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
/// <returns>The <see cref="Vector3"/>.</returns> /// <returns>The <see cref="Vector3"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector3 ToVector3() public readonly Vector3 ToVector3() => new(
{
return new Vector3(
((this.PackedValue >> 11) & 0x1F) * (1F / 31F), ((this.PackedValue >> 11) & 0x1F) * (1F / 31F),
((this.PackedValue >> 5) & 0x3F) * (1F / 63F), ((this.PackedValue >> 5) & 0x3F) * (1F / 63F),
(this.PackedValue & 0x1F) * (1F / 31F)); (this.PackedValue & 0x1F) * (1F / 31F));
}
/// <inheritdoc /> /// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Bgr565 other && this.Equals(other); public override readonly bool Equals(object obj) => obj is Bgr565 other && this.Equals(other);

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

@ -41,12 +41,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.
/// </summary> /// </summary>
private static readonly Vector4 MaxBytes = new Vector4(255); private static readonly Vector4 MaxBytes = new(255);
/// <summary> /// <summary>
/// The half vector value. /// The half vector value.
/// </summary> /// </summary>
private static readonly Vector4 Half = new Vector4(0.5F); private static readonly Vector4 Half = new(0.5F);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Bgra32"/> struct. /// Initializes a new instance of the <see cref="Bgra32"/> struct.
@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="source">The <see cref="Bgra32"/>.</param> /// <param name="source">The <see cref="Bgra32"/>.</param>
/// <returns>The <see cref="Color"/>.</returns> /// <returns>The <see cref="Color"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public static implicit operator Color(Bgra32 source) => new Color(source); public static implicit operator Color(Bgra32 source) => new(source);
/// <summary> /// <summary>
/// Converts a <see cref="Color"/> to <see cref="Bgra32"/>. /// Converts a <see cref="Color"/> to <see cref="Bgra32"/>.

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

@ -128,10 +128,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -78,14 +78,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() public readonly Vector4 ToVector4() => new(
{
return new Vector4(
((this.PackedValue >> 10) & 0x1F) / 31F, ((this.PackedValue >> 10) & 0x1F) / 31F,
((this.PackedValue >> 5) & 0x1F) / 31F, ((this.PackedValue >> 5) & 0x1F) / 31F,
((this.PackedValue >> 0) & 0x1F) / 31F, ((this.PackedValue >> 0) & 0x1F) / 31F,
(this.PackedValue >> 15) & 0x01); (this.PackedValue >> 15) & 0x01);
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -129,10 +126,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -78,14 +78,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() public readonly Vector4 ToVector4() => new(
{
return new Vector4(
this.PackedValue & 0xFF, this.PackedValue & 0xFF,
(this.PackedValue >> 0x8) & 0xFF, (this.PackedValue >> 0x8) & 0xFF,
(this.PackedValue >> 0x10) & 0xFF, (this.PackedValue >> 0x10) & 0xFF,
(this.PackedValue >> 0x18) & 0xFF); (this.PackedValue >> 0x18) & 0xFF);
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -129,10 +126,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.ToSingle(), 0, 0, 1F); public readonly Vector4 ToVector4() => new(this.ToSingle(), 0, 0, 1F);
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -118,10 +118,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -129,10 +129,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -86,14 +86,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() public readonly Vector4 ToVector4() => new(
{
return new Vector4(
HalfTypeHelper.Unpack((ushort)this.PackedValue), HalfTypeHelper.Unpack((ushort)this.PackedValue),
HalfTypeHelper.Unpack((ushort)(this.PackedValue >> 0x10)), HalfTypeHelper.Unpack((ushort)(this.PackedValue >> 0x10)),
HalfTypeHelper.Unpack((ushort)(this.PackedValue >> 0x20)), HalfTypeHelper.Unpack((ushort)(this.PackedValue >> 0x20)),
HalfTypeHelper.Unpack((ushort)(this.PackedValue >> 0x30))); HalfTypeHelper.Unpack((ushort)(this.PackedValue >> 0x30)));
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -137,10 +134,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -72,33 +72,24 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromArgb32(Argb32 source) public void FromArgb32(Argb32 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
{
this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
ColorNumerics.UpscaleFrom8BitTo16Bit(source.R), ColorNumerics.UpscaleFrom8BitTo16Bit(source.R),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.G), ColorNumerics.UpscaleFrom8BitTo16Bit(source.G),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.B)); ColorNumerics.UpscaleFrom8BitTo16Bit(source.B));
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromBgr24(Bgr24 source) public void FromBgr24(Bgr24 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
{
this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
ColorNumerics.UpscaleFrom8BitTo16Bit(source.R), ColorNumerics.UpscaleFrom8BitTo16Bit(source.R),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.G), ColorNumerics.UpscaleFrom8BitTo16Bit(source.G),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.B)); ColorNumerics.UpscaleFrom8BitTo16Bit(source.B));
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromBgra32(Bgra32 source) public void FromBgra32(Bgra32 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
{
this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
ColorNumerics.UpscaleFrom8BitTo16Bit(source.R), ColorNumerics.UpscaleFrom8BitTo16Bit(source.R),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.G), ColorNumerics.UpscaleFrom8BitTo16Bit(source.G),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.B)); ColorNumerics.UpscaleFrom8BitTo16Bit(source.B));
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -122,23 +113,17 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromRgb24(Rgb24 source) public void FromRgb24(Rgb24 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
{
this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
ColorNumerics.UpscaleFrom8BitTo16Bit(source.R), ColorNumerics.UpscaleFrom8BitTo16Bit(source.R),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.G), ColorNumerics.UpscaleFrom8BitTo16Bit(source.G),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.B)); ColorNumerics.UpscaleFrom8BitTo16Bit(source.B));
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromRgba32(Rgba32 source) public void FromRgba32(Rgba32 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
{
this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
ColorNumerics.UpscaleFrom8BitTo16Bit(source.R), ColorNumerics.UpscaleFrom8BitTo16Bit(source.R),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.G), ColorNumerics.UpscaleFrom8BitTo16Bit(source.G),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.B)); ColorNumerics.UpscaleFrom8BitTo16Bit(source.B));
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -14,8 +14,8 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
public partial struct L8 : IPixel<L8>, IPackedVector<byte> public partial struct L8 : IPixel<L8>, IPackedVector<byte>
{ {
private static readonly Vector4 MaxBytes = new Vector4(255F); private static readonly Vector4 MaxBytes = new(255F);
private static readonly Vector4 Half = new Vector4(0.5F); private static readonly Vector4 Half = new(0.5F);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="L8"/> struct. /// Initializes a new instance of the <see cref="L8"/> struct.

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

@ -16,8 +16,8 @@ namespace SixLabors.ImageSharp.PixelFormats
[StructLayout(LayoutKind.Explicit)] [StructLayout(LayoutKind.Explicit)]
public partial struct La16 : IPixel<La16>, IPackedVector<ushort> public partial struct La16 : IPixel<La16>, IPackedVector<ushort>
{ {
private static readonly Vector4 MaxBytes = new Vector4(255F); private static readonly Vector4 MaxBytes = new(255F);
private static readonly Vector4 Half = new Vector4(0.5F); private static readonly Vector4 Half = new(0.5F);
/// <summary> /// <summary>
/// Gets or sets the luminance component. /// Gets or sets the luminance component.
@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Initializes a new instance of the <see cref="La16"/> struct. /// Initializes a new instance of the <see cref="La16"/> struct.
/// </summary> /// </summary>
/// <param name="l">The luminance component.</param> /// <param name="l">The luminance component.</param>
/// <param name="a">The alpha componant.</param> /// <param name="a">The alpha component.</param>
public La16(byte l, byte a) public La16(byte l, byte a)
{ {
this.L = l; this.L = l;

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

@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Initializes a new instance of the <see cref="La32"/> struct. /// Initializes a new instance of the <see cref="La32"/> struct.
/// </summary> /// </summary>
/// <param name="l">The luminance component.</param> /// <param name="l">The luminance component.</param>
/// <param name="a">The alpha componant.</param> /// <param name="a">The alpha component.</param>
public La32(ushort l, ushort a) public La32(ushort l, ushort a)
{ {
this.L = l; this.L = l;

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

@ -17,8 +17,8 @@ namespace SixLabors.ImageSharp.PixelFormats
{ {
private const float MaxPos = 127F; private const float MaxPos = 127F;
private static readonly Vector2 Half = new Vector2(MaxPos); private static readonly Vector2 Half = new(MaxPos);
private static readonly Vector2 MinusOne = new Vector2(-1F); private static readonly Vector2 MinusOne = new(-1F);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="NormalizedByte2"/> struct. /// Initializes a new instance of the <see cref="NormalizedByte2"/> struct.
@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.ToVector2(), 0F, 1F); public readonly Vector4 ToVector4() => new(this.ToVector2(), 0F, 1F);
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -153,12 +153,9 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
/// <returns>The <see cref="Vector2"/>.</returns> /// <returns>The <see cref="Vector2"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector2 ToVector2() public readonly Vector2 ToVector2() => new(
{
return new Vector2(
(sbyte)((this.PackedValue >> 0) & 0xFF) / MaxPos, (sbyte)((this.PackedValue >> 0) & 0xFF) / MaxPos,
(sbyte)((this.PackedValue >> 8) & 0xFF) / MaxPos); (sbyte)((this.PackedValue >> 8) & 0xFF) / MaxPos);
}
/// <inheritdoc /> /// <inheritdoc />
public override readonly bool Equals(object obj) => obj is NormalizedByte2 other && this.Equals(other); public override readonly bool Equals(object obj) => obj is NormalizedByte2 other && this.Equals(other);

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

@ -17,8 +17,8 @@ namespace SixLabors.ImageSharp.PixelFormats
{ {
private const float MaxPos = 127F; private const float MaxPos = 127F;
private static readonly Vector4 Half = new Vector4(MaxPos); private static readonly Vector4 Half = new(MaxPos);
private static readonly Vector4 MinusOne = new Vector4(-1F); private static readonly Vector4 MinusOne = new(-1F);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="NormalizedByte4"/> struct. /// Initializes a new instance of the <see cref="NormalizedByte4"/> struct.
@ -91,14 +91,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() public readonly Vector4 ToVector4() => new(
{
return new Vector4(
(sbyte)((this.PackedValue >> 0) & 0xFF) / MaxPos, (sbyte)((this.PackedValue >> 0) & 0xFF) / MaxPos,
(sbyte)((this.PackedValue >> 8) & 0xFF) / MaxPos, (sbyte)((this.PackedValue >> 8) & 0xFF) / MaxPos,
(sbyte)((this.PackedValue >> 16) & 0xFF) / MaxPos, (sbyte)((this.PackedValue >> 16) & 0xFF) / MaxPos,
(sbyte)((this.PackedValue >> 24) & 0xFF) / MaxPos); (sbyte)((this.PackedValue >> 24) & 0xFF) / MaxPos);
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -142,10 +139,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.PixelFormats
// Largest two byte positive number 0xFFFF >> 1; // Largest two byte positive number 0xFFFF >> 1;
private const float MaxPos = 0x7FFF; private const float MaxPos = 0x7FFF;
private static readonly Vector2 Max = new Vector2(MaxPos); private static readonly Vector2 Max = new(MaxPos);
private static readonly Vector2 Min = Vector2.Negate(Max); private static readonly Vector2 Min = Vector2.Negate(Max);
/// <summary> /// <summary>
@ -138,10 +138,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -157,12 +154,9 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
/// <returns>The <see cref="Vector2"/>.</returns> /// <returns>The <see cref="Vector2"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector2 ToVector2() public readonly Vector2 ToVector2() => new(
{
return new Vector2(
(short)(this.PackedValue & 0xFFFF) / MaxPos, (short)(this.PackedValue & 0xFFFF) / MaxPos,
(short)(this.PackedValue >> 0x10) / MaxPos); (short)(this.PackedValue >> 0x10) / MaxPos);
}
/// <inheritdoc /> /// <inheritdoc />
public override readonly bool Equals(object obj) => obj is NormalizedShort2 other && this.Equals(other); public override readonly bool Equals(object obj) => obj is NormalizedShort2 other && this.Equals(other);

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

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.PixelFormats
// Largest two byte positive number 0xFFFF >> 1; // Largest two byte positive number 0xFFFF >> 1;
private const float MaxPos = 0x7FFF; private const float MaxPos = 0x7FFF;
private static readonly Vector4 Max = new Vector4(MaxPos); private static readonly Vector4 Max = new(MaxPos);
private static readonly Vector4 Min = Vector4.Negate(Max); private static readonly Vector4 Min = Vector4.Negate(Max);
/// <summary> /// <summary>
@ -92,14 +92,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() public readonly Vector4 ToVector4() => new(
{
return new Vector4(
(short)((this.PackedValue >> 0x00) & 0xFFFF) / MaxPos, (short)((this.PackedValue >> 0x00) & 0xFFFF) / MaxPos,
(short)((this.PackedValue >> 0x10) & 0xFFFF) / MaxPos, (short)((this.PackedValue >> 0x10) & 0xFFFF) / MaxPos,
(short)((this.PackedValue >> 0x20) & 0xFFFF) / MaxPos, (short)((this.PackedValue >> 0x20) & 0xFFFF) / MaxPos,
(short)((this.PackedValue >> 0x30) & 0xFFFF) / MaxPos); (short)((this.PackedValue >> 0x30) & 0xFFFF) / MaxPos);
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -143,10 +140,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
public partial struct Rg32 : IPixel<Rg32>, IPackedVector<uint> public partial struct Rg32 : IPixel<Rg32>, IPackedVector<uint>
{ {
private static readonly Vector2 Max = new Vector2(ushort.MaxValue); private static readonly Vector2 Max = new(ushort.MaxValue);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Rg32"/> struct. /// Initializes a new instance of the <see cref="Rg32"/> struct.
@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.ToVector2(), 0F, 1F); public readonly Vector4 ToVector4() => new(this.ToVector2(), 0F, 1F);
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -123,10 +123,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -36,8 +36,8 @@ namespace SixLabors.ImageSharp.PixelFormats
[FieldOffset(2)] [FieldOffset(2)]
public byte B; public byte B;
private static readonly Vector4 MaxBytes = new Vector4(byte.MaxValue); private static readonly Vector4 MaxBytes = new(byte.MaxValue);
private static readonly Vector4 Half = new Vector4(0.5F); private static readonly Vector4 Half = new(0.5F);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Rgb24"/> struct. /// Initializes a new instance of the <see cref="Rgb24"/> struct.

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

@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.R / Max, this.G / Max, this.B / Max, 1F); public readonly Vector4 ToVector4() => new(this.R / Max, this.G / Max, this.B / Max, 1F);
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
public partial struct Rgba1010102 : IPixel<Rgba1010102>, IPackedVector<uint> public partial struct Rgba1010102 : IPixel<Rgba1010102>, IPackedVector<uint>
{ {
private static readonly Vector4 Multiplier = new Vector4(1023F, 1023F, 1023F, 3F); private static readonly Vector4 Multiplier = new(1023F, 1023F, 1023F, 3F);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Rgba1010102"/> struct. /// Initializes a new instance of the <see cref="Rgba1010102"/> struct.
@ -78,14 +78,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() public readonly Vector4 ToVector4() => new Vector4(
{
return new Vector4(
(this.PackedValue >> 0) & 0x03FF, (this.PackedValue >> 0) & 0x03FF,
(this.PackedValue >> 10) & 0x03FF, (this.PackedValue >> 10) & 0x03FF,
(this.PackedValue >> 20) & 0x03FF, (this.PackedValue >> 20) & 0x03FF,
(this.PackedValue >> 30) & 0x03) / Multiplier; (this.PackedValue >> 30) & 0x03) / Multiplier;
}
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -129,10 +126,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
{
dest.FromScaledVector4(this.ToScaledVector4());
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

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

@ -44,8 +44,8 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
public byte A; public byte A;
private static readonly Vector4 MaxBytes = new Vector4(byte.MaxValue); private static readonly Vector4 MaxBytes = new(byte.MaxValue);
private static readonly Vector4 Half = new Vector4(0.5F); private static readonly Vector4 Half = new(0.5F);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Rgba32"/> struct. /// Initializes a new instance of the <see cref="Rgba32"/> struct.
@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public Rgb24 Rgb public Rgb24 Rgb
{ {
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
readonly get => new Rgb24(this.R, this.G, this.B); readonly get => new(this.R, this.G, this.B);
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
set set
@ -154,7 +154,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public Bgr24 Bgr public Bgr24 Bgr
{ {
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
readonly get => new Bgr24(this.R, this.G, this.B); readonly get => new(this.R, this.G, this.B);
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
set set
@ -181,7 +181,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="source">The <see cref="Rgba32"/>.</param> /// <param name="source">The <see cref="Rgba32"/>.</param>
/// <returns>The <see cref="Color"/>.</returns> /// <returns>The <see cref="Color"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public static implicit operator Color(Rgba32 source) => new Color(source); public static implicit operator Color(Rgba32 source) => new(source);
/// <summary> /// <summary>
/// Converts a <see cref="Color"/> to <see cref="Rgba32"/>. /// Converts a <see cref="Color"/> to <see cref="Rgba32"/>.
@ -393,10 +393,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest) => dest = this;
{
dest = this;
}
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -424,7 +421,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <returns>A hexadecimal string representation of the value.</returns> /// <returns>A hexadecimal string representation of the value.</returns>
public readonly string ToHex() public readonly string ToHex()
{ {
uint hexOrder = (uint)(this.A << 0 | this.B << 8 | this.G << 16 | this.R << 24); uint hexOrder = (uint)((this.A << 0) | (this.B << 8) | (this.G << 16) | (this.R << 24));
return hexOrder.ToString("X8"); return hexOrder.ToString("X8");
} }
@ -523,7 +520,7 @@ namespace SixLabors.ImageSharp.PixelFormats
return hex + "FF"; return hex + "FF";
} }
if (hex.Length < 3 || hex.Length > 4) if (hex.Length is < 3 or > 4)
{ {
return null; return null;
} }

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

@ -162,7 +162,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <param name="source">The <see cref="Rgba64"/>.</param> /// <param name="source">The <see cref="Rgba64"/>.</param>
/// <returns>The <see cref="Color"/>.</returns> /// <returns>The <see cref="Color"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public static implicit operator Color(Rgba64 source) => new Color(source); public static implicit operator Color(Rgba64 source) => new(source);
/// <summary> /// <summary>
/// Converts a <see cref="Color"/> to <see cref="Rgba64"/>. /// Converts a <see cref="Color"/> to <see cref="Rgba64"/>.

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

@ -43,8 +43,8 @@ namespace SixLabors.ImageSharp.PixelFormats
public float A; public float A;
private const float MaxBytes = byte.MaxValue; private const float MaxBytes = byte.MaxValue;
private static readonly Vector4 Max = new Vector4(MaxBytes); private static readonly Vector4 Max = new(MaxBytes);
private static readonly Vector4 Half = new Vector4(0.5F); private static readonly Vector4 Half = new(0.5F);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="RgbaVector"/> struct. /// Initializes a new instance of the <see cref="RgbaVector"/> struct.
@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A); public readonly Vector4 ToVector4() => new(this.R, this.G, this.B, this.A);
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.PixelFormats
// Hex is RRGGBBAA // Hex is RRGGBBAA
Vector4 vector = this.ToVector4() * Max; Vector4 vector = this.ToVector4() * Max;
vector += Half; vector += Half;
uint hexOrder = (uint)((byte)vector.W | (byte)vector.Z << 8 | (byte)vector.Y << 16 | (byte)vector.X << 24); uint hexOrder = (uint)((byte)vector.W | ((byte)vector.Z << 8) | ((byte)vector.Y << 16) | ((byte)vector.X << 24));
return hexOrder.ToString("X8"); return hexOrder.ToString("X8");
} }
@ -199,10 +199,7 @@ namespace SixLabors.ImageSharp.PixelFormats
&& this.A.Equals(other.A); && this.A.Equals(other.A);
/// <inheritdoc/> /// <inheritdoc/>
public override readonly string ToString() public override readonly string ToString() => FormattableString.Invariant($"RgbaVector({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##}, {this.A:#0.##})");
{
return FormattableString.Invariant($"RgbaVector({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##}, {this.A:#0.##})");
}
/// <inheritdoc/> /// <inheritdoc/>
public override readonly int GetHashCode() => HashCode.Combine(this.R, this.G, this.B, this.A); public override readonly int GetHashCode() => HashCode.Combine(this.R, this.G, this.B, this.A);

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

@ -21,8 +21,8 @@ namespace SixLabors.ImageSharp.PixelFormats
// Two's complement // Two's complement
private const float MinNeg = ~(int)MaxPos; private const float MinNeg = ~(int)MaxPos;
private static readonly Vector2 Max = new Vector2(MaxPos); private static readonly Vector2 Max = new(MaxPos);
private static readonly Vector2 Min = new Vector2(MinNeg); private static readonly Vector2 Min = new(MinNeg);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Short2"/> struct. /// Initializes a new instance of the <see cref="Short2"/> struct.
@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector4 ToVector4() => new Vector4((short)(this.PackedValue & 0xFFFF), (short)(this.PackedValue >> 0x10), 0, 1); public readonly Vector4 ToVector4() => new((short)(this.PackedValue & 0xFFFF), (short)(this.PackedValue >> 0x10), 0, 1);
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
/// <returns>The <see cref="Vector2"/>.</returns> /// <returns>The <see cref="Vector2"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public readonly Vector2 ToVector2() => new Vector2((short)(this.PackedValue & 0xFFFF), (short)(this.PackedValue >> 0x10)); public readonly Vector2 ToVector2() => new((short)(this.PackedValue & 0xFFFF), (short)(this.PackedValue >> 0x10));
/// <inheritdoc /> /// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Short2 other && this.Equals(other); public override readonly bool Equals(object obj) => obj is Short2 other && this.Equals(other);

3
tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs

@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.NotEqual(color1, color2); Assert.NotEqual(color1, color2);
} }
public static readonly TheoryData<byte, byte, byte> ColorData = public static readonly TheoryData<byte, byte, byte> ColorData = new() { { 1, 2, 3 }, { 4, 5, 6 }, { 0, 255, 42 } };
new TheoryData<byte, byte, byte> { { 1, 2, 3 }, { 4, 5, 6 }, { 0, 255, 42 } };
[Theory] [Theory]
[MemberData(nameof(ColorData))] [MemberData(nameof(ColorData))]

11
tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs

@ -35,10 +35,13 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
} }
public static readonly TheoryData<byte, byte, byte, byte> ColorData = public static readonly TheoryData<byte, byte, byte, byte> ColorData =
new TheoryData<byte, byte, byte, byte> new()
{ {
{ 1, 2, 3, 4 }, { 4, 5, 6, 7 }, { 0, 255, 42, 0 }, { 1, 2, 3, 255 } { 1, 2, 3, 4 },
}; { 4, 5, 6, 7 },
{ 0, 255, 42, 0 },
{ 1, 2, 3, 255 }
};
[Theory] [Theory]
[MemberData(nameof(ColorData))] [MemberData(nameof(ColorData))]

24
tests/ImageSharp.Tests/PixelFormats/L8Tests.cs

@ -12,29 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public class L8Tests public class L8Tests
{ {
public static readonly TheoryData<byte> LuminanceData public static readonly TheoryData<byte> LuminanceData
= new TheoryData<byte> = new() { 0, 1, 2, 3, 5, 13, 31, 71, 73, 79, 83, 109, 127, 128, 131, 199, 250, 251, 254, 255 };
{
0,
1,
2,
3,
5,
13,
31,
71,
73,
79,
83,
109,
127,
128,
131,
199,
250,
251,
254,
255
};
[Theory] [Theory]
[InlineData(0)] [InlineData(0)]

24
tests/ImageSharp.Tests/PixelFormats/La16Tests.cs

@ -12,29 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public class La16Tests public class La16Tests
{ {
public static readonly TheoryData<byte> LuminanceData public static readonly TheoryData<byte> LuminanceData
= new TheoryData<byte> = new() { 0, 1, 2, 3, 5, 13, 31, 71, 73, 79, 83, 109, 127, 128, 131, 199, 250, 251, 254, 255 };
{
0,
1,
2,
3,
5,
13,
31,
71,
73,
79,
83,
109,
127,
128,
131,
199,
250,
251,
254,
255
};
[Theory] [Theory]
[InlineData(0, 0)] [InlineData(0, 0)]

6
tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs

@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Trait("Category", "PixelFormats")] [Trait("Category", "PixelFormats")]
public class PixelBlenderTests public class PixelBlenderTests
{ {
public static TheoryData<object, Type, PixelColorBlendingMode> BlenderMappings = new TheoryData<object, Type, PixelColorBlendingMode> public static TheoryData<object, Type, PixelColorBlendingMode> BlenderMappings = new()
{ {
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.NormalSrcOver), PixelColorBlendingMode.Normal }, { new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.NormalSrcOver), PixelColorBlendingMode.Normal },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.ScreenSrcOver), PixelColorBlendingMode.Screen }, { new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.ScreenSrcOver), PixelColorBlendingMode.Screen },
@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.IsType(type, blender); Assert.IsType(type, blender);
} }
public static TheoryData<Rgba32, Rgba32, float, PixelColorBlendingMode, Rgba32> ColorBlendingExpectedResults = new TheoryData<Rgba32, Rgba32, float, PixelColorBlendingMode, Rgba32> public static TheoryData<Rgba32, Rgba32, float, PixelColorBlendingMode, Rgba32> ColorBlendingExpectedResults = new()
{ {
{ Color.MistyRose, Color.MidnightBlue, 1, PixelColorBlendingMode.Normal, Color.MidnightBlue }, { Color.MistyRose, Color.MidnightBlue, 1, PixelColorBlendingMode.Normal, Color.MidnightBlue },
{ Color.MistyRose, Color.MidnightBlue, 1, PixelColorBlendingMode.Screen, new Rgba32(0xFFEEE7FF) }, { Color.MistyRose, Color.MidnightBlue, 1, PixelColorBlendingMode.Screen, new Rgba32(0xFFEEE7FF) },
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.Equal(actualResult.ToVector4(), expectedResult.ToVector4()); Assert.Equal(actualResult.ToVector4(), expectedResult.ToVector4());
} }
public static TheoryData<Rgba32, Rgba32, float, PixelAlphaCompositionMode, Rgba32> AlphaCompositionExpectedResults = new TheoryData<Rgba32, Rgba32, float, PixelAlphaCompositionMode, Rgba32> public static TheoryData<Rgba32, Rgba32, float, PixelAlphaCompositionMode, Rgba32> AlphaCompositionExpectedResults = new()
{ {
{ Color.MistyRose, Color.MidnightBlue, 1, PixelAlphaCompositionMode.Clear, new Rgba32(0) }, { Color.MistyRose, Color.MidnightBlue, 1, PixelAlphaCompositionMode.Clear, new Rgba32(0) },
{ Color.MistyRose, Color.MidnightBlue, 1, PixelAlphaCompositionMode.Xor, new Rgba32(0) }, { Color.MistyRose, Color.MidnightBlue, 1, PixelAlphaCompositionMode.Xor, new Rgba32(0) },

42
tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.cs

@ -11,21 +11,21 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public abstract partial class PixelConverterTests public abstract partial class PixelConverterTests
{ {
public static readonly TheoryData<byte, byte, byte, byte> RgbaData = public static readonly TheoryData<byte, byte, byte, byte> RgbaData =
new TheoryData<byte, byte, byte, byte> new()
{ {
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 255 }, { 0, 0, 0, 255 },
{ 0, 0, 255, 0 }, { 0, 0, 255, 0 },
{ 0, 255, 0, 0 }, { 0, 255, 0, 0 },
{ 255, 0, 0, 0 }, { 255, 0, 0, 0 },
{ 255, 255, 255, 255 }, { 255, 255, 255, 255 },
{ 0, 0, 0, 1 }, { 0, 0, 0, 1 },
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 },
{ 0, 1, 0, 0 }, { 0, 1, 0, 0 },
{ 1, 0, 0, 0 }, { 1, 0, 0, 0 },
{ 3, 5, 7, 11 }, { 3, 5, 7, 11 },
{ 67, 71, 101, 109 } { 67, 71, 101, 109 }
}; };
public class FromRgba32 : PixelConverterTests public class FromRgba32 : PixelConverterTests
{ {
@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public void ToArgb32(byte r, byte g, byte b, byte a) public void ToArgb32(byte r, byte g, byte b, byte a)
{ {
byte[] source = ReferenceImplementations.MakeRgba32ByteArray(r, g, b, a); byte[] source = ReferenceImplementations.MakeRgba32ByteArray(r, g, b, a);
var actual = new byte[source.Length]; byte[] actual = new byte[source.Length];
PixelConverter.FromRgba32.ToArgb32(source, actual); PixelConverter.FromRgba32.ToArgb32(source, actual);
@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public void ToBgra32(byte r, byte g, byte b, byte a) public void ToBgra32(byte r, byte g, byte b, byte a)
{ {
byte[] source = ReferenceImplementations.MakeRgba32ByteArray(r, g, b, a); byte[] source = ReferenceImplementations.MakeRgba32ByteArray(r, g, b, a);
var actual = new byte[source.Length]; byte[] actual = new byte[source.Length];
PixelConverter.FromRgba32.ToBgra32(source, actual); PixelConverter.FromRgba32.ToBgra32(source, actual);
@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public void ToRgba32(byte r, byte g, byte b, byte a) public void ToRgba32(byte r, byte g, byte b, byte a)
{ {
byte[] source = ReferenceImplementations.MakeArgb32ByteArray(r, g, b, a); byte[] source = ReferenceImplementations.MakeArgb32ByteArray(r, g, b, a);
var actual = new byte[source.Length]; byte[] actual = new byte[source.Length];
PixelConverter.FromArgb32.ToRgba32(source, actual); PixelConverter.FromArgb32.ToRgba32(source, actual);
@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public void ToBgra32(byte r, byte g, byte b, byte a) public void ToBgra32(byte r, byte g, byte b, byte a)
{ {
byte[] source = ReferenceImplementations.MakeArgb32ByteArray(r, g, b, a); byte[] source = ReferenceImplementations.MakeArgb32ByteArray(r, g, b, a);
var actual = new byte[source.Length]; byte[] actual = new byte[source.Length];
PixelConverter.FromArgb32.ToBgra32(source, actual); PixelConverter.FromArgb32.ToBgra32(source, actual);
@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public void ToArgb32(byte r, byte g, byte b, byte a) public void ToArgb32(byte r, byte g, byte b, byte a)
{ {
byte[] source = ReferenceImplementations.MakeBgra32ByteArray(r, g, b, a); byte[] source = ReferenceImplementations.MakeBgra32ByteArray(r, g, b, a);
var actual = new byte[source.Length]; byte[] actual = new byte[source.Length];
PixelConverter.FromBgra32.ToArgb32(source, actual); PixelConverter.FromBgra32.ToArgb32(source, actual);
@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public void ToRgba32(byte r, byte g, byte b, byte a) public void ToRgba32(byte r, byte g, byte b, byte a)
{ {
byte[] source = ReferenceImplementations.MakeBgra32ByteArray(r, g, b, a); byte[] source = ReferenceImplementations.MakeBgra32ByteArray(r, g, b, a);
var actual = new byte[source.Length]; byte[] actual = new byte[source.Length];
PixelConverter.FromBgra32.ToRgba32(source, actual); PixelConverter.FromBgra32.ToRgba32(source, actual);

4
tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs

@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public class Rgb24Tests public class Rgb24Tests
{ {
public static readonly TheoryData<byte, byte, byte> ColorData = public static readonly TheoryData<byte, byte, byte> ColorData =
new TheoryData<byte, byte, byte> new()
{ {
{ 1, 2, 3 }, { 1, 2, 3 },
{ 4, 5, 6 }, { 4, 5, 6 },
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.Equal(3, rgb.B); Assert.Equal(3, rgb.B);
} }
private static Vector4 Vec(byte r, byte g, byte b, byte a = 255) => new Vector4( private static Vector4 Vec(byte r, byte g, byte b, byte a = 255) => new(
r / 255f, r / 255f,
g / 255f, g / 255f,
b / 255f, b / 255f,

2
tests/ImageSharp.Tests/PixelFormats/UnPackedPixelTests.cs

@ -5,7 +5,7 @@ using System.Numerics;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit; using Xunit;
namespace SixLabors.ImageSharp.Tests.Colors namespace SixLabors.ImageSharp.Tests.PixelFormats
{ {
[Trait("Category", "PixelFormats")] [Trait("Category", "PixelFormats")]
public class UnPackedPixelTests public class UnPackedPixelTests

Loading…
Cancel
Save