mirror of
https://github.com/DarthAffe/HPPH.git
synced 2025-12-12 13:28:37 +00:00
Changed ColorFormat-ByteMapping to use constants
This commit is contained in:
parent
7a67f77168
commit
e34af1fbd3
@ -44,7 +44,7 @@ internal readonly struct ColorFormatData(string typeName, int bpp, char firstEnt
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Methods
|
||||
|
||||
private string CreateByteMapping()
|
||||
@ -52,19 +52,19 @@ internal readonly struct ColorFormatData(string typeName, int bpp, char firstEnt
|
||||
string[] mapping = new string[Bpp];
|
||||
if (Bpp > 0)
|
||||
{
|
||||
mapping[0] = GetByteMappingIndex(FirstEntry).ToString();
|
||||
mapping[0] = "Color." + FirstEntry.ToUpper();
|
||||
|
||||
if (Bpp > 1)
|
||||
{
|
||||
mapping[1] = GetByteMappingIndex(SecondEntry).ToString();
|
||||
mapping[1] = "Color." + SecondEntry.ToUpper();
|
||||
|
||||
if (Bpp > 2)
|
||||
{
|
||||
mapping[2] = GetByteMappingIndex(ThirdEntry).ToString();
|
||||
mapping[2] = "Color." + ThirdEntry.ToUpper();
|
||||
|
||||
if (Bpp > 3)
|
||||
{
|
||||
mapping[3] = GetByteMappingIndex(FourthEntry).ToString();
|
||||
mapping[3] = "Color." + FourthEntry.ToUpper();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -83,15 +83,5 @@ internal readonly struct ColorFormatData(string typeName, int bpp, char firstEnt
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
private static int GetByteMappingIndex(string entry)
|
||||
=> entry switch
|
||||
{
|
||||
"r" => 0,
|
||||
"g" => 1,
|
||||
"b" => 2,
|
||||
"a" => 3,
|
||||
_ => throw new IndexOutOfRangeException()
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -3,6 +3,14 @@
|
||||
|
||||
namespace HPPH;
|
||||
|
||||
internal static class Color
|
||||
{
|
||||
internal const int R = 0;
|
||||
internal const int G = 1;
|
||||
internal const int B = 2;
|
||||
internal const int A = 3;
|
||||
}
|
||||
|
||||
[ColorGenerator]
|
||||
public readonly partial struct ColorRGB;
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ public sealed partial class ColorFormatABGR : IColorFormat
|
||||
|
||||
public string Name => "ABGR";
|
||||
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [3, 2, 1, 0];
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [Color.A, Color.B, Color.G, Color.R];
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ public sealed partial class ColorFormatARGB : IColorFormat
|
||||
|
||||
public string Name => "ARGB";
|
||||
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [3, 0, 1, 2];
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [Color.A, Color.R, Color.G, Color.B];
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ public sealed partial class ColorFormatBGR : IColorFormat
|
||||
|
||||
public string Name => "BGR";
|
||||
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [2, 1, 0];
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [Color.B, Color.G, Color.R];
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ public sealed partial class ColorFormatBGRA : IColorFormat
|
||||
|
||||
public string Name => "BGRA";
|
||||
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [2, 1, 0, 3];
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [Color.B, Color.G, Color.R, Color.A];
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ public sealed partial class ColorFormatRGB : IColorFormat
|
||||
|
||||
public string Name => "RGB";
|
||||
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [0, 1, 2];
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [Color.R, Color.G, Color.B];
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ public sealed partial class ColorFormatRGBA : IColorFormat
|
||||
|
||||
public string Name => "RGBA";
|
||||
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [0, 1, 2, 3];
|
||||
ReadOnlySpan<byte> IColorFormat.ByteMapping => [Color.R, Color.G, Color.B, Color.A];
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user