mirror of
https://github.com/AssetRipper/AssetRipper.TextureDecoder.git
synced 2026-11-12 18:07:28 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdd73752df | ||
|
|
99556c46dd | ||
|
|
c919852137 | ||
|
|
9bca952f2d |
No files matched your search
@@ -21,5 +21,5 @@ public class Argb32Decoding
|
||||
public int OriginalMethod() => RgbConverter.ARGB32ToBGRA32(inputData, Width, Height, outputData);
|
||||
|
||||
[Benchmark]
|
||||
public int GenericMethod() => RgbConverter.Convert<ColorARGB32, byte, ColorBGRA32, byte>(inputData, Width, Height, outputData);
|
||||
public int GenericMethod() => RgbConverter.Convert<ColorARGB<byte>, byte, ColorBGRA<byte>, byte>(inputData, Width, Height, outputData);
|
||||
}
|
||||
@@ -21,5 +21,5 @@ public class Rgb9e5Decoding
|
||||
public int OriginalMethod() => RgbConverter.RGB9e5FloatToBGRA32(inputData, Width, Height, outputData);
|
||||
|
||||
[Benchmark]
|
||||
public int GenericMethod() => RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA32, byte>(inputData, Width, Height, outputData);
|
||||
public int GenericMethod() => RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA<byte>, byte>(inputData, Width, Height, outputData);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using AssetRipper.Text.SourceGeneration;
|
||||
using AssetRipper.TextureDecoder.SourceGeneration.Common;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.ColorGenerator;
|
||||
@@ -18,24 +19,22 @@ internal static partial class Program
|
||||
private static readonly List<(string, Type, bool, bool, bool, bool, bool)> CustomColors = new()
|
||||
{
|
||||
( "ColorARGB16", typeof(byte), true, true, true, true, false ),
|
||||
( "ColorARGB32", typeof(byte), true, true, true, true, true ),
|
||||
( "ColorBGRA32", typeof(byte), true, true, true, true, true ),
|
||||
( "ColorRGB16", typeof(byte), true, true, true, false, false ),
|
||||
( "ColorRGB9e5", typeof(double), true, true, true, false, false ),
|
||||
( "ColorRGBA16", typeof(byte), true, true, true, true, false ),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Name, Red, Blue, Green, Alpha
|
||||
/// </summary>
|
||||
private static readonly List<(string, bool, bool, bool, bool)> GenericColors = new()
|
||||
{
|
||||
( "ColorR", true, false, false, false ),
|
||||
( "ColorRG", true, true, false, false ),
|
||||
( "ColorRGB", true, true, true, false ),
|
||||
( "ColorRGBA", true, true, true, true ),
|
||||
( "ColorA", false, false, false, true ),
|
||||
};
|
||||
private static readonly List<string> GenericColors =
|
||||
[
|
||||
"ColorR",
|
||||
"ColorRG",
|
||||
"ColorRGB",
|
||||
"ColorRGBA",
|
||||
"ColorA",
|
||||
"ColorARGB",
|
||||
"ColorBGRA",
|
||||
"ColorBGR",
|
||||
];
|
||||
|
||||
static void Main()
|
||||
{
|
||||
@@ -43,7 +42,7 @@ internal static partial class Program
|
||||
{
|
||||
WriteCustomColor(customColor);
|
||||
}
|
||||
foreach (var genericColor in GenericColors)
|
||||
foreach (string genericColor in GenericColors)
|
||||
{
|
||||
WriteGenericColor(genericColor);
|
||||
}
|
||||
@@ -63,12 +62,11 @@ internal static partial class Program
|
||||
WriteCustomColor(writer, name, type, hasRed, hasGreen, hasBlue, hasAlpha, fullyUtilized);
|
||||
}
|
||||
|
||||
private static void WriteGenericColor((string, bool, bool, bool, bool) details)
|
||||
private static void WriteGenericColor(string name)
|
||||
{
|
||||
(string name, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha) = details;
|
||||
Console.WriteLine(name);
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create(FormatsFolder, name);
|
||||
WriteGenericColor(writer, name, hasRed, hasGreen, hasBlue, hasAlpha);
|
||||
WriteGenericColor(writer, name);
|
||||
}
|
||||
|
||||
private static void WriteSuperGenericColor(int channelCount)
|
||||
@@ -214,7 +212,7 @@ internal static partial class Program
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteGenericColor(IndentedTextWriter writer, string name, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha)
|
||||
private static void WriteGenericColor(IndentedTextWriter writer, string name)
|
||||
{
|
||||
const string typeName = "T";
|
||||
const string minValue = "NumericConversion.GetMinimumValueSafe<T>()";
|
||||
@@ -229,14 +227,39 @@ internal static partial class Program
|
||||
writer.WriteLine($"public partial struct {name}<T> : IColor<{name}<T>, T> where T : unmanaged, INumberBase<T>, IMinMaxValue<T>");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
WriteProperty(writer, hasRed, typeName, 'R', minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteProperty(writer, hasGreen, typeName, 'G', minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteProperty(writer, hasBlue, typeName, 'B', minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteProperty(writer, hasAlpha, typeName, 'A', maxValue);
|
||||
writer.WriteLineNoTabs();
|
||||
Debug.Assert(name.StartsWith("Color", StringComparison.Ordinal));
|
||||
ReadOnlySpan<char> channels = name.AsSpan()[5..];
|
||||
foreach (char channel in channels)
|
||||
{
|
||||
WriteProperty(writer, true, typeName, channel, minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
|
||||
bool hasRed = channels.Contains('R');
|
||||
bool hasGreen = channels.Contains('G');
|
||||
bool hasBlue = channels.Contains('B');
|
||||
bool hasAlpha = channels.Contains('A');
|
||||
|
||||
if (!hasRed)
|
||||
{
|
||||
WriteProperty(writer, hasRed, typeName, 'R', minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
if (!hasGreen)
|
||||
{
|
||||
WriteProperty(writer, hasGreen, typeName, 'G', minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
if (!hasBlue)
|
||||
{
|
||||
WriteProperty(writer, hasBlue, typeName, 'B', minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
if (!hasAlpha)
|
||||
{
|
||||
WriteProperty(writer, hasAlpha, typeName, 'A', maxValue);
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
|
||||
WriteConstructor(writer, name, hasRed, hasGreen, hasBlue, hasAlpha, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
@@ -27,7 +27,7 @@ internal static partial class Program
|
||||
string args6 = args.GetArgument(6);
|
||||
byte[] data = File.ReadAllBytes(path);
|
||||
|
||||
DirectBitmap<ColorBGRA32, byte> bitmap = new DirectBitmap<ColorBGRA32, byte>(width, height);
|
||||
DirectBitmap<ColorBGRA<byte>, byte> bitmap = new DirectBitmap<ColorBGRA<byte>, byte>(width, height);
|
||||
switch (inputType)
|
||||
{
|
||||
case "astc":
|
||||
@@ -52,7 +52,7 @@ internal static partial class Program
|
||||
DecodeRgb(data, width, height, args5, bitmap.Bits);
|
||||
break;
|
||||
case "yuy2":
|
||||
Yuy2Decoder.DecompressYUY2<ColorBGRA32, byte>(data, width, height, bitmap.Bits);
|
||||
Yuy2Decoder.DecompressYUY2<ColorBGRA<byte>, byte>(data, width, height, bitmap.Bits);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(inputType);
|
||||
@@ -105,7 +105,7 @@ internal static partial class Program
|
||||
Console.WriteLine("Arg at index 6 : blockYSize");
|
||||
int blockXSize = int.Parse(blockXSizeString);
|
||||
int blockYSize = int.Parse(blockYSizeString);
|
||||
AstcDecoder.DecodeASTC<ColorBGRA32, byte>(input, width, height, blockXSize, blockYSize, output);
|
||||
AstcDecoder.DecodeASTC<ColorBGRA<byte>, byte>(input, width, height, blockXSize, blockYSize, output);
|
||||
}
|
||||
|
||||
private static void DecodeAtc(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)
|
||||
@@ -117,10 +117,10 @@ internal static partial class Program
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
AtcDecoder.DecompressAtcRgb4<ColorBGRA32, byte>(input, width, height, output);
|
||||
AtcDecoder.DecompressAtcRgb4<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 1:
|
||||
AtcDecoder.DecompressAtcRgba8<ColorBGRA32, byte>(input, width, height, output);
|
||||
AtcDecoder.DecompressAtcRgba8<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -143,25 +143,25 @@ internal static partial class Program
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
Bc1.Decompress<ColorBGRA32, byte>(input, width, height, output);
|
||||
Bc1.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
Bc2.Decompress<ColorBGRA32, byte>(input, width, height, output);
|
||||
Bc2.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 3:
|
||||
Bc3.Decompress<ColorBGRA32, byte>(input, width, height, output);
|
||||
Bc3.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 4:
|
||||
Bc4.Decompress<ColorBGRA32, byte>(input, width, height, output);
|
||||
Bc4.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 5:
|
||||
Bc5.Decompress<ColorBGRA32, byte>(input, width, height, output);
|
||||
Bc5.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 6:
|
||||
Bc6h.Decompress<ColorBGRA32, byte>(input, width, height, bool.Parse(isSignedString), output);
|
||||
Bc6h.Decompress<ColorBGRA<byte>, byte>(input, width, height, bool.Parse(isSignedString), output);
|
||||
break;
|
||||
case 7:
|
||||
Bc7.Decompress<ColorBGRA32, byte>(input, width, height, output);
|
||||
Bc7.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -179,13 +179,13 @@ internal static partial class Program
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
DxtDecoder.DecompressDXT1<ColorBGRA32, byte>(input, width, height, output);
|
||||
DxtDecoder.DecompressDXT1<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 1:
|
||||
DxtDecoder.DecompressDXT3<ColorBGRA32, byte>(input, width, height, output);
|
||||
DxtDecoder.DecompressDXT3<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
DxtDecoder.DecompressDXT5<ColorBGRA32, byte>(input, width, height, output);
|
||||
DxtDecoder.DecompressDXT5<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -208,28 +208,28 @@ internal static partial class Program
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
EtcDecoder.DecompressETC<ColorBGRA32, byte>(input, width, height, output);
|
||||
EtcDecoder.DecompressETC<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 1:
|
||||
EtcDecoder.DecompressETC2<ColorBGRA32, byte>(input, width, height, output);
|
||||
EtcDecoder.DecompressETC2<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
EtcDecoder.DecompressETC2A1<ColorBGRA32, byte>(input, width, height, output);
|
||||
EtcDecoder.DecompressETC2A1<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 3:
|
||||
EtcDecoder.DecompressETC2A8<ColorBGRA32, byte>(input, width, height, output);
|
||||
EtcDecoder.DecompressETC2A8<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 4:
|
||||
EtcDecoder.DecompressEACRUnsigned<ColorBGRA32, byte>(input, width, height, output);
|
||||
EtcDecoder.DecompressEACRUnsigned<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 5:
|
||||
EtcDecoder.DecompressEACRSigned<ColorBGRA32, byte>(input, width, height, output);
|
||||
EtcDecoder.DecompressEACRSigned<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 6:
|
||||
EtcDecoder.DecompressEACRGUnsigned<ColorBGRA32, byte>(input, width, height, output);
|
||||
EtcDecoder.DecompressEACRGUnsigned<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 7:
|
||||
EtcDecoder.DecompressEACRGSigned<ColorBGRA32, byte>(input, width, height, output);
|
||||
EtcDecoder.DecompressEACRGSigned<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -241,6 +241,6 @@ internal static partial class Program
|
||||
{
|
||||
Console.WriteLine("Arg at index 5 : 2bitMode");
|
||||
bool do2bit = bool.Parse(do2bitModeString);
|
||||
PvrtcDecoder.DecompressPVRTC<ColorBGRA32, byte>(input, width, height, do2bit, output);
|
||||
PvrtcDecoder.DecompressPVRTC<ColorBGRA<byte>, byte>(input, width, height, do2bit, output);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Channels;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -15,367 +16,495 @@ static partial class Program
|
||||
Console.WriteLine(" 2 - RGB_SByte");
|
||||
Console.WriteLine(" 3 - RGBA_SByte");
|
||||
Console.WriteLine(" 4 - A_SByte");
|
||||
Console.WriteLine(" 5 - R_Byte");
|
||||
Console.WriteLine(" 6 - RG_Byte");
|
||||
Console.WriteLine(" 7 - RGB_Byte");
|
||||
Console.WriteLine(" 8 - RGBA_Byte");
|
||||
Console.WriteLine(" 9 - A_Byte");
|
||||
Console.WriteLine(" 10 - R_Int16");
|
||||
Console.WriteLine(" 11 - RG_Int16");
|
||||
Console.WriteLine(" 12 - RGB_Int16");
|
||||
Console.WriteLine(" 13 - RGBA_Int16");
|
||||
Console.WriteLine(" 14 - A_Int16");
|
||||
Console.WriteLine(" 15 - R_UInt16");
|
||||
Console.WriteLine(" 16 - RG_UInt16");
|
||||
Console.WriteLine(" 17 - RGB_UInt16");
|
||||
Console.WriteLine(" 18 - RGBA_UInt16");
|
||||
Console.WriteLine(" 19 - A_UInt16");
|
||||
Console.WriteLine(" 20 - R_Int32");
|
||||
Console.WriteLine(" 21 - RG_Int32");
|
||||
Console.WriteLine(" 22 - RGB_Int32");
|
||||
Console.WriteLine(" 23 - RGBA_Int32");
|
||||
Console.WriteLine(" 24 - A_Int32");
|
||||
Console.WriteLine(" 25 - R_UInt32");
|
||||
Console.WriteLine(" 26 - RG_UInt32");
|
||||
Console.WriteLine(" 27 - RGB_UInt32");
|
||||
Console.WriteLine(" 28 - RGBA_UInt32");
|
||||
Console.WriteLine(" 29 - A_UInt32");
|
||||
Console.WriteLine(" 30 - R_IntPtr");
|
||||
Console.WriteLine(" 31 - RG_IntPtr");
|
||||
Console.WriteLine(" 32 - RGB_IntPtr");
|
||||
Console.WriteLine(" 33 - RGBA_IntPtr");
|
||||
Console.WriteLine(" 34 - A_IntPtr");
|
||||
Console.WriteLine(" 35 - R_UIntPtr");
|
||||
Console.WriteLine(" 36 - RG_UIntPtr");
|
||||
Console.WriteLine(" 37 - RGB_UIntPtr");
|
||||
Console.WriteLine(" 38 - RGBA_UIntPtr");
|
||||
Console.WriteLine(" 39 - A_UIntPtr");
|
||||
Console.WriteLine(" 40 - R_Int64");
|
||||
Console.WriteLine(" 41 - RG_Int64");
|
||||
Console.WriteLine(" 42 - RGB_Int64");
|
||||
Console.WriteLine(" 43 - RGBA_Int64");
|
||||
Console.WriteLine(" 44 - A_Int64");
|
||||
Console.WriteLine(" 45 - R_UInt64");
|
||||
Console.WriteLine(" 46 - RG_UInt64");
|
||||
Console.WriteLine(" 47 - RGB_UInt64");
|
||||
Console.WriteLine(" 48 - RGBA_UInt64");
|
||||
Console.WriteLine(" 49 - A_UInt64");
|
||||
Console.WriteLine(" 50 - R_Int128");
|
||||
Console.WriteLine(" 51 - RG_Int128");
|
||||
Console.WriteLine(" 52 - RGB_Int128");
|
||||
Console.WriteLine(" 53 - RGBA_Int128");
|
||||
Console.WriteLine(" 54 - A_Int128");
|
||||
Console.WriteLine(" 55 - R_UInt128");
|
||||
Console.WriteLine(" 56 - RG_UInt128");
|
||||
Console.WriteLine(" 57 - RGB_UInt128");
|
||||
Console.WriteLine(" 58 - RGBA_UInt128");
|
||||
Console.WriteLine(" 59 - A_UInt128");
|
||||
Console.WriteLine(" 60 - R_Half");
|
||||
Console.WriteLine(" 61 - RG_Half");
|
||||
Console.WriteLine(" 62 - RGB_Half");
|
||||
Console.WriteLine(" 63 - RGBA_Half");
|
||||
Console.WriteLine(" 64 - A_Half");
|
||||
Console.WriteLine(" 65 - R_Single");
|
||||
Console.WriteLine(" 66 - RG_Single");
|
||||
Console.WriteLine(" 67 - RGB_Single");
|
||||
Console.WriteLine(" 68 - RGBA_Single");
|
||||
Console.WriteLine(" 69 - A_Single");
|
||||
Console.WriteLine(" 70 - R_NFloat");
|
||||
Console.WriteLine(" 71 - RG_NFloat");
|
||||
Console.WriteLine(" 72 - RGB_NFloat");
|
||||
Console.WriteLine(" 73 - RGBA_NFloat");
|
||||
Console.WriteLine(" 74 - A_NFloat");
|
||||
Console.WriteLine(" 75 - R_Double");
|
||||
Console.WriteLine(" 76 - RG_Double");
|
||||
Console.WriteLine(" 77 - RGB_Double");
|
||||
Console.WriteLine(" 78 - RGBA_Double");
|
||||
Console.WriteLine(" 79 - A_Double");
|
||||
Console.WriteLine(" 80 - R_Decimal");
|
||||
Console.WriteLine(" 81 - RG_Decimal");
|
||||
Console.WriteLine(" 82 - RGB_Decimal");
|
||||
Console.WriteLine(" 83 - RGBA_Decimal");
|
||||
Console.WriteLine(" 84 - A_Decimal");
|
||||
Console.WriteLine(" 85 - ARGB16");
|
||||
Console.WriteLine(" 86 - ARGB32");
|
||||
Console.WriteLine(" 87 - BGRA32");
|
||||
Console.WriteLine(" 88 - RGB16");
|
||||
Console.WriteLine(" 89 - RGB9e5");
|
||||
Console.WriteLine(" 90 - RGBA16");
|
||||
Console.WriteLine(" 5 - ARGB_SByte");
|
||||
Console.WriteLine(" 6 - BGRA_SByte");
|
||||
Console.WriteLine(" 7 - R_Byte");
|
||||
Console.WriteLine(" 8 - RG_Byte");
|
||||
Console.WriteLine(" 9 - RGB_Byte");
|
||||
Console.WriteLine(" 10 - RGBA_Byte");
|
||||
Console.WriteLine(" 11 - A_Byte");
|
||||
Console.WriteLine(" 12 - ARGB_Byte");
|
||||
Console.WriteLine(" 13 - BGRA_Byte");
|
||||
Console.WriteLine(" 14 - R_Int16");
|
||||
Console.WriteLine(" 15 - RG_Int16");
|
||||
Console.WriteLine(" 16 - RGB_Int16");
|
||||
Console.WriteLine(" 17 - RGBA_Int16");
|
||||
Console.WriteLine(" 18 - A_Int16");
|
||||
Console.WriteLine(" 19 - ARGB_Int16");
|
||||
Console.WriteLine(" 20 - BGRA_Int16");
|
||||
Console.WriteLine(" 21 - R_UInt16");
|
||||
Console.WriteLine(" 22 - RG_UInt16");
|
||||
Console.WriteLine(" 23 - RGB_UInt16");
|
||||
Console.WriteLine(" 24 - RGBA_UInt16");
|
||||
Console.WriteLine(" 25 - A_UInt16");
|
||||
Console.WriteLine(" 26 - ARGB_UInt16");
|
||||
Console.WriteLine(" 27 - BGRA_UInt16");
|
||||
Console.WriteLine(" 28 - R_Int32");
|
||||
Console.WriteLine(" 29 - RG_Int32");
|
||||
Console.WriteLine(" 30 - RGB_Int32");
|
||||
Console.WriteLine(" 31 - RGBA_Int32");
|
||||
Console.WriteLine(" 32 - A_Int32");
|
||||
Console.WriteLine(" 33 - ARGB_Int32");
|
||||
Console.WriteLine(" 34 - BGRA_Int32");
|
||||
Console.WriteLine(" 35 - R_UInt32");
|
||||
Console.WriteLine(" 36 - RG_UInt32");
|
||||
Console.WriteLine(" 37 - RGB_UInt32");
|
||||
Console.WriteLine(" 38 - RGBA_UInt32");
|
||||
Console.WriteLine(" 39 - A_UInt32");
|
||||
Console.WriteLine(" 40 - ARGB_UInt32");
|
||||
Console.WriteLine(" 41 - BGRA_UInt32");
|
||||
Console.WriteLine(" 42 - R_IntPtr");
|
||||
Console.WriteLine(" 43 - RG_IntPtr");
|
||||
Console.WriteLine(" 44 - RGB_IntPtr");
|
||||
Console.WriteLine(" 45 - RGBA_IntPtr");
|
||||
Console.WriteLine(" 46 - A_IntPtr");
|
||||
Console.WriteLine(" 47 - ARGB_IntPtr");
|
||||
Console.WriteLine(" 48 - BGRA_IntPtr");
|
||||
Console.WriteLine(" 49 - R_UIntPtr");
|
||||
Console.WriteLine(" 50 - RG_UIntPtr");
|
||||
Console.WriteLine(" 51 - RGB_UIntPtr");
|
||||
Console.WriteLine(" 52 - RGBA_UIntPtr");
|
||||
Console.WriteLine(" 53 - A_UIntPtr");
|
||||
Console.WriteLine(" 54 - ARGB_UIntPtr");
|
||||
Console.WriteLine(" 55 - BGRA_UIntPtr");
|
||||
Console.WriteLine(" 56 - R_Int64");
|
||||
Console.WriteLine(" 57 - RG_Int64");
|
||||
Console.WriteLine(" 58 - RGB_Int64");
|
||||
Console.WriteLine(" 59 - RGBA_Int64");
|
||||
Console.WriteLine(" 60 - A_Int64");
|
||||
Console.WriteLine(" 61 - ARGB_Int64");
|
||||
Console.WriteLine(" 62 - BGRA_Int64");
|
||||
Console.WriteLine(" 63 - R_UInt64");
|
||||
Console.WriteLine(" 64 - RG_UInt64");
|
||||
Console.WriteLine(" 65 - RGB_UInt64");
|
||||
Console.WriteLine(" 66 - RGBA_UInt64");
|
||||
Console.WriteLine(" 67 - A_UInt64");
|
||||
Console.WriteLine(" 68 - ARGB_UInt64");
|
||||
Console.WriteLine(" 69 - BGRA_UInt64");
|
||||
Console.WriteLine(" 70 - R_Int128");
|
||||
Console.WriteLine(" 71 - RG_Int128");
|
||||
Console.WriteLine(" 72 - RGB_Int128");
|
||||
Console.WriteLine(" 73 - RGBA_Int128");
|
||||
Console.WriteLine(" 74 - A_Int128");
|
||||
Console.WriteLine(" 75 - ARGB_Int128");
|
||||
Console.WriteLine(" 76 - BGRA_Int128");
|
||||
Console.WriteLine(" 77 - R_UInt128");
|
||||
Console.WriteLine(" 78 - RG_UInt128");
|
||||
Console.WriteLine(" 79 - RGB_UInt128");
|
||||
Console.WriteLine(" 80 - RGBA_UInt128");
|
||||
Console.WriteLine(" 81 - A_UInt128");
|
||||
Console.WriteLine(" 82 - ARGB_UInt128");
|
||||
Console.WriteLine(" 83 - BGRA_UInt128");
|
||||
Console.WriteLine(" 84 - R_Half");
|
||||
Console.WriteLine(" 85 - RG_Half");
|
||||
Console.WriteLine(" 86 - RGB_Half");
|
||||
Console.WriteLine(" 87 - RGBA_Half");
|
||||
Console.WriteLine(" 88 - A_Half");
|
||||
Console.WriteLine(" 89 - ARGB_Half");
|
||||
Console.WriteLine(" 90 - BGRA_Half");
|
||||
Console.WriteLine(" 91 - R_Single");
|
||||
Console.WriteLine(" 92 - RG_Single");
|
||||
Console.WriteLine(" 93 - RGB_Single");
|
||||
Console.WriteLine(" 94 - RGBA_Single");
|
||||
Console.WriteLine(" 95 - A_Single");
|
||||
Console.WriteLine(" 96 - ARGB_Single");
|
||||
Console.WriteLine(" 97 - BGRA_Single");
|
||||
Console.WriteLine(" 98 - R_NFloat");
|
||||
Console.WriteLine(" 99 - RG_NFloat");
|
||||
Console.WriteLine(" 100 - RGB_NFloat");
|
||||
Console.WriteLine(" 101 - RGBA_NFloat");
|
||||
Console.WriteLine(" 102 - A_NFloat");
|
||||
Console.WriteLine(" 103 - ARGB_NFloat");
|
||||
Console.WriteLine(" 104 - BGRA_NFloat");
|
||||
Console.WriteLine(" 105 - R_Double");
|
||||
Console.WriteLine(" 106 - RG_Double");
|
||||
Console.WriteLine(" 107 - RGB_Double");
|
||||
Console.WriteLine(" 108 - RGBA_Double");
|
||||
Console.WriteLine(" 109 - A_Double");
|
||||
Console.WriteLine(" 110 - ARGB_Double");
|
||||
Console.WriteLine(" 111 - BGRA_Double");
|
||||
Console.WriteLine(" 112 - R_Decimal");
|
||||
Console.WriteLine(" 113 - RG_Decimal");
|
||||
Console.WriteLine(" 114 - RGB_Decimal");
|
||||
Console.WriteLine(" 115 - RGBA_Decimal");
|
||||
Console.WriteLine(" 116 - A_Decimal");
|
||||
Console.WriteLine(" 117 - ARGB_Decimal");
|
||||
Console.WriteLine(" 118 - BGRA_Decimal");
|
||||
Console.WriteLine(" 119 - ARGB16");
|
||||
Console.WriteLine(" 120 - RGB16");
|
||||
Console.WriteLine(" 121 - RGB9e5");
|
||||
Console.WriteLine(" 122 - RGBA16");
|
||||
int mode = int.Parse(modeString);
|
||||
switch(mode)
|
||||
{
|
||||
case 0:
|
||||
RgbConverter.Convert<ColorR<sbyte>, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 1:
|
||||
RgbConverter.Convert<ColorRG<sbyte>, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
RgbConverter.Convert<ColorRGB<sbyte>, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 3:
|
||||
RgbConverter.Convert<ColorRGBA<sbyte>, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 4:
|
||||
RgbConverter.Convert<ColorA<sbyte>, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 5:
|
||||
RgbConverter.Convert<ColorR<byte>, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 6:
|
||||
RgbConverter.Convert<ColorRG<byte>, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 7:
|
||||
RgbConverter.Convert<ColorRGB<byte>, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 8:
|
||||
RgbConverter.Convert<ColorRGBA<byte>, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 9:
|
||||
RgbConverter.Convert<ColorA<byte>, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 10:
|
||||
RgbConverter.Convert<ColorR<short>, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 11:
|
||||
RgbConverter.Convert<ColorRG<short>, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 12:
|
||||
RgbConverter.Convert<ColorRGB<short>, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 13:
|
||||
RgbConverter.Convert<ColorRGBA<short>, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 14:
|
||||
RgbConverter.Convert<ColorA<short>, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 15:
|
||||
RgbConverter.Convert<ColorR<ushort>, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 16:
|
||||
RgbConverter.Convert<ColorRG<ushort>, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 17:
|
||||
RgbConverter.Convert<ColorRGB<ushort>, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 18:
|
||||
RgbConverter.Convert<ColorRGBA<ushort>, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 19:
|
||||
RgbConverter.Convert<ColorA<ushort>, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 20:
|
||||
RgbConverter.Convert<ColorR<int>, int, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 21:
|
||||
RgbConverter.Convert<ColorRG<int>, int, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 22:
|
||||
RgbConverter.Convert<ColorRGB<int>, int, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 23:
|
||||
RgbConverter.Convert<ColorRGBA<int>, int, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 24:
|
||||
RgbConverter.Convert<ColorA<int>, int, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 25:
|
||||
RgbConverter.Convert<ColorR<uint>, uint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 26:
|
||||
RgbConverter.Convert<ColorRG<uint>, uint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 27:
|
||||
RgbConverter.Convert<ColorRGB<uint>, uint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 28:
|
||||
RgbConverter.Convert<ColorRGBA<uint>, uint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 29:
|
||||
RgbConverter.Convert<ColorA<uint>, uint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 30:
|
||||
RgbConverter.Convert<ColorR<nint>, nint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 31:
|
||||
RgbConverter.Convert<ColorRG<nint>, nint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 32:
|
||||
RgbConverter.Convert<ColorRGB<nint>, nint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 33:
|
||||
RgbConverter.Convert<ColorRGBA<nint>, nint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 34:
|
||||
RgbConverter.Convert<ColorA<nint>, nint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 35:
|
||||
RgbConverter.Convert<ColorR<nuint>, nuint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 36:
|
||||
RgbConverter.Convert<ColorRG<nuint>, nuint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 37:
|
||||
RgbConverter.Convert<ColorRGB<nuint>, nuint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 38:
|
||||
RgbConverter.Convert<ColorRGBA<nuint>, nuint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 39:
|
||||
RgbConverter.Convert<ColorA<nuint>, nuint, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 40:
|
||||
RgbConverter.Convert<ColorR<long>, long, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 41:
|
||||
RgbConverter.Convert<ColorRG<long>, long, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 42:
|
||||
RgbConverter.Convert<ColorRGB<long>, long, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 43:
|
||||
RgbConverter.Convert<ColorRGBA<long>, long, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 44:
|
||||
RgbConverter.Convert<ColorA<long>, long, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 45:
|
||||
RgbConverter.Convert<ColorR<ulong>, ulong, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 46:
|
||||
RgbConverter.Convert<ColorRG<ulong>, ulong, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 47:
|
||||
RgbConverter.Convert<ColorRGB<ulong>, ulong, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 48:
|
||||
RgbConverter.Convert<ColorRGBA<ulong>, ulong, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 49:
|
||||
RgbConverter.Convert<ColorA<ulong>, ulong, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 50:
|
||||
RgbConverter.Convert<ColorR<Int128>, Int128, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 51:
|
||||
RgbConverter.Convert<ColorRG<Int128>, Int128, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 52:
|
||||
RgbConverter.Convert<ColorRGB<Int128>, Int128, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 53:
|
||||
RgbConverter.Convert<ColorRGBA<Int128>, Int128, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 54:
|
||||
RgbConverter.Convert<ColorA<Int128>, Int128, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 55:
|
||||
RgbConverter.Convert<ColorR<UInt128>, UInt128, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 56:
|
||||
RgbConverter.Convert<ColorRG<UInt128>, UInt128, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 57:
|
||||
RgbConverter.Convert<ColorRGB<UInt128>, UInt128, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 58:
|
||||
RgbConverter.Convert<ColorRGBA<UInt128>, UInt128, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 59:
|
||||
RgbConverter.Convert<ColorA<UInt128>, UInt128, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 60:
|
||||
RgbConverter.Convert<ColorR<Half>, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 61:
|
||||
RgbConverter.Convert<ColorRG<Half>, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 62:
|
||||
RgbConverter.Convert<ColorRGB<Half>, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 63:
|
||||
RgbConverter.Convert<ColorRGBA<Half>, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 64:
|
||||
RgbConverter.Convert<ColorA<Half>, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 65:
|
||||
RgbConverter.Convert<ColorR<float>, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 66:
|
||||
RgbConverter.Convert<ColorRG<float>, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 67:
|
||||
RgbConverter.Convert<ColorRGB<float>, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 68:
|
||||
RgbConverter.Convert<ColorRGBA<float>, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 69:
|
||||
RgbConverter.Convert<ColorA<float>, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 70:
|
||||
RgbConverter.Convert<ColorR<NFloat>, NFloat, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 71:
|
||||
RgbConverter.Convert<ColorRG<NFloat>, NFloat, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 72:
|
||||
RgbConverter.Convert<ColorRGB<NFloat>, NFloat, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 73:
|
||||
RgbConverter.Convert<ColorRGBA<NFloat>, NFloat, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 74:
|
||||
RgbConverter.Convert<ColorA<NFloat>, NFloat, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 75:
|
||||
RgbConverter.Convert<ColorR<double>, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 76:
|
||||
RgbConverter.Convert<ColorRG<double>, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 77:
|
||||
RgbConverter.Convert<ColorRGB<double>, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 78:
|
||||
RgbConverter.Convert<ColorRGBA<double>, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 79:
|
||||
RgbConverter.Convert<ColorA<double>, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 80:
|
||||
RgbConverter.Convert<ColorR<decimal>, decimal, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 81:
|
||||
RgbConverter.Convert<ColorRG<decimal>, decimal, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 82:
|
||||
RgbConverter.Convert<ColorRGB<decimal>, decimal, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 83:
|
||||
RgbConverter.Convert<ColorRGBA<decimal>, decimal, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 84:
|
||||
RgbConverter.Convert<ColorA<decimal>, decimal, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 85:
|
||||
RgbConverter.Convert<ColorARGB16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 86:
|
||||
RgbConverter.Convert<ColorARGB32, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 87:
|
||||
RgbConverter.Convert<ColorBGRA32, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 88:
|
||||
RgbConverter.Convert<ColorRGB16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 89:
|
||||
RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 90:
|
||||
RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 91:
|
||||
RgbConverter.Convert<ColorR<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 92:
|
||||
RgbConverter.Convert<ColorRG<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 93:
|
||||
RgbConverter.Convert<ColorRGB<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 94:
|
||||
RgbConverter.Convert<ColorRGBA<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 95:
|
||||
RgbConverter.Convert<ColorA<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 96:
|
||||
RgbConverter.Convert<ColorARGB<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 97:
|
||||
RgbConverter.Convert<ColorBGRA<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 98:
|
||||
RgbConverter.Convert<ColorR<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 99:
|
||||
RgbConverter.Convert<ColorRG<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 100:
|
||||
RgbConverter.Convert<ColorRGB<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 101:
|
||||
RgbConverter.Convert<ColorRGBA<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 102:
|
||||
RgbConverter.Convert<ColorA<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 103:
|
||||
RgbConverter.Convert<ColorARGB<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 104:
|
||||
RgbConverter.Convert<ColorBGRA<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 105:
|
||||
RgbConverter.Convert<ColorR<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 106:
|
||||
RgbConverter.Convert<ColorRG<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 107:
|
||||
RgbConverter.Convert<ColorRGB<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 108:
|
||||
RgbConverter.Convert<ColorRGBA<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 109:
|
||||
RgbConverter.Convert<ColorA<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 110:
|
||||
RgbConverter.Convert<ColorARGB<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 111:
|
||||
RgbConverter.Convert<ColorBGRA<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 112:
|
||||
RgbConverter.Convert<ColorR<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 113:
|
||||
RgbConverter.Convert<ColorRG<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 114:
|
||||
RgbConverter.Convert<ColorRGB<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 115:
|
||||
RgbConverter.Convert<ColorRGBA<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 116:
|
||||
RgbConverter.Convert<ColorA<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 117:
|
||||
RgbConverter.Convert<ColorARGB<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 118:
|
||||
RgbConverter.Convert<ColorBGRA<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 119:
|
||||
RgbConverter.Convert<ColorARGB16, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 120:
|
||||
RgbConverter.Convert<ColorRGB16, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 121:
|
||||
RgbConverter.Convert<ColorRGB9e5, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 122:
|
||||
RgbConverter.Convert<ColorRGBA16, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(mode.ToString());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using AssetRipper.Text.SourceGeneration;
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Channels;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using AssetRipper.TextureDecoder.SourceGeneration.Common;
|
||||
using System.CodeDom.Compiler;
|
||||
@@ -12,8 +13,6 @@ namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
internal static readonly List<GenerationData> dataList = new()
|
||||
{
|
||||
GenerationData.Create<ColorARGB16>(2),
|
||||
GenerationData.Create<ColorARGB32>(4),
|
||||
GenerationData.Create<ColorBGRA32>(4),
|
||||
GenerationData.Create<ColorRGB16>(2),
|
||||
GenerationData.Create<ColorRGB9e5>(4),
|
||||
GenerationData.Create<ColorRGBA16>(2),
|
||||
@@ -35,7 +34,8 @@ namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"using {typeof(RgbConverter).Namespace};");
|
||||
writer.WriteLine($"using {typeof(ColorBGRA32).Namespace};");
|
||||
writer.WriteLine($"using {typeof(B).Namespace};");
|
||||
writer.WriteLine($"using {typeof(ColorRGBA16).Namespace};");
|
||||
writer.WriteLine($"using {typeof(NFloat).Namespace};");
|
||||
writer.WriteLine();
|
||||
|
||||
|
||||
@@ -75,27 +75,27 @@ internal static class TestClassGenerator
|
||||
}
|
||||
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorRGBA<byte>)}<{channelTypeName}>", channelTypeName);
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorRGBA<>)}<{channelTypeName}>", channelTypeName);
|
||||
|
||||
if (!data.AlphaChannel)
|
||||
{
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorRGB<byte>)}<{channelTypeName}>", channelTypeName);
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorRGB<>)}<{channelTypeName}>", channelTypeName);
|
||||
if (!data.BlueChannel)
|
||||
{
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorRG<byte>)}<{channelTypeName}>", channelTypeName);
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorRG<>)}<{channelTypeName}>", channelTypeName);
|
||||
if (!data.GreenChannel)
|
||||
{
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorR<byte>)}<{channelTypeName}>", channelTypeName);
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorR<>)}<{channelTypeName}>", channelTypeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!data.RedChannel && !data.GreenChannel && !data.BlueChannel)
|
||||
{
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorA<byte>)}<{channelTypeName}>", channelTypeName);
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorA<>)}<{channelTypeName}>", channelTypeName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,11 +135,13 @@ internal static class TestClassGenerator
|
||||
|
||||
internal static IEnumerable<string> GetGenericColorNames()
|
||||
{
|
||||
yield return nameof(ColorR<byte>);
|
||||
yield return nameof(ColorRG<byte>);
|
||||
yield return nameof(ColorRGB<byte>);
|
||||
yield return nameof(ColorRGBA<byte>);
|
||||
yield return nameof(ColorA<byte>);
|
||||
yield return nameof(ColorR<>);
|
||||
yield return nameof(ColorRG<>);
|
||||
yield return nameof(ColorRGB<>);
|
||||
yield return nameof(ColorRGBA<>);
|
||||
yield return nameof(ColorA<>);
|
||||
yield return nameof(ColorARGB<>);
|
||||
yield return nameof(ColorBGRA<>);
|
||||
}
|
||||
|
||||
private static void MakeLosslessColorTests()
|
||||
@@ -218,7 +220,7 @@ internal static class TestClassGenerator
|
||||
|
||||
textWriter.WriteLine("var color = MakeRandomColor();");
|
||||
textWriter.WriteLine("color.GetChannels(out var r, out var g, out var b, out var a);");
|
||||
textWriter.WriteLine("Assert.Multiple(() =>");
|
||||
textWriter.WriteLine("using (Assert.EnterMultipleScope())");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
@@ -228,7 +230,7 @@ internal static class TestClassGenerator
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
textWriter.WriteLine("};");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
@@ -248,7 +250,7 @@ internal static class TestClassGenerator
|
||||
}
|
||||
textWriter.WriteLine($"color.{channel} = MakeRandomValue();");
|
||||
|
||||
textWriter.WriteLine("Assert.Multiple(() =>");
|
||||
textWriter.WriteLine("using (Assert.EnterMultipleScope())");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
@@ -258,7 +260,7 @@ internal static class TestClassGenerator
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
textWriter.WriteLine("};");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
@@ -308,7 +310,7 @@ internal static class TestClassGenerator
|
||||
textWriter.WriteLine("var color = MakeRandomColor();");
|
||||
textWriter.WriteLine("color.GetChannels(out var r, out var g, out var b, out var a);");
|
||||
textWriter.WriteLine("color.SetChannels(r, g, b, a);");
|
||||
textWriter.WriteLine("Assert.Multiple(() =>");
|
||||
textWriter.WriteLine("using (Assert.EnterMultipleScope())");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
@@ -318,7 +320,7 @@ internal static class TestClassGenerator
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
textWriter.WriteLine("};");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
|
||||
@@ -68,7 +68,7 @@ public sealed class AstcTests
|
||||
private static void AssertCorrectDecompression<T>(int blockWidth, int blockHeight, double maxMeanDeviation, double maxStandardDeviation) where T : ITexture
|
||||
{
|
||||
ReadOnlySpan<byte> data = T.Data;
|
||||
int bytesRead = AstcDecoder.DecodeASTC<ColorBGRA32, byte>(data, T.Width, T.Height, blockWidth, blockHeight, out byte[] decompressedData);
|
||||
int bytesRead = AstcDecoder.DecodeASTC<ColorBGRA<byte>, byte>(data, T.Width, T.Height, blockWidth, blockHeight, out byte[] decompressedData);
|
||||
if (!T.Mips)
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
@@ -79,6 +79,6 @@ public sealed class AstcTests
|
||||
[TestCase(new byte[16] { 83, 1, 147, 104, 198, 173, 55, 116, 182, 66, 105, 11, 102, 43, 148, 125 }, 8, 8, TestName = "GetBits Should not throw in DecodeIntseq")]
|
||||
public void DecodesBlockWithoutThrowing(byte[] block, int blockWidth, int blockHeight)
|
||||
{
|
||||
Assert.DoesNotThrow(() => AstcDecoder.DecodeASTC<ColorBGRA32, byte>(block, blockWidth, blockHeight, blockWidth, blockHeight, out _));
|
||||
Assert.DoesNotThrow(() => AstcDecoder.DecodeASTC<ColorBGRA<byte>, byte>(block, blockWidth, blockHeight, blockWidth, blockHeight, out _));
|
||||
}
|
||||
}
|
||||
@@ -8,24 +8,24 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
public void DecompressAtcRgb4Test()
|
||||
{
|
||||
byte[] data = File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgb4");
|
||||
int bytesRead = Atc.AtcDecoder.DecompressAtcRgb4<ColorBGRA32, byte>(data, 256, 256, out byte[] decodedData);
|
||||
Assert.Multiple(() =>
|
||||
int bytesRead = Atc.AtcDecoder.DecompressAtcRgb4<ColorBGRA<byte>, byte>(data, 256, 256, out byte[] decodedData);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Is.EqualTo(File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgb4_decoded")));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressAtcRgba8Test()
|
||||
{
|
||||
byte[] data = File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgba8");
|
||||
int bytesRead = Atc.AtcDecoder.DecompressAtcRgba8<ColorBGRA32, byte>(data, 256, 256, out byte[] decodedData);
|
||||
Assert.Multiple(() =>
|
||||
int bytesRead = Atc.AtcDecoder.DecompressAtcRgba8<ColorBGRA<byte>, byte>(data, 256, 256, out byte[] decodedData);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Is.EqualTo(File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgba8_decoded")));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,8 +27,8 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output
|
||||
{
|
||||
int bytesRead = Bc1.Decompress<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT1<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
int bytesRead = Bc1.Decompress<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT1<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
|
||||
}
|
||||
@@ -42,8 +42,8 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output
|
||||
{
|
||||
int bytesRead = Bc2.Decompress<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT3<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
int bytesRead = Bc2.Decompress<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT3<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
|
||||
}
|
||||
@@ -57,8 +57,8 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output
|
||||
{
|
||||
int bytesRead = Bc3.Decompress<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT5<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
int bytesRead = Bc3.Decompress<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT5<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
public void Decompress_BC4()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc4");
|
||||
int bytesRead = Bc4.Decompress<ColorBGRA32, byte>(data, 512, 512, out _);
|
||||
int bytesRead = Bc4.Decompress<ColorBGRA<byte>, byte>(data, 512, 512, out _);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
public void Decompress_BC5()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc5");
|
||||
int bytesRead = Bc5.Decompress<ColorBGRA32, byte>(data, 512, 512, out _);
|
||||
int bytesRead = Bc5.Decompress<ColorBGRA<byte>, byte>(data, 512, 512, out _);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
@@ -100,91 +100,91 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[Test]
|
||||
public void PartialBlock_BC1([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt1").AsSpan()[..Bc1.BlockSize];
|
||||
int bytesRead = Bc1.Decompress<ColorBGRA32, byte>(data, width, height, out byte[] decodedData);
|
||||
int bytesRead = Bc1.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA32>()));
|
||||
});
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartialBlock_BC2([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt3").AsSpan()[..Bc2.BlockSize];
|
||||
int bytesRead = Bc2.Decompress<ColorBGRA32, byte>(data, width, height, out byte[] decodedData);
|
||||
int bytesRead = Bc2.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA32>()));
|
||||
});
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartialBlock_BC3([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt5").AsSpan()[..Bc3.BlockSize];
|
||||
int bytesRead = Bc3.Decompress<ColorBGRA32, byte>(data, width, height, out byte[] decodedData);
|
||||
int bytesRead = Bc3.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA32>()));
|
||||
});
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartialBlock_BC4([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc4").AsSpan()[..Bc4.BlockSize];
|
||||
int bytesRead = Bc4.Decompress<ColorBGRA32, byte>(data, width, height, out byte[] decodedData);
|
||||
int bytesRead = Bc4.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA32>()));
|
||||
});
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartialBlock_BC5([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc5").AsSpan()[..Bc5.BlockSize];
|
||||
int bytesRead = Bc5.Decompress<ColorBGRA32, byte>(data, width, height, out byte[] decodedData);
|
||||
int bytesRead = Bc5.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA32>()));
|
||||
});
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartialBlock_BC6H([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc6h_best").AsSpan()[..Bc6h.BlockSize];
|
||||
int bytesRead = Bc6h.Decompress<ColorBGRA32, byte>(data, width, height, false, out byte[] decodedData);
|
||||
int bytesRead = Bc6h.Decompress<ColorBGRA<byte>, byte>(data, width, height, false, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA32>()));
|
||||
});
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartialBlock_BC7([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc7_best").AsSpan()[..Bc7.BlockSize];
|
||||
int bytesRead = Bc7.Decompress<ColorBGRA32, byte>(data, width, height, out byte[] decodedData);
|
||||
int bytesRead = Bc7.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA32>()));
|
||||
});
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertCorrectBC6HDecompression(string path, int width, int height, bool isSigned)
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(path);
|
||||
int bytesRead = Bc6h.Decompress<ColorBGRA32, byte>(data, width, height, isSigned, out byte[] decodedData);
|
||||
int bytesRead = Bc6h.Decompress<ColorBGRA<byte>, byte>(data, width, height, isSigned, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
ByteArrayDeviation.AssertMinimalDeviation(decodedData, originalBgra32LogoData, MaxMeanDeviationBc6h, MaxStandardDeviationBc6h);
|
||||
}
|
||||
@@ -192,7 +192,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
private static void AssertCorrectBC7Decompression(string path, int width, int height)
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(path);
|
||||
int bytesRead = Bc7.Decompress<ColorBGRA32, byte>(data, width, height, out byte[] decodedData);
|
||||
int bytesRead = Bc7.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
ByteArrayDeviation.AssertMinimalDeviation(decodedData, originalBgra32LogoData, MaxMeanDeviationBc7, MaxStandardDeviationBc7);
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ internal static class ByteArrayDeviation
|
||||
double standardDeviation = Math.Sqrt(sumOfSquaredDeviations / (decoded.Length - 1));
|
||||
//Not sure if Bessel's correction is needed here, but it doesn't hurt, especially since length is around 1 million in the current use.
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(mean, Is.LessThan(maxMeanDeviation), "Mean too far positive");
|
||||
Assert.That(mean, Is.GreaterThan(-maxMeanDeviation), "Mean too far negative");
|
||||
Assert.That(standardDeviation, Is.LessThan(maxStandardDeviation), "Standard deviation too large");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT1<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT1<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -24,7 +24,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT3<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT3<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -37,7 +37,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT5<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT5<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
|
||||
@@ -6,14 +6,14 @@ namespace AssetRipper.TextureDecoder.Tests;
|
||||
|
||||
public sealed class EtcTests
|
||||
{
|
||||
private static DecodingDelegate ETCDelegate { get; } = EtcDecoder.DecompressETC<ColorBGRA32, byte>;
|
||||
private static DecodingDelegate ETC2Delegate { get; } = EtcDecoder.DecompressETC2<ColorBGRA32, byte>;
|
||||
private static DecodingDelegate ETC2A1Delegate { get; } = EtcDecoder.DecompressETC2A1<ColorBGRA32, byte>;
|
||||
private static DecodingDelegate ETC2A8Delegate { get; } = EtcDecoder.DecompressETC2A8<ColorBGRA32, byte>;
|
||||
private static DecodingDelegate EACRSignedDelegate { get; } = EtcDecoder.DecompressEACRSigned<ColorBGRA32, byte>;
|
||||
private static DecodingDelegate EACRUnsignedDelegate { get; } = EtcDecoder.DecompressEACRUnsigned<ColorBGRA32, byte>;
|
||||
private static DecodingDelegate EACRGSignedDelegate { get; } = EtcDecoder.DecompressEACRGSigned<ColorBGRA32, byte>;
|
||||
private static DecodingDelegate EACRGUnsignedDelegate { get; } = EtcDecoder.DecompressEACRGUnsigned<ColorBGRA32, byte>;
|
||||
private static DecodingDelegate ETCDelegate { get; } = EtcDecoder.DecompressETC<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate ETC2Delegate { get; } = EtcDecoder.DecompressETC2<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate ETC2A1Delegate { get; } = EtcDecoder.DecompressETC2A1<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate ETC2A8Delegate { get; } = EtcDecoder.DecompressETC2A8<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate EACRSignedDelegate { get; } = EtcDecoder.DecompressEACRSigned<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate EACRUnsignedDelegate { get; } = EtcDecoder.DecompressEACRUnsigned<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate EACRGSignedDelegate { get; } = EtcDecoder.DecompressEACRGSigned<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate EACRGUnsignedDelegate { get; } = EtcDecoder.DecompressEACRGUnsigned<ColorBGRA<byte>, byte>;
|
||||
|
||||
[Test]
|
||||
public void DecompressETCTest() => AssertCorrectByteCountReadFor256SquareWithMips(TestFileFolders.EtcTestFiles + "test.etc", ETCDelegate);
|
||||
@@ -88,12 +88,12 @@ public sealed class EtcTests
|
||||
byte[] comparisonData = AndroidTextures.Logo_00.Data;
|
||||
|
||||
//Remove unused color channels
|
||||
if (typeof(TColor) != typeof(ColorBGRA32) && typeof(TColor) != typeof(ColorRGBA<byte>))
|
||||
if (typeof(TColor) != typeof(ColorBGRA<byte>) && typeof(TColor) != typeof(ColorRGBA<byte>))
|
||||
{
|
||||
Span<ColorBGRA32> pixels = MemoryMarshal.Cast<byte, ColorBGRA32>((Span<byte>)comparisonData);
|
||||
Span<ColorBGRA<byte>> pixels = MemoryMarshal.Cast<byte, ColorBGRA<byte>>((Span<byte>)comparisonData);
|
||||
for (int i = 0; i < pixels.Length; i++)
|
||||
{
|
||||
pixels[i] = pixels[i].Convert<ColorBGRA32, byte, TColor, byte>().Convert<TColor, byte, ColorBGRA32, byte>();
|
||||
pixels[i] = pixels[i].Convert<ColorBGRA<byte>, byte, TColor, byte>().Convert<TColor, byte, ColorBGRA<byte>, byte>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,12 +57,12 @@ public partial class ColorARGB16Tests
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -73,12 +73,12 @@ public partial class ColorARGB16Tests
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -89,12 +89,12 @@ public partial class ColorARGB16Tests
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -105,12 +105,12 @@ public partial class ColorARGB16Tests
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -118,13 +118,13 @@ public partial class ColorARGB16Tests
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -133,31 +133,19 @@ public partial class ColorARGB16Tests
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
color.SetChannels(r, g, b, a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public static ColorARGB16 MakeRandomColor() => ColorRandom<ColorARGB16, byte>.MakeRandomColor();
|
||||
|
||||
public static byte MakeRandomValue() => ColorRandom<ColorARGB16, byte>.MakeRandomValue();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorARGB32()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorARGB32, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorBGRA32()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorBGRA32, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_sbyte()
|
||||
{
|
||||
|
||||
@@ -1,232 +0,0 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorARGB32Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorARGB32>(), Is.EqualTo(4));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_R()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var r = color.R;
|
||||
color.R = r;
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_G()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var g = color.G;
|
||||
color.G = g;
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_B()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var b = color.B;
|
||||
color.B = b;
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_A()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var a = color.A;
|
||||
color.A = a;
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_R()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_G()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var r = color.R;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_B()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_A()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetMethodMatchesProperties()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MethodsAreSymmetric()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
color.SetChannels(r, g, b, a);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorARGB32 MakeRandomColor() => ColorRandom<ColorARGB32, byte>.MakeRandomColor();
|
||||
|
||||
public static byte MakeRandomValue() => ColorRandom<ColorARGB32, byte>.MakeRandomValue();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorARGB32()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorARGB32, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorBGRA32()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorBGRA32, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_sbyte()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<sbyte>, sbyte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_byte()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<byte>, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_short()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<short>, short>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_ushort()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<ushort>, ushort>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_int()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<int>, int>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_uint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<uint>, uint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_nint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<nint>, nint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_nuint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<nuint>, nuint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_long()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<long>, long>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_ulong()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<ulong>, ulong>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_Int128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<Int128>, Int128>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_UInt128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB32, byte, ColorRGBA<UInt128>, UInt128>();
|
||||
}
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorBGRA32Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorBGRA32>(), Is.EqualTo(4));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_R()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var r = color.R;
|
||||
color.R = r;
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_G()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var g = color.G;
|
||||
color.G = g;
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_B()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var b = color.B;
|
||||
color.B = b;
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_A()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var a = color.A;
|
||||
color.A = a;
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_R()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_G()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var r = color.R;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_B()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_A()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetMethodMatchesProperties()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MethodsAreSymmetric()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
color.SetChannels(r, g, b, a);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorBGRA32 MakeRandomColor() => ColorRandom<ColorBGRA32, byte>.MakeRandomColor();
|
||||
|
||||
public static byte MakeRandomValue() => ColorRandom<ColorBGRA32, byte>.MakeRandomValue();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorARGB32()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorARGB32, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorBGRA32()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorBGRA32, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_sbyte()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<sbyte>, sbyte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_byte()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<byte>, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_short()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<short>, short>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_ushort()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<ushort>, ushort>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_int()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<int>, int>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_uint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<uint>, uint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_nint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<nint>, nint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_nuint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<nuint>, nuint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_long()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<long>, long>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_ulong()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<ulong>, ulong>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_Int128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<Int128>, Int128>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_UInt128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorBGRA32, byte, ColorRGBA<UInt128>, UInt128>();
|
||||
}
|
||||
}
|
||||
@@ -57,12 +57,12 @@ public partial class ColorRGB16Tests
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -73,12 +73,12 @@ public partial class ColorRGB16Tests
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -89,12 +89,12 @@ public partial class ColorRGB16Tests
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -105,12 +105,12 @@ public partial class ColorRGB16Tests
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -118,13 +118,13 @@ public partial class ColorRGB16Tests
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -133,31 +133,19 @@ public partial class ColorRGB16Tests
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
color.SetChannels(r, g, b, a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public static ColorRGB16 MakeRandomColor() => ColorRandom<ColorRGB16, byte>.MakeRandomColor();
|
||||
|
||||
public static byte MakeRandomValue() => ColorRandom<ColorRGB16, byte>.MakeRandomValue();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorARGB32()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorARGB32, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorBGRA32()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorBGRA32, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_sbyte()
|
||||
{
|
||||
|
||||
@@ -18,13 +18,13 @@ public partial class ColorRGB9e5Tests
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -33,13 +33,13 @@ public partial class ColorRGB9e5Tests
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
color.SetChannels(r, g, b, a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public static ColorRGB9e5 MakeRandomColor() => ColorRandom<ColorRGB9e5, double>.MakeRandomColor();
|
||||
|
||||
@@ -57,12 +57,12 @@ public partial class ColorRGBA16Tests
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -73,12 +73,12 @@ public partial class ColorRGBA16Tests
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -89,12 +89,12 @@ public partial class ColorRGBA16Tests
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -105,12 +105,12 @@ public partial class ColorRGBA16Tests
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -118,13 +118,13 @@ public partial class ColorRGBA16Tests
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -133,31 +133,19 @@ public partial class ColorRGBA16Tests
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
color.SetChannels(r, g, b, a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public static ColorRGBA16 MakeRandomColor() => ColorRandom<ColorRGBA16, byte>.MakeRandomColor();
|
||||
|
||||
public static byte MakeRandomValue() => ColorRandom<ColorRGBA16, byte>.MakeRandomValue();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorARGB32()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorARGB32, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorBGRA32()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorBGRA32, byte>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_sbyte()
|
||||
{
|
||||
|
||||
@@ -55,12 +55,12 @@ internal partial class GenericColorTests<TColor, TChannelValue> where TColor : u
|
||||
TChannelValue b = color.B;
|
||||
TChannelValue a = color.A;
|
||||
color.R = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -71,12 +71,12 @@ internal partial class GenericColorTests<TColor, TChannelValue> where TColor : u
|
||||
TChannelValue b = color.B;
|
||||
TChannelValue a = color.A;
|
||||
color.G = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -87,12 +87,12 @@ internal partial class GenericColorTests<TColor, TChannelValue> where TColor : u
|
||||
TChannelValue g = color.G;
|
||||
TChannelValue a = color.A;
|
||||
color.B = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -103,12 +103,12 @@ internal partial class GenericColorTests<TColor, TChannelValue> where TColor : u
|
||||
TChannelValue g = color.G;
|
||||
TChannelValue b = color.B;
|
||||
color.A = MakeRandomValue();
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -116,13 +116,13 @@ internal partial class GenericColorTests<TColor, TChannelValue> where TColor : u
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
color.GetChannels(out TChannelValue r, out TChannelValue g, out TChannelValue b, out TChannelValue a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -131,13 +131,13 @@ internal partial class GenericColorTests<TColor, TChannelValue> where TColor : u
|
||||
TColor color = MakeRandomColor();
|
||||
color.GetChannels(out TChannelValue r, out TChannelValue g, out TChannelValue b, out TChannelValue a);
|
||||
color.SetChannels(r, g, b, a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static TChannelValue MakeRandomValue() => ColorRandom<TColor, TChannelValue>.MakeRandomValue();
|
||||
|
||||
@@ -8,86 +8,120 @@ namespace AssetRipper.TextureDecoder.Tests.Formats.Generic;
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<decimal>), typeof(decimal) })]
|
||||
partial class GenericColorTests<TColor, TChannelValue>
|
||||
{
|
||||
}
|
||||
+20
-20
@@ -9,26 +9,26 @@ namespace AssetRipper.TextureDecoder.Tests.Formats.Generic;
|
||||
[TestFixture(TypeArgs = [typeof(long), typeof(ulong)])]
|
||||
[TestFixture(TypeArgs = [typeof(Int128), typeof(UInt128)])]
|
||||
internal class NumericConversionExtremesTests<TSigned, TUnsigned>
|
||||
where TSigned : unmanaged, IMinMaxValue<TSigned>
|
||||
where TUnsigned : unmanaged, IMinMaxValue<TUnsigned>
|
||||
where TSigned : unmanaged, IMinMaxValue<TSigned>
|
||||
where TUnsigned : unmanaged, IMinMaxValue<TUnsigned>
|
||||
{
|
||||
[Test]
|
||||
public void SignedToUnsignedExtremesAreCorrect()
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(NumericConversion.Convert<TSigned, TUnsigned>(TSigned.MinValue), Is.EqualTo(TUnsigned.MinValue));
|
||||
Assert.That(NumericConversion.Convert<TSigned, TUnsigned>(TSigned.MaxValue), Is.EqualTo(TUnsigned.MaxValue));
|
||||
});
|
||||
}
|
||||
[Test]
|
||||
public void SignedToUnsignedExtremesAreCorrect()
|
||||
{
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(NumericConversion.Convert<TSigned, TUnsigned>(TSigned.MinValue), Is.EqualTo(TUnsigned.MinValue));
|
||||
Assert.That(NumericConversion.Convert<TSigned, TUnsigned>(TSigned.MaxValue), Is.EqualTo(TUnsigned.MaxValue));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnsignedToSignedExtremesAreCorrect()
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(NumericConversion.Convert<TUnsigned, TSigned>(TUnsigned.MinValue), Is.EqualTo(TSigned.MinValue));
|
||||
Assert.That(NumericConversion.Convert<TUnsigned, TSigned>(TUnsigned.MaxValue), Is.EqualTo(TSigned.MaxValue));
|
||||
});
|
||||
}
|
||||
[Test]
|
||||
public void UnsignedToSignedExtremesAreCorrect()
|
||||
{
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(NumericConversion.Convert<TUnsigned, TSigned>(TUnsigned.MinValue), Is.EqualTo(TSigned.MinValue));
|
||||
Assert.That(NumericConversion.Convert<TUnsigned, TSigned>(TUnsigned.MaxValue), Is.EqualTo(TSigned.MaxValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.A8ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorA<byte>, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorA<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
@@ -27,7 +27,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.Convert<ColorARGB16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = RgbConverter.Convert<ColorARGB16, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -41,7 +41,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.RGB24ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB<byte>, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRGB<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.RGBA32ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<byte>, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
@@ -71,7 +71,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.ARGB32ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorARGB32, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorARGB<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.RGB16ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRGB16, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
@@ -100,7 +100,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.Convert<ColorR<ushort>, ushort, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = RgbConverter.Convert<ColorR<ushort>, ushort, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -113,7 +113,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -127,7 +127,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.RG16ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG<byte>, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRG<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
@@ -142,7 +142,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.R8ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorR<byte>, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorR<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
@@ -154,7 +154,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rhalf");
|
||||
RgbConverter.RHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorR<Half>, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorR<Half>, Half, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rghalf");
|
||||
RgbConverter.RGHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG<Half>, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRG<Half>, Half, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgbahalf");
|
||||
RgbConverter.RGBAHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<Half>, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<Half>, Half, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rfloat");
|
||||
RgbConverter.RFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorR<float>, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorR<float>, float, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgfloat");
|
||||
RgbConverter.RGFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG<float>, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRG<float>, float, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgbafloat");
|
||||
RgbConverter.RGBAFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<float>, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<float>, float, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgb9e5float");
|
||||
RgbConverter.RGB9e5FloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rg32");
|
||||
RgbConverter.RG32ToBGRA32(data, 512, 512, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG<ushort>, ushort, ColorBGRA32, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRG<ushort>, ushort, ColorBGRA<byte>, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgb48");
|
||||
RgbConverter.RGB48ToBGRA32(data, 512, 512, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB<ushort>, ushort, ColorBGRA32, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRGB<ushort>, ushort, ColorBGRA<byte>, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgba64");
|
||||
RgbConverter.RGBA64ToBGRA32(data, 512, 512, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<ushort>, ushort, ColorBGRA32, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<ushort>, ushort, ColorBGRA<byte>, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public sealed class PvrtcTests
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = PvrtcDecoder.DecompressPVRTC<ColorBGRA32, byte>(data, size, size, false, out _);
|
||||
int bytesRead = PvrtcDecoder.DecompressPVRTC<ColorBGRA<byte>, byte>(data, size, size, false, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -33,7 +33,7 @@ public sealed class PvrtcTests
|
||||
private static void AssertCorrectDecompression<T>(bool do2bitMode, double maxMeanDeviation, double maxStandardDeviation) where T : ITexture
|
||||
{
|
||||
ReadOnlySpan<byte> data = T.Data;
|
||||
int bytesRead = PvrtcDecoder.DecompressPVRTC<ColorBGRA32, byte>(data, T.Width, T.Height, do2bitMode, out byte[] decompressedData);
|
||||
int bytesRead = PvrtcDecoder.DecompressPVRTC<ColorBGRA<byte>, byte>(data, T.Width, T.Height, do2bitMode, out byte[] decompressedData);
|
||||
if (!T.Mips)
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
|
||||
@@ -13,12 +13,12 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
public void DecompressYUY2Test()
|
||||
{
|
||||
byte[] input = File.ReadAllBytes(TestFileFolders.Yuy2TestFiles + "test.yuy2");
|
||||
int bytesRead = Yuy2Decoder.DecompressYUY2<ColorBGRA32, byte>(input, TestImageWidth, TestImageHeight, out byte[] decodedData);
|
||||
Assert.Multiple(() =>
|
||||
int bytesRead = Yuy2Decoder.DecompressYUY2<ColorBGRA<byte>, byte>(input, TestImageWidth, TestImageHeight, out byte[] decodedData);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(input.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(TestImageWidth * TestImageHeight * Unsafe.SizeOf<ColorBGRA32>()));
|
||||
});
|
||||
Assert.That(decodedData, Has.Length.EqualTo(TestImageWidth * TestImageHeight * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
public partial struct ColorA<T> : IColor<ColorA<T>, T> where T : unmanaged, INumberBase<T>, IMinMaxValue<T>
|
||||
{
|
||||
public T A { get; set; }
|
||||
|
||||
public readonly T R
|
||||
{
|
||||
get => NumericConversion.GetMinimumValueSafe<T>();
|
||||
@@ -22,8 +24,6 @@ public partial struct ColorA<T> : IColor<ColorA<T>, T> where T : unmanaged, INum
|
||||
set { }
|
||||
}
|
||||
|
||||
public T A { get; set; }
|
||||
|
||||
public ColorA(T a)
|
||||
{
|
||||
A = a;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
public partial struct ColorARGB<T> : IColor<ColorARGB<T>, T> where T : unmanaged, INumberBase<T>, IMinMaxValue<T>
|
||||
{
|
||||
public T A { get; set; }
|
||||
|
||||
public T R { get; set; }
|
||||
|
||||
public T G { get; set; }
|
||||
|
||||
public T B { get; set; }
|
||||
|
||||
public ColorARGB(T r, T g, T b, T a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
B = b;
|
||||
A = a;
|
||||
}
|
||||
|
||||
public readonly void GetChannels(out T r, out T g, out T b, out T a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(T r, T g, T b, T a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
B = b;
|
||||
A = a;
|
||||
}
|
||||
|
||||
static bool IColor.HasRedChannel => true;
|
||||
static bool IColor.HasGreenChannel => true;
|
||||
static bool IColor.HasBlueChannel => true;
|
||||
static bool IColor.HasAlphaChannel => true;
|
||||
static bool IColor.ChannelsAreFullyUtilized => true;
|
||||
static Type IColor.ChannelType => typeof(T);
|
||||
|
||||
public static ColorARGB<T> Black => new(NumericConversion.GetMinimumValueSafe<T>(), NumericConversion.GetMinimumValueSafe<T>(), NumericConversion.GetMinimumValueSafe<T>(), NumericConversion.GetMaximumValueSafe<T>());
|
||||
public static ColorARGB<T> White => new(NumericConversion.GetMaximumValueSafe<T>(), NumericConversion.GetMaximumValueSafe<T>(), NumericConversion.GetMaximumValueSafe<T>(), NumericConversion.GetMaximumValueSafe<T>());
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{{ R: {R}, G: {G}, B: {B}, A: {A} }}";
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public partial struct ColorARGB32 : IColor<byte>
|
||||
{
|
||||
public byte A { get; set; }
|
||||
public byte R { get; set; }
|
||||
public byte G { get; set; }
|
||||
public byte B { get; set; }
|
||||
|
||||
public readonly void GetChannels(out byte r, out byte g, out byte b, out byte a)
|
||||
{
|
||||
DefaultColorMethods.GetChannels(this, out r, out g, out b, out a);
|
||||
}
|
||||
|
||||
public void SetChannels(byte r, byte g, byte b, byte a)
|
||||
{
|
||||
DefaultColorMethods.SetChannels(ref this, r, g, b, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public partial struct ColorARGB32 : IColor<byte>
|
||||
{
|
||||
static bool IColor.HasRedChannel => true;
|
||||
static bool IColor.HasGreenChannel => true;
|
||||
static bool IColor.HasBlueChannel => true;
|
||||
static bool IColor.HasAlphaChannel => true;
|
||||
static bool IColor.ChannelsAreFullyUtilized => true;
|
||||
static Type IColor.ChannelType => typeof(byte);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{{ R: {R}, G: {G}, B: {B}, A: {A} }}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
public partial struct ColorBGR<T> : IColor<ColorBGR<T>, T> where T : unmanaged, INumberBase<T>, IMinMaxValue<T>
|
||||
{
|
||||
public T B { get; set; }
|
||||
|
||||
public T G { get; set; }
|
||||
|
||||
public T R { get; set; }
|
||||
|
||||
public readonly T A
|
||||
{
|
||||
get => NumericConversion.GetMaximumValueSafe<T>();
|
||||
set { }
|
||||
}
|
||||
|
||||
public ColorBGR(T r, T g, T b)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
B = b;
|
||||
}
|
||||
|
||||
public readonly void GetChannels(out T r, out T g, out T b, out T a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(T r, T g, T b, T a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
B = b;
|
||||
}
|
||||
|
||||
static bool IColor.HasRedChannel => true;
|
||||
static bool IColor.HasGreenChannel => true;
|
||||
static bool IColor.HasBlueChannel => true;
|
||||
static bool IColor.HasAlphaChannel => false;
|
||||
static bool IColor.ChannelsAreFullyUtilized => true;
|
||||
static Type IColor.ChannelType => typeof(T);
|
||||
|
||||
public static ColorBGR<T> Black => new(NumericConversion.GetMinimumValueSafe<T>(), NumericConversion.GetMinimumValueSafe<T>(), NumericConversion.GetMinimumValueSafe<T>());
|
||||
public static ColorBGR<T> White => new(NumericConversion.GetMaximumValueSafe<T>(), NumericConversion.GetMaximumValueSafe<T>(), NumericConversion.GetMaximumValueSafe<T>());
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{{ R: {R}, G: {G}, B: {B} }}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
public partial struct ColorBGRA<T> : IColor<ColorBGRA<T>, T> where T : unmanaged, INumberBase<T>, IMinMaxValue<T>
|
||||
{
|
||||
public T B { get; set; }
|
||||
|
||||
public T G { get; set; }
|
||||
|
||||
public T R { get; set; }
|
||||
|
||||
public T A { get; set; }
|
||||
|
||||
public ColorBGRA(T r, T g, T b, T a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
B = b;
|
||||
A = a;
|
||||
}
|
||||
|
||||
public readonly void GetChannels(out T r, out T g, out T b, out T a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(T r, T g, T b, T a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
B = b;
|
||||
A = a;
|
||||
}
|
||||
|
||||
static bool IColor.HasRedChannel => true;
|
||||
static bool IColor.HasGreenChannel => true;
|
||||
static bool IColor.HasBlueChannel => true;
|
||||
static bool IColor.HasAlphaChannel => true;
|
||||
static bool IColor.ChannelsAreFullyUtilized => true;
|
||||
static Type IColor.ChannelType => typeof(T);
|
||||
|
||||
public static ColorBGRA<T> Black => new(NumericConversion.GetMinimumValueSafe<T>(), NumericConversion.GetMinimumValueSafe<T>(), NumericConversion.GetMinimumValueSafe<T>(), NumericConversion.GetMaximumValueSafe<T>());
|
||||
public static ColorBGRA<T> White => new(NumericConversion.GetMaximumValueSafe<T>(), NumericConversion.GetMaximumValueSafe<T>(), NumericConversion.GetMaximumValueSafe<T>(), NumericConversion.GetMaximumValueSafe<T>());
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{{ R: {R}, G: {G}, B: {B}, A: {A} }}";
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public partial struct ColorBGRA32 : IColor<byte>
|
||||
{
|
||||
public byte B { get; set; }
|
||||
public byte G { get; set; }
|
||||
public byte R { get; set; }
|
||||
public byte A { get; set; }
|
||||
|
||||
public readonly void GetChannels(out byte r, out byte g, out byte b, out byte a)
|
||||
{
|
||||
DefaultColorMethods.GetChannels(this, out r, out g, out b, out a);
|
||||
}
|
||||
|
||||
public void SetChannels(byte r, byte g, byte b, byte a)
|
||||
{
|
||||
DefaultColorMethods.SetChannels(ref this, r, g, b, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public partial struct ColorBGRA32 : IColor<byte>
|
||||
{
|
||||
static bool IColor.HasRedChannel => true;
|
||||
static bool IColor.HasGreenChannel => true;
|
||||
static bool IColor.HasBlueChannel => true;
|
||||
static bool IColor.HasAlphaChannel => true;
|
||||
static bool IColor.ChannelsAreFullyUtilized => true;
|
||||
static Type IColor.ChannelType => typeof(byte);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{{ R: {R}, G: {G}, B: {B}, A: {A} }}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,7 @@
|
||||
<IsAotCompatible>true</IsAotCompatible>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
|
||||
<Version>2.4.0</Version>
|
||||
<AssemblyVersion>$(Version)</AssemblyVersion>
|
||||
<VersionPrefix>2.5.0</VersionPrefix>
|
||||
<Copyright>Copyright © ds5678</Copyright>
|
||||
<Authors>ds5678</Authors>
|
||||
<Company>AssetRipper</Company>
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.32112.339
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3AAF94E5-9A19-461C-923F-BBC603C630BB}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
.gitignore = .gitignore
|
||||
Directory.Build.props = Directory.Build.props
|
||||
LICENSE = LICENSE
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{226FED9B-5CD8-4FD0-8E77-660F542D7508}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.github\workflows\build.yml = .github\workflows\build.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Licenses", "Licenses", "{0BFF6817-43C8-43EE-8EE8-1A03B7ECEA1A}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Licenses\bcdec.md = Licenses\bcdec.md
|
||||
Licenses\uTinyRipper.md = Licenses\uTinyRipper.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.TextureDecoder.Tests", "AssetRipper.TextureDecoder.Tests\AssetRipper.TextureDecoder.Tests.csproj", "{30E8E8F4-2CE4-4435-A49F-C5AF91D58FFE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.TextureDecoder", "AssetRipper.TextureDecoder\AssetRipper.TextureDecoder.csproj", "{E5A6E093-436C-4455-A597-3E357D99C4D9}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.TextureDecoder.TestGenerator", "AssetRipper.TextureDecoder.TestGenerator\AssetRipper.TextureDecoder.TestGenerator.csproj", "{0074908C-35A8-4C71-8F74-A83A4095ACEA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.TextureDecoder.ConsoleApp", "AssetRipper.TextureDecoder.ConsoleApp\AssetRipper.TextureDecoder.ConsoleApp.csproj", "{FFC8EEF8-8BF1-4B65-ADDA-A949EDDF4CB4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.TextureDecoder.Benchmarks", "AssetRipper.TextureDecoder.Benchmarks\AssetRipper.TextureDecoder.Benchmarks.csproj", "{F85804F4-4864-412E-BDC6-8B6E2B5646A7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.TextureDecoder.ColorGenerator", "AssetRipper.TextureDecoder.ColorGenerator\AssetRipper.TextureDecoder.ColorGenerator.csproj", "{E9ED1120-1CEA-433E-9BFF-C4B20A34CC7B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegerConversion.ConstantEstimation", "IntegerConversion.ConstantEstimation\IntegerConversion.ConstantEstimation.csproj", "{9897C52D-2F38-405A-AB85-B06383FDF6E0}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.TextureDecoder.SourceGeneration.Common", "AssetRipper.TextureDecoder.SourceGeneration.Common\AssetRipper.TextureDecoder.SourceGeneration.Common.csproj", "{336CF443-373C-41B3-8E7C-881672E9875E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.TextureDecoder.Paths", "AssetRipper.TextureDecoder.Paths\AssetRipper.TextureDecoder.Paths.csproj", "{48731523-A672-4D39-A49E-2C4C253B4491}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{30E8E8F4-2CE4-4435-A49F-C5AF91D58FFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{30E8E8F4-2CE4-4435-A49F-C5AF91D58FFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{30E8E8F4-2CE4-4435-A49F-C5AF91D58FFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{30E8E8F4-2CE4-4435-A49F-C5AF91D58FFE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E5A6E093-436C-4455-A597-3E357D99C4D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E5A6E093-436C-4455-A597-3E357D99C4D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E5A6E093-436C-4455-A597-3E357D99C4D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E5A6E093-436C-4455-A597-3E357D99C4D9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0074908C-35A8-4C71-8F74-A83A4095ACEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0074908C-35A8-4C71-8F74-A83A4095ACEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0074908C-35A8-4C71-8F74-A83A4095ACEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0074908C-35A8-4C71-8F74-A83A4095ACEA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FFC8EEF8-8BF1-4B65-ADDA-A949EDDF4CB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FFC8EEF8-8BF1-4B65-ADDA-A949EDDF4CB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FFC8EEF8-8BF1-4B65-ADDA-A949EDDF4CB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FFC8EEF8-8BF1-4B65-ADDA-A949EDDF4CB4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F85804F4-4864-412E-BDC6-8B6E2B5646A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F85804F4-4864-412E-BDC6-8B6E2B5646A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F85804F4-4864-412E-BDC6-8B6E2B5646A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F85804F4-4864-412E-BDC6-8B6E2B5646A7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E9ED1120-1CEA-433E-9BFF-C4B20A34CC7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E9ED1120-1CEA-433E-9BFF-C4B20A34CC7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E9ED1120-1CEA-433E-9BFF-C4B20A34CC7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E9ED1120-1CEA-433E-9BFF-C4B20A34CC7B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9897C52D-2F38-405A-AB85-B06383FDF6E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9897C52D-2F38-405A-AB85-B06383FDF6E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9897C52D-2F38-405A-AB85-B06383FDF6E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9897C52D-2F38-405A-AB85-B06383FDF6E0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{336CF443-373C-41B3-8E7C-881672E9875E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{336CF443-373C-41B3-8E7C-881672E9875E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{336CF443-373C-41B3-8E7C-881672E9875E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{336CF443-373C-41B3-8E7C-881672E9875E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{48731523-A672-4D39-A49E-2C4C253B4491}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{48731523-A672-4D39-A49E-2C4C253B4491}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{48731523-A672-4D39-A49E-2C4C253B4491}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48731523-A672-4D39-A49E-2C4C253B4491}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{226FED9B-5CD8-4FD0-8E77-660F542D7508} = {3AAF94E5-9A19-461C-923F-BBC603C630BB}
|
||||
{0BFF6817-43C8-43EE-8EE8-1A03B7ECEA1A} = {3AAF94E5-9A19-461C-923F-BBC603C630BB}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D4E786DF-F6DD-407C-B23E-854CF00B7801}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,25 @@
|
||||
<Solution>
|
||||
<Folder Name="/Solution Items/">
|
||||
<File Path=".editorconfig" />
|
||||
<File Path=".gitignore" />
|
||||
<File Path="Directory.Build.props" />
|
||||
<File Path="LICENSE" />
|
||||
<File Path="README.md" />
|
||||
</Folder>
|
||||
<Folder Name="/Solution Items/Licenses/">
|
||||
<File Path="Licenses/bcdec.md" />
|
||||
<File Path="Licenses/uTinyRipper.md" />
|
||||
</Folder>
|
||||
<Folder Name="/Solution Items/Workflows/">
|
||||
<File Path=".github/workflows/build.yml" />
|
||||
</Folder>
|
||||
<Project Path="AssetRipper.TextureDecoder.Benchmarks/AssetRipper.TextureDecoder.Benchmarks.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.ColorGenerator/AssetRipper.TextureDecoder.ColorGenerator.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.ConsoleApp/AssetRipper.TextureDecoder.ConsoleApp.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.Paths/AssetRipper.TextureDecoder.Paths.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.SourceGeneration.Common/AssetRipper.TextureDecoder.SourceGeneration.Common.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.TestGenerator/AssetRipper.TextureDecoder.TestGenerator.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.Tests/AssetRipper.TextureDecoder.Tests.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder/AssetRipper.TextureDecoder.csproj" />
|
||||
<Project Path="IntegerConversion.ConstantEstimation/IntegerConversion.ConstantEstimation.csproj" />
|
||||
</Solution>
|
||||
Reference in new issue
Block a user