diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs
index 77df2bc80..cca7ff7db 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs
@@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[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);
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
index 3ac9b523f..8c1b04ff1 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
@@ -44,12 +44,12 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The maximum byte value.
///
- private static readonly Vector4 MaxBytes = new Vector4(255);
+ private static readonly Vector4 MaxBytes = new(255);
///
/// The half vector value.
///
- private static readonly Vector4 Half = new Vector4(0.5F);
+ private static readonly Vector4 Half = new(0.5F);
///
/// Initializes a new instance of the struct.
@@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The .
/// The .
[MethodImpl(InliningOptions.ShortMethod)]
- public static implicit operator Color(Argb32 source) => new Color(source);
+ public static implicit operator Color(Argb32 source) => new(source);
///
/// Converts a to .
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs
index 6cff5fd77..22e983a65 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs
@@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The .
/// The .
[MethodImpl(InliningOptions.ShortMethod)]
- public static implicit operator Color(Bgr24 source) => new Color(source);
+ public static implicit operator Color(Bgr24 source) => new(source);
///
/// Converts a to .
@@ -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 string ToString() => $"Bgra({this.B}, {this.G}, {this.R})";
+ public override readonly string ToString() => $"Bgr24({this.B}, {this.G}, {this.R})";
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs
index fd12b6837..5585310b9 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs
@@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector4 ToVector4() => new Vector4(this.ToVector3(), 1F);
+ public readonly Vector4 ToVector4() => new(this.ToVector3(), 1F);
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -125,10 +125,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -144,13 +141,10 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The .
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector3 ToVector3()
- {
- return new Vector3(
+ public readonly Vector3 ToVector3() => new(
((this.PackedValue >> 11) & 0x1F) * (1F / 31F),
((this.PackedValue >> 5) & 0x3F) * (1F / 63F),
(this.PackedValue & 0x1F) * (1F / 31F));
- }
///
public override readonly bool Equals(object obj) => obj is Bgr565 other && this.Equals(other);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
index 190345dda..be4e178c2 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
@@ -41,12 +41,12 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The maximum byte value.
///
- private static readonly Vector4 MaxBytes = new Vector4(255);
+ private static readonly Vector4 MaxBytes = new(255);
///
/// The half vector value.
///
- private static readonly Vector4 Half = new Vector4(0.5F);
+ private static readonly Vector4 Half = new(0.5F);
///
/// Initializes a new instance of the struct.
@@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The .
/// The .
[MethodImpl(InliningOptions.ShortMethod)]
- public static implicit operator Color(Bgra32 source) => new Color(source);
+ public static implicit operator Color(Bgra32 source) => new(source);
///
/// Converts a to .
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs
index 8fa5219d5..3578f1dd3 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs
@@ -128,10 +128,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs
index b3a0d0896..0254397c3 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs
@@ -78,14 +78,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector4 ToVector4()
- {
- return new Vector4(
+ public readonly Vector4 ToVector4() => new(
((this.PackedValue >> 10) & 0x1F) / 31F,
((this.PackedValue >> 5) & 0x1F) / 31F,
((this.PackedValue >> 0) & 0x1F) / 31F,
(this.PackedValue >> 15) & 0x01);
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -129,10 +126,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs
index e26121291..0995f8417 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs
@@ -78,14 +78,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector4 ToVector4()
- {
- return new Vector4(
+ public readonly Vector4 ToVector4() => new(
this.PackedValue & 0xFF,
(this.PackedValue >> 0x8) & 0xFF,
(this.PackedValue >> 0x10) & 0xFF,
(this.PackedValue >> 0x18) & 0xFF);
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -129,10 +126,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs
index 5c4aa1cfb..b0ef0f6a9 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs
@@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector4 ToVector4() => new Vector4(this.ToSingle(), 0, 0, 1F);
+ public readonly Vector4 ToVector4() => new(this.ToSingle(), 0, 0, 1F);
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -118,10 +118,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
index 39cb6f799..8be826130 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
@@ -129,10 +129,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs
index 9826d61a2..955b274ac 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs
@@ -86,14 +86,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector4 ToVector4()
- {
- return new Vector4(
+ public readonly Vector4 ToVector4() => new(
HalfTypeHelper.Unpack((ushort)this.PackedValue),
HalfTypeHelper.Unpack((ushort)(this.PackedValue >> 0x10)),
HalfTypeHelper.Unpack((ushort)(this.PackedValue >> 0x20)),
HalfTypeHelper.Unpack((ushort)(this.PackedValue >> 0x30)));
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -137,10 +134,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
index dd31aae2f..6d1128dd2 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
@@ -72,33 +72,24 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void FromArgb32(Argb32 source)
- {
- this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
+ public void FromArgb32(Argb32 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
ColorNumerics.UpscaleFrom8BitTo16Bit(source.R),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.G),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.B));
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void FromBgr24(Bgr24 source)
- {
- this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
+ public void FromBgr24(Bgr24 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
ColorNumerics.UpscaleFrom8BitTo16Bit(source.R),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.G),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.B));
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void FromBgra32(Bgra32 source)
- {
- this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
+ public void FromBgra32(Bgra32 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
ColorNumerics.UpscaleFrom8BitTo16Bit(source.R),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.G),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.B));
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -122,23 +113,17 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void FromRgb24(Rgb24 source)
- {
- this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
+ public void FromRgb24(Rgb24 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
ColorNumerics.UpscaleFrom8BitTo16Bit(source.R),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.G),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.B));
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void FromRgba32(Rgba32 source)
- {
- this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
+ public void FromRgba32(Rgba32 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(
ColorNumerics.UpscaleFrom8BitTo16Bit(source.R),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.G),
ColorNumerics.UpscaleFrom8BitTo16Bit(source.B));
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
index c570c33a1..ffff60be5 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
@@ -14,8 +14,8 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public partial struct L8 : IPixel, IPackedVector
{
- private static readonly Vector4 MaxBytes = new Vector4(255F);
- private static readonly Vector4 Half = new Vector4(0.5F);
+ private static readonly Vector4 MaxBytes = new(255F);
+ private static readonly Vector4 Half = new(0.5F);
///
/// Initializes a new instance of the struct.
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
index 5a69431a1..877aaed81 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
@@ -16,8 +16,8 @@ namespace SixLabors.ImageSharp.PixelFormats
[StructLayout(LayoutKind.Explicit)]
public partial struct La16 : IPixel, IPackedVector
{
- private static readonly Vector4 MaxBytes = new Vector4(255F);
- private static readonly Vector4 Half = new Vector4(0.5F);
+ private static readonly Vector4 MaxBytes = new(255F);
+ private static readonly Vector4 Half = new(0.5F);
///
/// Gets or sets the luminance component.
@@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Initializes a new instance of the struct.
///
/// The luminance component.
- /// The alpha componant.
+ /// The alpha component.
public La16(byte l, byte a)
{
this.L = l;
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
index 66d0e38c7..f19f22813 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
@@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Initializes a new instance of the struct.
///
/// The luminance component.
- /// The alpha componant.
+ /// The alpha component.
public La32(ushort l, ushort a)
{
this.L = l;
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
index 720a1eef6..62eaf949d 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
@@ -17,8 +17,8 @@ namespace SixLabors.ImageSharp.PixelFormats
{
private const float MaxPos = 127F;
- private static readonly Vector2 Half = new Vector2(MaxPos);
- private static readonly Vector2 MinusOne = new Vector2(-1F);
+ private static readonly Vector2 Half = new(MaxPos);
+ private static readonly Vector2 MinusOne = new(-1F);
///
/// Initializes a new instance of the struct.
@@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector4 ToVector4() => new Vector4(this.ToVector2(), 0F, 1F);
+ public readonly Vector4 ToVector4() => new(this.ToVector2(), 0F, 1F);
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -153,12 +153,9 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The .
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector2 ToVector2()
- {
- return new Vector2(
+ public readonly Vector2 ToVector2() => new(
(sbyte)((this.PackedValue >> 0) & 0xFF) / MaxPos,
(sbyte)((this.PackedValue >> 8) & 0xFF) / MaxPos);
- }
///
public override readonly bool Equals(object obj) => obj is NormalizedByte2 other && this.Equals(other);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs
index d1b4b73f2..2e81b3e2d 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs
@@ -17,8 +17,8 @@ namespace SixLabors.ImageSharp.PixelFormats
{
private const float MaxPos = 127F;
- private static readonly Vector4 Half = new Vector4(MaxPos);
- private static readonly Vector4 MinusOne = new Vector4(-1F);
+ private static readonly Vector4 Half = new(MaxPos);
+ private static readonly Vector4 MinusOne = new(-1F);
///
/// Initializes a new instance of the struct.
@@ -91,14 +91,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector4 ToVector4()
- {
- return new Vector4(
+ public readonly Vector4 ToVector4() => new(
(sbyte)((this.PackedValue >> 0) & 0xFF) / MaxPos,
(sbyte)((this.PackedValue >> 8) & 0xFF) / MaxPos,
(sbyte)((this.PackedValue >> 16) & 0xFF) / MaxPos,
(sbyte)((this.PackedValue >> 24) & 0xFF) / MaxPos);
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -142,10 +139,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
index d08a54603..b97aaacec 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
@@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.PixelFormats
// Largest two byte positive number 0xFFFF >> 1;
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);
///
@@ -138,10 +138,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -157,12 +154,9 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The .
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector2 ToVector2()
- {
- return new Vector2(
+ public readonly Vector2 ToVector2() => new(
(short)(this.PackedValue & 0xFFFF) / MaxPos,
(short)(this.PackedValue >> 0x10) / MaxPos);
- }
///
public override readonly bool Equals(object obj) => obj is NormalizedShort2 other && this.Equals(other);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs
index 158b6eb4b..f2e8aedd8 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs
@@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.PixelFormats
// Largest two byte positive number 0xFFFF >> 1;
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);
///
@@ -92,14 +92,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector4 ToVector4()
- {
- return new Vector4(
+ public readonly Vector4 ToVector4() => new(
(short)((this.PackedValue >> 0x00) & 0xFFFF) / MaxPos,
(short)((this.PackedValue >> 0x10) & 0xFFFF) / MaxPos,
(short)((this.PackedValue >> 0x20) & 0xFFFF) / MaxPos,
(short)((this.PackedValue >> 0x30) & 0xFFFF) / MaxPos);
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -143,10 +140,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs
index d7e6f53cf..12b6e153f 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs
@@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public partial struct Rg32 : IPixel, IPackedVector
{
- private static readonly Vector2 Max = new Vector2(ushort.MaxValue);
+ private static readonly Vector2 Max = new(ushort.MaxValue);
///
/// Initializes a new instance of the struct.
@@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector4 ToVector4() => new Vector4(this.ToVector2(), 0F, 1F);
+ public readonly Vector4 ToVector4() => new(this.ToVector2(), 0F, 1F);
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -123,10 +123,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs
index 7fd63c676..3b5bdb3d5 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs
@@ -36,8 +36,8 @@ namespace SixLabors.ImageSharp.PixelFormats
[FieldOffset(2)]
public byte B;
- private static readonly Vector4 MaxBytes = new Vector4(byte.MaxValue);
- private static readonly Vector4 Half = new Vector4(0.5F);
+ private static readonly Vector4 MaxBytes = new(byte.MaxValue);
+ private static readonly Vector4 Half = new(0.5F);
///
/// Initializes a new instance of the struct.
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs
index e3738b70c..d16b7db7a 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs
@@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[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);
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs
index dee2f9fcb..e68726018 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs
@@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public partial struct Rgba1010102 : IPixel, IPackedVector
{
- private static readonly Vector4 Multiplier = new Vector4(1023F, 1023F, 1023F, 3F);
+ private static readonly Vector4 Multiplier = new(1023F, 1023F, 1023F, 3F);
///
/// Initializes a new instance of the struct.
@@ -78,14 +78,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public readonly Vector4 ToVector4()
- {
- return new Vector4(
+ public readonly Vector4 ToVector4() => new Vector4(
(this.PackedValue >> 0) & 0x03FF,
(this.PackedValue >> 10) & 0x03FF,
(this.PackedValue >> 20) & 0x03FF,
(this.PackedValue >> 30) & 0x03) / Multiplier;
- }
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -129,10 +126,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest.FromScaledVector4(this.ToScaledVector4());
- }
+ public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
///
[MethodImpl(InliningOptions.ShortMethod)]
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
index 868165e9c..3dc6490f1 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
@@ -44,8 +44,8 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public byte A;
- private static readonly Vector4 MaxBytes = new Vector4(byte.MaxValue);
- private static readonly Vector4 Half = new Vector4(0.5F);
+ private static readonly Vector4 MaxBytes = new(byte.MaxValue);
+ private static readonly Vector4 Half = new(0.5F);
///
/// Initializes a new instance of the struct.
@@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public Rgb24 Rgb
{
[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)]
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);
+ readonly get => new(this.R, this.G, this.B);
[MethodImpl(InliningOptions.ShortMethod)]
set
@@ -181,7 +181,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The .
/// The .
[MethodImpl(InliningOptions.ShortMethod)]
- public static implicit operator Color(Rgba32 source) => new Color(source);
+ public static implicit operator Color(Rgba32 source) => new(source);
///
/// Converts a to .
@@ -393,10 +393,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(InliningOptions.ShortMethod)]
- public void ToRgba32(ref Rgba32 dest)
- {
- dest = this;
- }
+ public void ToRgba32(ref Rgba32 dest) => dest = this;
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -424,7 +421,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// A hexadecimal string representation of the value.
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");
}
@@ -523,7 +520,7 @@ namespace SixLabors.ImageSharp.PixelFormats
return hex + "FF";
}
- if (hex.Length < 3 || hex.Length > 4)
+ if (hex.Length is < 3 or > 4)
{
return null;
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
index 9add3d718..4cfa0bf97 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
@@ -162,7 +162,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The .
/// The .
[MethodImpl(InliningOptions.ShortMethod)]
- public static implicit operator Color(Rgba64 source) => new Color(source);
+ public static implicit operator Color(Rgba64 source) => new(source);
///
/// Converts a to .
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
index 97e103d0f..cd6f53c4e 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
@@ -43,8 +43,8 @@ namespace SixLabors.ImageSharp.PixelFormats
public float A;
private const float MaxBytes = byte.MaxValue;
- private static readonly Vector4 Max = new Vector4(MaxBytes);
- private static readonly Vector4 Half = new Vector4(0.5F);
+ private static readonly Vector4 Max = new(MaxBytes);
+ private static readonly Vector4 Half = new(0.5F);
///
/// Initializes a new instance of the struct.
@@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[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);
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.PixelFormats
// Hex is RRGGBBAA
Vector4 vector = this.ToVector4() * Max;
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");
}
@@ -199,10 +199,7 @@ namespace SixLabors.ImageSharp.PixelFormats
&& this.A.Equals(other.A);
///
- public override readonly string ToString()
- {
- return FormattableString.Invariant($"RgbaVector({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##}, {this.A:#0.##})");
- }
+ public override readonly string ToString() => FormattableString.Invariant($"RgbaVector({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##}, {this.A:#0.##})");
///
public override readonly int GetHashCode() => HashCode.Combine(this.R, this.G, this.B, this.A);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
index 101027a78..24f6b4d1d 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
@@ -21,8 +21,8 @@ namespace SixLabors.ImageSharp.PixelFormats
// Two's complement
private const float MinNeg = ~(int)MaxPos;
- private static readonly Vector2 Max = new Vector2(MaxPos);
- private static readonly Vector2 Min = new Vector2(MinNeg);
+ private static readonly Vector2 Max = new(MaxPos);
+ private static readonly Vector2 Min = new(MinNeg);
///
/// Initializes a new instance of the struct.
@@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[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);
///
[MethodImpl(InliningOptions.ShortMethod)]
@@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The .
[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));
///
public override readonly bool Equals(object obj) => obj is Short2 other && this.Equals(other);
diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs
index f6a6d44bb..36cdd157d 100644
--- a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs
@@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.NotEqual(color1, color2);
}
- public static readonly TheoryData ColorData =
- new TheoryData { { 1, 2, 3 }, { 4, 5, 6 }, { 0, 255, 42 } };
+ public static readonly TheoryData ColorData = new() { { 1, 2, 3 }, { 4, 5, 6 }, { 0, 255, 42 } };
[Theory]
[MemberData(nameof(ColorData))]
diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs
index b7fbdde71..4b8f4c2ea 100644
--- a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs
@@ -35,10 +35,13 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
}
public static readonly TheoryData ColorData =
- new TheoryData
- {
- { 1, 2, 3, 4 }, { 4, 5, 6, 7 }, { 0, 255, 42, 0 }, { 1, 2, 3, 255 }
- };
+ new()
+ {
+ { 1, 2, 3, 4 },
+ { 4, 5, 6, 7 },
+ { 0, 255, 42, 0 },
+ { 1, 2, 3, 255 }
+ };
[Theory]
[MemberData(nameof(ColorData))]
diff --git a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs
index d877283c1..fc91590d2 100644
--- a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs
@@ -12,29 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public class L8Tests
{
public static readonly TheoryData LuminanceData
- = new TheoryData
- {
- 0,
- 1,
- 2,
- 3,
- 5,
- 13,
- 31,
- 71,
- 73,
- 79,
- 83,
- 109,
- 127,
- 128,
- 131,
- 199,
- 250,
- 251,
- 254,
- 255
- };
+ = new() { 0, 1, 2, 3, 5, 13, 31, 71, 73, 79, 83, 109, 127, 128, 131, 199, 250, 251, 254, 255 };
[Theory]
[InlineData(0)]
diff --git a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs
index 2c9a27028..7e082147e 100644
--- a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs
@@ -12,29 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public class La16Tests
{
public static readonly TheoryData LuminanceData
- = new TheoryData
- {
- 0,
- 1,
- 2,
- 3,
- 5,
- 13,
- 31,
- 71,
- 73,
- 79,
- 83,
- 109,
- 127,
- 128,
- 131,
- 199,
- 250,
- 251,
- 254,
- 255
- };
+ = new() { 0, 1, 2, 3, 5, 13, 31, 71, 73, 79, 83, 109, 127, 128, 131, 199, 250, 251, 254, 255 };
[Theory]
[InlineData(0, 0)]
diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs
index 7954f1aff..5988cc851 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs
@@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Trait("Category", "PixelFormats")]
public class PixelBlenderTests
{
- public static TheoryData