|
|
|
@ -45,7 +45,7 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// <param name="g">The green component.</param>
|
|
|
|
/// <param name="b">The blue component.</param>
|
|
|
|
/// <param name="a">The alpha component.</param>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public Rgba64(ushort r, ushort g, ushort b, ushort a) |
|
|
|
{ |
|
|
|
this.R = r; |
|
|
|
@ -58,64 +58,64 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// Initializes a new instance of the <see cref="Rgba64"/> struct.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">A structure of 4 bytes in RGBA byte order.</param>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public Rgba64(Rgba32 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.UpscaleFrom8BitTo16Bit(source.A); |
|
|
|
this.R = ColorNumerics.From8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.From8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.From8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.From8BitTo16Bit(source.A); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="Rgba64"/> struct.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">A structure of 4 bytes in BGRA byte order.</param>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public Rgba64(Bgra32 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.UpscaleFrom8BitTo16Bit(source.A); |
|
|
|
this.R = ColorNumerics.From8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.From8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.From8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.From8BitTo16Bit(source.A); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="Rgba64"/> struct.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">A structure of 4 bytes in ARGB byte order.</param>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public Rgba64(Argb32 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.UpscaleFrom8BitTo16Bit(source.A); |
|
|
|
this.R = ColorNumerics.From8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.From8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.From8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.From8BitTo16Bit(source.A); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="Rgba64"/> struct.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">A structure of 4 bytes in ABGR byte order.</param>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public Rgba64(Abgr32 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.UpscaleFrom8BitTo16Bit(source.A); |
|
|
|
this.R = ColorNumerics.From8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.From8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.From8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.From8BitTo16Bit(source.A); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="Rgba64"/> struct.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">A structure of 3 bytes in RGB byte order.</param>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public Rgba64(Rgb24 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.R = ColorNumerics.From8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.From8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.From8BitTo16Bit(source.B); |
|
|
|
this.A = ushort.MaxValue; |
|
|
|
} |
|
|
|
|
|
|
|
@ -123,12 +123,12 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// Initializes a new instance of the <see cref="Rgba64"/> struct.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">A structure of 3 bytes in BGR byte order.</param>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public Rgba64(Bgr24 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.R = ColorNumerics.From8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.From8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.From8BitTo16Bit(source.B); |
|
|
|
this.A = ushort.MaxValue; |
|
|
|
} |
|
|
|
|
|
|
|
@ -136,7 +136,7 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// Initializes a new instance of the <see cref="Rgba64"/> struct.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="vector">The <see cref="Vector4"/>.</param>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public Rgba64(Vector4 vector) |
|
|
|
{ |
|
|
|
vector = Numerics.Clamp(vector, Vector4.Zero, Vector4.One) * Max; |
|
|
|
@ -151,20 +151,20 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// </summary>
|
|
|
|
public Rgb48 Rgb |
|
|
|
{ |
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
readonly get => Unsafe.As<Rgba64, Rgb48>(ref Unsafe.AsRef(in this)); |
|
|
|
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
set => Unsafe.As<Rgba64, Rgb48>(ref this) = value; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ulong PackedValue |
|
|
|
{ |
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
readonly get => Unsafe.As<Rgba64, ulong>(ref Unsafe.AsRef(in this)); |
|
|
|
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
set => Unsafe.As<Rgba64, ulong>(ref this) = value; |
|
|
|
} |
|
|
|
|
|
|
|
@ -176,7 +176,7 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// <returns>
|
|
|
|
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
|
|
|
|
/// </returns>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static bool operator ==(Rgba64 left, Rgba64 right) => left.PackedValue == right.PackedValue; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -187,9 +187,26 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// <returns>
|
|
|
|
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
|
|
|
|
/// </returns>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static bool operator !=(Rgba64 left, Rgba64 right) => left.PackedValue != right.PackedValue; |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public readonly Rgba32 ToRgba32() |
|
|
|
=> new( |
|
|
|
ColorNumerics.From16BitTo8Bit(this.R), |
|
|
|
ColorNumerics.From16BitTo8Bit(this.G), |
|
|
|
ColorNumerics.From16BitTo8Bit(this.B), |
|
|
|
ColorNumerics.From16BitTo8Bit(this.A)); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public readonly Vector4 ToScaledVector4() => this.ToVector4(); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public readonly Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A) / Max; |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public static PixelTypeInfo GetPixelTypeInfo() |
|
|
|
=> PixelTypeInfo.Create<Rgba64>( |
|
|
|
@ -201,181 +218,80 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
public readonly PixelOperations<Rgba64> CreatePixelOperations() => new PixelOperations(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromScaledVector4(Vector4 vector) => this.FromVector4(vector); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public readonly Vector4 ToScaledVector4() => this.ToVector4(); |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromScaledVector4(Vector4 source) => FromVector4(source); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromVector4(Vector4 vector) |
|
|
|
{ |
|
|
|
vector = Numerics.Clamp(vector, Vector4.Zero, Vector4.One) * Max; |
|
|
|
this.R = (ushort)MathF.Round(vector.X); |
|
|
|
this.G = (ushort)MathF.Round(vector.Y); |
|
|
|
this.B = (ushort)MathF.Round(vector.Z); |
|
|
|
this.A = (ushort)MathF.Round(vector.W); |
|
|
|
} |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromVector4(Vector4 source) => new(source); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public readonly Vector4 ToVector4() => new Vector4(this.R, this.G, this.B, this.A) / Max; |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromArgb32(Argb32 source) => new(source); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromArgb32(Argb32 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.UpscaleFrom8BitTo16Bit(source.A); |
|
|
|
} |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromBgr24(Bgr24 source) => new(source); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromBgr24(Bgr24 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.A = ushort.MaxValue; |
|
|
|
} |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromBgra32(Bgra32 source) => new(source); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromBgra32(Bgra32 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.UpscaleFrom8BitTo16Bit(source.A); |
|
|
|
} |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromAbgr32(Abgr32 source) => new(source); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromAbgr32(Abgr32 source) |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromL8(L8 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.UpscaleFrom8BitTo16Bit(source.A); |
|
|
|
ushort rgb = ColorNumerics.From8BitTo16Bit(source.PackedValue); |
|
|
|
return new(rgb, rgb, rgb, ushort.MaxValue); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromBgra5551(Bgra5551 source) => this.FromScaledVector4(source.ToScaledVector4()); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromL8(L8 source) |
|
|
|
{ |
|
|
|
ushort rgb = ColorNumerics.UpscaleFrom8BitTo16Bit(source.PackedValue); |
|
|
|
this.R = rgb; |
|
|
|
this.G = rgb; |
|
|
|
this.B = rgb; |
|
|
|
this.A = ushort.MaxValue; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromL16(L16 source) |
|
|
|
{ |
|
|
|
this.R = source.PackedValue; |
|
|
|
this.G = source.PackedValue; |
|
|
|
this.B = source.PackedValue; |
|
|
|
this.A = ushort.MaxValue; |
|
|
|
} |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromL16(L16 source) => new(source.PackedValue, source.PackedValue, source.PackedValue, ushort.MaxValue); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromLa16(La16 source) |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromLa16(La16 source) |
|
|
|
{ |
|
|
|
ushort rgb = ColorNumerics.UpscaleFrom8BitTo16Bit(source.L); |
|
|
|
this.R = rgb; |
|
|
|
this.G = rgb; |
|
|
|
this.B = rgb; |
|
|
|
this.A = ColorNumerics.UpscaleFrom8BitTo16Bit(source.A); |
|
|
|
ushort rgb = ColorNumerics.From8BitTo16Bit(source.L); |
|
|
|
return new(rgb, rgb, rgb, ColorNumerics.From8BitTo16Bit(source.A)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromLa32(La32 source) |
|
|
|
{ |
|
|
|
this.R = source.L; |
|
|
|
this.G = source.L; |
|
|
|
this.B = source.L; |
|
|
|
this.A = source.A; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromRgb24(Rgb24 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.A = ushort.MaxValue; |
|
|
|
} |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromLa32(La32 source) => new(source.L, source.L, source.L, source.A); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromRgba32(Rgba32 source) |
|
|
|
{ |
|
|
|
this.R = ColorNumerics.UpscaleFrom8BitTo16Bit(source.R); |
|
|
|
this.G = ColorNumerics.UpscaleFrom8BitTo16Bit(source.G); |
|
|
|
this.B = ColorNumerics.UpscaleFrom8BitTo16Bit(source.B); |
|
|
|
this.A = ColorNumerics.UpscaleFrom8BitTo16Bit(source.A); |
|
|
|
} |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromRgb24(Rgb24 source) => new(source); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void ToRgba32(ref Rgba32 dest) |
|
|
|
{ |
|
|
|
dest.R = ColorNumerics.DownScaleFrom16BitTo8Bit(this.R); |
|
|
|
dest.G = ColorNumerics.DownScaleFrom16BitTo8Bit(this.G); |
|
|
|
dest.B = ColorNumerics.DownScaleFrom16BitTo8Bit(this.B); |
|
|
|
dest.A = ColorNumerics.DownScaleFrom16BitTo8Bit(this.A); |
|
|
|
} |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromRgba32(Rgba32 source) => new(source); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromRgb48(Rgb48 source) |
|
|
|
{ |
|
|
|
this.Rgb = source; |
|
|
|
this.A = ushort.MaxValue; |
|
|
|
} |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromRgb48(Rgb48 source) => new(source.R, source.G, source.B, ushort.MaxValue); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void FromRgba64(Rgba64 source) => this = source; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Convert to <see cref="Rgba32"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The <see cref="Rgba32"/>.</returns>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public readonly Rgba32 ToRgba32() |
|
|
|
{ |
|
|
|
byte r = ColorNumerics.DownScaleFrom16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.DownScaleFrom16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.DownScaleFrom16BitTo8Bit(this.B); |
|
|
|
byte a = ColorNumerics.DownScaleFrom16BitTo8Bit(this.A); |
|
|
|
return new Rgba32(r, g, b, a); |
|
|
|
} |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static Rgba64 FromRgba64(Rgba64 source) => new(source.R, source.G, source.B, source.A); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Convert to <see cref="Bgra32"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The <see cref="Bgra32"/>.</returns>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public readonly Bgra32 ToBgra32() |
|
|
|
{ |
|
|
|
byte r = ColorNumerics.DownScaleFrom16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.DownScaleFrom16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.DownScaleFrom16BitTo8Bit(this.B); |
|
|
|
byte a = ColorNumerics.DownScaleFrom16BitTo8Bit(this.A); |
|
|
|
byte r = ColorNumerics.From16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.From16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.From16BitTo8Bit(this.B); |
|
|
|
byte a = ColorNumerics.From16BitTo8Bit(this.A); |
|
|
|
return new Bgra32(r, g, b, a); |
|
|
|
} |
|
|
|
|
|
|
|
@ -383,13 +299,13 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// Convert to <see cref="Argb32"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The <see cref="Argb32"/>.</returns>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public readonly Argb32 ToArgb32() |
|
|
|
{ |
|
|
|
byte r = ColorNumerics.DownScaleFrom16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.DownScaleFrom16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.DownScaleFrom16BitTo8Bit(this.B); |
|
|
|
byte a = ColorNumerics.DownScaleFrom16BitTo8Bit(this.A); |
|
|
|
byte r = ColorNumerics.From16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.From16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.From16BitTo8Bit(this.B); |
|
|
|
byte a = ColorNumerics.From16BitTo8Bit(this.A); |
|
|
|
return new Argb32(r, g, b, a); |
|
|
|
} |
|
|
|
|
|
|
|
@ -397,13 +313,13 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// Convert to <see cref="Abgr32"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The <see cref="Abgr32"/>.</returns>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public readonly Abgr32 ToAbgr32() |
|
|
|
{ |
|
|
|
byte r = ColorNumerics.DownScaleFrom16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.DownScaleFrom16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.DownScaleFrom16BitTo8Bit(this.B); |
|
|
|
byte a = ColorNumerics.DownScaleFrom16BitTo8Bit(this.A); |
|
|
|
byte r = ColorNumerics.From16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.From16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.From16BitTo8Bit(this.B); |
|
|
|
byte a = ColorNumerics.From16BitTo8Bit(this.A); |
|
|
|
return new Abgr32(r, g, b, a); |
|
|
|
} |
|
|
|
|
|
|
|
@ -411,12 +327,12 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// Convert to <see cref="Rgb24"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The <see cref="Rgb24"/>.</returns>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public readonly Rgb24 ToRgb24() |
|
|
|
{ |
|
|
|
byte r = ColorNumerics.DownScaleFrom16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.DownScaleFrom16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.DownScaleFrom16BitTo8Bit(this.B); |
|
|
|
byte r = ColorNumerics.From16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.From16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.From16BitTo8Bit(this.B); |
|
|
|
return new Rgb24(r, g, b); |
|
|
|
} |
|
|
|
|
|
|
|
@ -424,12 +340,12 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
/// Convert to <see cref="Bgr24"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The <see cref="Bgr24"/>.</returns>
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public readonly Bgr24 ToBgr24() |
|
|
|
{ |
|
|
|
byte r = ColorNumerics.DownScaleFrom16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.DownScaleFrom16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.DownScaleFrom16BitTo8Bit(this.B); |
|
|
|
byte r = ColorNumerics.From16BitTo8Bit(this.R); |
|
|
|
byte g = ColorNumerics.From16BitTo8Bit(this.G); |
|
|
|
byte b = ColorNumerics.From16BitTo8Bit(this.B); |
|
|
|
return new Bgr24(r, g, b); |
|
|
|
} |
|
|
|
|
|
|
|
@ -437,13 +353,11 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong> |
|
|
|
public override readonly 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); |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override readonly string ToString() => $"Rgba64({this.R}, {this.G}, {this.B}, {this.A})"; |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public override readonly int GetHashCode() => this.PackedValue.GetHashCode(); |
|
|
|
} |
|
|
|
|