mirror of
https://github.com/AssetRipper/AssetRipper.TextureDecoder.git
synced 2026-11-13 12:41:27 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
958b831205 | ||
|
|
2085dbcce4 | ||
|
|
d6ad4d5a6f | ||
|
|
1a5ca1405e | ||
|
|
d5da591f92 | ||
|
|
dd129401c7 | ||
|
|
6855b6b287 | ||
|
|
0274cb1a05 | ||
|
|
e3e7779739 | ||
|
|
40326e20bc | ||
|
|
fa94774143 | ||
|
|
58b113e1e0 | ||
|
|
862995196f | ||
|
|
691796b919 | ||
|
|
a6f54dd9b1 | ||
|
|
fe93d46a6c | ||
|
|
7c6ac4ba0e | ||
|
|
977800b5bb | ||
|
|
f9c8dd980f | ||
|
|
aea23c3be6 | ||
|
|
6b65475bc1 | ||
|
|
4835e38ec6 | ||
|
|
874bef99eb | ||
|
|
6908984ff2 | ||
|
|
f012b3a4d9 | ||
|
|
541176ad79 | ||
|
|
a44a788060 | ||
|
|
5c937aca17 | ||
|
|
04b086c372 | ||
|
|
99b5d670f3 | ||
|
|
53beeff97e | ||
|
|
c566ecc668 | ||
|
|
3d3746e2d7 | ||
|
|
cd37722a53 | ||
|
|
7cea861443 | ||
|
|
fb48fa3b94 | ||
|
|
a6bc637d47 | ||
|
|
ba40e2c7d7 | ||
|
|
e2fba56e81 | ||
|
|
92d1909562 | ||
|
|
bb346aabbc | ||
|
|
18abd1731b | ||
|
|
b4ad9bcb39 | ||
|
|
e4c873b3b0 | ||
|
|
9c89b6fac5 | ||
|
|
ce581c0ea6 | ||
|
|
b992959c24 | ||
|
|
07c653873b | ||
|
|
03373afddb | ||
|
|
35ed50dc26 | ||
|
|
a5cfc5cbf7 | ||
|
|
dc1ecc5d46 | ||
|
|
89b76dafd3 | ||
|
|
56ba562fd5 | ||
|
|
1b2208b38a | ||
|
|
28e3a22265 | ||
|
|
5705e12af0 | ||
|
|
3e7eae579e | ||
|
|
7fb7530a37 | ||
|
|
b1dfd0b6d8 | ||
|
|
9259884731 | ||
|
|
4e1251649b | ||
|
|
26fcfb695e | ||
|
|
1c156c4cd3 | ||
|
|
c019bc5a04 | ||
|
|
099daf3044 | ||
|
|
5de28c63c3 | ||
|
|
f4d37ff16c |
No files matched your search
@@ -1,63 +0,0 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
||||
@@ -14,9 +14,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v3.0.1
|
||||
uses: actions/setup-dotnet@v3.2.0
|
||||
with:
|
||||
dotnet-version: 6.0.x
|
||||
dotnet-version: 7.0.x
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
- name: Build
|
||||
|
||||
+12
-12
@@ -1,18 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AssetRipper.TextureDecoder\AssetRipper.TextureDecoder.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AssetRipper.TextureDecoder\AssetRipper.TextureDecoder.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,255 @@
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.ColorGenerator;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
private const string AttributeNamespace = "AssetRipper.TextureDecoder.Attributes";
|
||||
private const string OutputNamespace = "AssetRipper.TextureDecoder.Rgb.Formats";
|
||||
private const string OutputFolder = "../../../../AssetRipper.TextureDecoder/Rgb/Formats/";
|
||||
|
||||
private static readonly Dictionary<Type, string> MinimumValues = new()
|
||||
{
|
||||
{ typeof(byte), "byte.MinValue" },
|
||||
{ typeof(sbyte), "sbyte.MinValue" },
|
||||
{ typeof(short), "short.MinValue" },
|
||||
{ typeof(ushort), "ushort.MinValue" },
|
||||
{ typeof(Half), "default" },
|
||||
{ typeof(float), "0f" },
|
||||
{ typeof(double), "0d" },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<Type, string> MaximumValues = new()
|
||||
{
|
||||
{ typeof(byte), "byte.MaxValue" },
|
||||
{ typeof(sbyte), "sbyte.MaxValue" },
|
||||
{ typeof(short), "short.MaxValue" },
|
||||
{ typeof(ushort), "ushort.MaxValue" },
|
||||
{ typeof(Half), "HalfConstants.One" },
|
||||
{ typeof(float), "1f" },
|
||||
{ typeof(double), "1d" },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<Type, string> TypeNames = new()
|
||||
{
|
||||
{ typeof(byte), "byte" },
|
||||
{ typeof(sbyte), "sbyte" },
|
||||
{ typeof(short), "short" },
|
||||
{ typeof(ushort), "ushort" },
|
||||
{ typeof(Half), "Half" },
|
||||
{ typeof(float), "float" },
|
||||
{ typeof(double), "double" },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Name, Type, Red, Blue, Green, Alpha
|
||||
/// </summary>
|
||||
private static readonly List<(string, Type, bool, bool, bool, bool)> Colors = new()
|
||||
{
|
||||
( "ColorA8", typeof(byte), false, false, false, true ),
|
||||
|
||||
( "ColorR8", typeof(byte), true, false, false, false ),
|
||||
( "ColorRG16", typeof(byte), true, true, false, false ),
|
||||
( "ColorRGB24", typeof(byte), true, true, true, false ),
|
||||
( "ColorRGBA32", typeof(byte), true, true, true, true ),
|
||||
|
||||
( "ColorR8Signed", typeof(sbyte), true, false, false, false ),
|
||||
( "ColorRG16Signed", typeof(sbyte), true, true, false, false ),
|
||||
( "ColorRGB24Signed", typeof(sbyte), true, true, true, false ),
|
||||
( "ColorRGBA32Signed", typeof(sbyte), true, true, true, true ),
|
||||
|
||||
( "ColorR16", typeof(ushort), true, false, false, false ),
|
||||
( "ColorRG32", typeof(ushort), true, true, false, false ),
|
||||
( "ColorRGB48", typeof(ushort), true, true, true, false ),
|
||||
( "ColorRGBA64", typeof(ushort), true, true, true, true ),
|
||||
|
||||
( "ColorR16Signed", typeof(short), true, false, false, false ),
|
||||
( "ColorRG32Signed", typeof(short), true, true, false, false ),
|
||||
( "ColorRGB48Signed", typeof(short), true, true, true, false ),
|
||||
( "ColorRGBA64Signed", typeof(short), true, true, true, true ),
|
||||
|
||||
( "ColorR16Half", typeof(Half), true, false, false, false ),
|
||||
( "ColorRG32Half", typeof(Half), true, true, false, false ),
|
||||
( "ColorRGB48Half", typeof(Half), true, true, true, false ),
|
||||
( "ColorRGBA64Half", typeof(Half), true, true, true, true ),
|
||||
|
||||
( "ColorR32Single", typeof(float), true, false, false, false ),
|
||||
( "ColorRG64Single", typeof(float), true, true, false, false ),
|
||||
( "ColorRGB96Single", typeof(float), true, true, true, false ),
|
||||
( "ColorRGBA128Single", typeof(float), true, true, true, true ),
|
||||
|
||||
( "ColorR64Double", typeof(double), true, false, false, false ),
|
||||
( "ColorRG128Double", typeof(double), true, true, false, false ),
|
||||
( "ColorRGB192Double", typeof(double), true, true, true, false ),
|
||||
( "ColorRGBA256Double", typeof(double), true, true, true, true ),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Name, Type, Red, Blue, Green, Alpha, Fully Utilized
|
||||
/// </summary>
|
||||
private static readonly List<(string, Type, bool, bool, bool, bool, bool)> OtherColors = 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 ),
|
||||
( "ColorRGB32Half", typeof(Half), true, true, true, false, false ),
|
||||
};
|
||||
|
||||
static void Main()
|
||||
{
|
||||
foreach (var color in Colors)
|
||||
{
|
||||
WriteColor(color);
|
||||
}
|
||||
foreach (var otherColor in OtherColors)
|
||||
{
|
||||
WriteOtherColor(otherColor);
|
||||
}
|
||||
Console.WriteLine("Done!");
|
||||
}
|
||||
|
||||
private static void WriteColor((string, Type, bool, bool, bool, bool) details)
|
||||
{
|
||||
(string name, Type type, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha) = details;
|
||||
Console.WriteLine(name);
|
||||
using FileStream stream = File.Create($"{OutputFolder}{name}.g.cs");
|
||||
using StreamWriter streamWriter = new StreamWriter(stream);
|
||||
streamWriter.NewLine = "\n";
|
||||
using IndentedTextWriter writer = new IndentedTextWriter(streamWriter, "\t");
|
||||
writer.NewLine = "\n";
|
||||
WriteColor(writer, name, type, hasRed, hasGreen, hasBlue, hasAlpha);
|
||||
}
|
||||
|
||||
private static void WriteOtherColor((string, Type, bool, bool, bool, bool, bool) details)
|
||||
{
|
||||
(string name, Type type, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha, bool fullyUtilized) = details;
|
||||
Console.WriteLine(name);
|
||||
using FileStream stream = File.Create($"{OutputFolder}{name}.g.cs");
|
||||
using StreamWriter streamWriter = new StreamWriter(stream);
|
||||
streamWriter.NewLine = "\n";
|
||||
using IndentedTextWriter writer = new IndentedTextWriter(streamWriter, "\t");
|
||||
writer.NewLine = "\n";
|
||||
WriteOtherColor(writer, name, type, hasRed, hasGreen, hasBlue, hasAlpha, fullyUtilized);
|
||||
}
|
||||
|
||||
private static void WriteOtherColor(IndentedTextWriter writer, string name, Type type, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha, bool fullyUtilized)
|
||||
{
|
||||
string typeName = TypeNames[type];
|
||||
writer.WriteLine("//This code is source generated. Do not edit manually.");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"using {AttributeNamespace};");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"namespace {OutputNamespace}");
|
||||
writer.WriteLine('{');
|
||||
writer.Indent++;
|
||||
|
||||
writer.WriteLine($"[RgbaAttribute(RedChannel = {hasRed.ToLowerString()}, GreenChannel = {hasGreen.ToLowerString()}, BlueChannel = {hasBlue.ToLowerString()}, AlphaChannel = {hasAlpha.ToLowerString()}, FullyUtilizedChannels = {fullyUtilized.ToLowerString()})]");
|
||||
writer.WriteLine($"public partial struct {name} : IColor<{typeName}>");
|
||||
writer.WriteLine('{');
|
||||
writer.WriteLine('}');
|
||||
|
||||
writer.Indent--;
|
||||
writer.WriteLine('}');
|
||||
}
|
||||
|
||||
private static void WriteColor(IndentedTextWriter writer, string name, Type type, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha)
|
||||
{
|
||||
string typeName = TypeNames[type];
|
||||
writer.WriteLine("//This code is source generated. Do not edit manually.");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"using {AttributeNamespace};");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"namespace {OutputNamespace}");
|
||||
writer.WriteLine('{');
|
||||
writer.Indent++;
|
||||
|
||||
writer.WriteLine($"[RgbaAttribute(RedChannel = {hasRed.ToLowerString()}, GreenChannel = {hasGreen.ToLowerString()}, BlueChannel = {hasBlue.ToLowerString()}, AlphaChannel = {hasAlpha.ToLowerString()}, FullyUtilizedChannels = true)]");
|
||||
writer.WriteLine($"public partial struct {name} : IColor<{typeName}>");
|
||||
writer.WriteLine('{');
|
||||
writer.Indent++;
|
||||
|
||||
WriteProperty(writer, hasRed, typeName, 'R', MinimumValues[type]);
|
||||
writer.WriteLine();
|
||||
WriteProperty(writer, hasGreen, typeName, 'G', MinimumValues[type]);
|
||||
writer.WriteLine();
|
||||
WriteProperty(writer, hasBlue, typeName, 'B', MinimumValues[type]);
|
||||
writer.WriteLine();
|
||||
WriteProperty(writer, hasAlpha, typeName, 'A', MaximumValues[type]);
|
||||
writer.WriteLine();
|
||||
|
||||
WriteGetChannels(writer, typeName);
|
||||
writer.WriteLine();
|
||||
WriteSetChannels(writer, type, hasRed, hasGreen, hasBlue, hasAlpha);
|
||||
|
||||
writer.Indent--;
|
||||
writer.WriteLine('}');
|
||||
|
||||
writer.Indent--;
|
||||
writer.WriteLine('}');
|
||||
}
|
||||
|
||||
private static void WriteGetChannels(IndentedTextWriter writer, string typeName)
|
||||
{
|
||||
writer.WriteLine($"public void GetChannels(out {typeName} r, out {typeName} g, out {typeName} b, out {typeName} a)");
|
||||
writer.WriteLine('{');
|
||||
writer.Indent++;
|
||||
writer.WriteLine("r = R;");
|
||||
writer.WriteLine("g = G;");
|
||||
writer.WriteLine("b = B;");
|
||||
writer.WriteLine("a = A;");
|
||||
writer.Indent--;
|
||||
writer.WriteLine('}');
|
||||
}
|
||||
|
||||
private static void WriteSetChannels(IndentedTextWriter writer, Type type, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha)
|
||||
{
|
||||
string typeName = TypeNames[type];
|
||||
writer.WriteLine($"public void SetChannels({typeName} r, {typeName} g, {typeName} b, {typeName} a)");
|
||||
writer.WriteLine('{');
|
||||
writer.Indent++;
|
||||
if (hasRed)
|
||||
{
|
||||
writer.WriteLine("R = r;");
|
||||
}
|
||||
if (hasGreen)
|
||||
{
|
||||
writer.WriteLine("G = g;");
|
||||
}
|
||||
if (hasBlue)
|
||||
{
|
||||
writer.WriteLine("B = b;");
|
||||
}
|
||||
if (hasAlpha)
|
||||
{
|
||||
writer.WriteLine("A = a;");
|
||||
}
|
||||
writer.Indent--;
|
||||
writer.WriteLine('}');
|
||||
}
|
||||
|
||||
private static void WriteProperty(IndentedTextWriter writer, bool hasColor, string typeName, char channel, string defaultValue)
|
||||
{
|
||||
if (hasColor)
|
||||
{
|
||||
writer.WriteLine($"public {typeName} {channel} {{ get; set; }}");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine($"public {typeName} {channel} ");
|
||||
writer.WriteLine('{');
|
||||
writer.Indent++;
|
||||
writer.WriteLine($"get => {defaultValue};");
|
||||
writer.WriteLine("set { }");
|
||||
writer.Indent--;
|
||||
writer.WriteLine('}');
|
||||
}
|
||||
}
|
||||
|
||||
private static string ToLowerString(this bool value)
|
||||
{
|
||||
return value ? "true" : "false";
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
|
||||
@@ -43,6 +43,63 @@ public struct DirectBitmap<TColor, TColorArg>
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAsBmp(string path)
|
||||
{
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
ImageWriter writer = new();
|
||||
if (typeof(TColor) == typeof(ColorRGBA32))
|
||||
{
|
||||
writer.WriteBmp(Data, Width, Height, ColorComponents.RedGreenBlueAlpha, stream);
|
||||
}
|
||||
else if (typeof(TColor) == typeof(ColorRGB24))
|
||||
{
|
||||
writer.WriteBmp(Data, Width, Height, ColorComponents.RedGreenBlue, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
RgbConverter.Convert<TColor, TColorArg, ColorRGBA32, byte>(Bits, Width, Height, out byte[] output);
|
||||
writer.WriteBmp(output, Width, Height, ColorComponents.RedGreenBlueAlpha, stream);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAsHdr(string path)
|
||||
{
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
ImageWriter writer = new();
|
||||
if (typeof(TColor) == typeof(ColorRGBA32))
|
||||
{
|
||||
writer.WriteHdr(Data, Width, Height, ColorComponents.RedGreenBlueAlpha, stream);
|
||||
}
|
||||
else if (typeof(TColor) == typeof(ColorRGB24))
|
||||
{
|
||||
writer.WriteHdr(Data, Width, Height, ColorComponents.RedGreenBlue, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
RgbConverter.Convert<TColor, TColorArg, ColorRGBA32, byte>(Bits, Width, Height, out byte[] output);
|
||||
writer.WriteHdr(output, Width, Height, ColorComponents.RedGreenBlueAlpha, stream);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAsJpg(string path)
|
||||
{
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
ImageWriter writer = new();
|
||||
if (typeof(TColor) == typeof(ColorRGBA32))
|
||||
{
|
||||
writer.WriteJpg(Data, Width, Height, ColorComponents.RedGreenBlueAlpha, stream, default);
|
||||
}
|
||||
else if (typeof(TColor) == typeof(ColorRGB24))
|
||||
{
|
||||
writer.WriteJpg(Data, Width, Height, ColorComponents.RedGreenBlue, stream, default);
|
||||
}
|
||||
else
|
||||
{
|
||||
RgbConverter.Convert<TColor, TColorArg, ColorRGBA32, byte>(Bits, Width, Height, out byte[] output);
|
||||
writer.WriteJpg(output, Width, Height, ColorComponents.RedGreenBlueAlpha, stream, default);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAsPng(string path)
|
||||
{
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
@@ -62,6 +119,25 @@ public struct DirectBitmap<TColor, TColorArg>
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAsTga(string path)
|
||||
{
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
ImageWriter writer = new();
|
||||
if (typeof(TColor) == typeof(ColorRGBA32))
|
||||
{
|
||||
writer.WriteTga(Data, Width, Height, ColorComponents.RedGreenBlueAlpha, stream);
|
||||
}
|
||||
else if (typeof(TColor) == typeof(ColorRGB24))
|
||||
{
|
||||
writer.WriteTga(Data, Width, Height, ColorComponents.RedGreenBlue, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
RgbConverter.Convert<TColor, TColorArg, ColorRGBA32, byte>(Bits, Width, Height, out byte[] output);
|
||||
writer.WriteTga(output, Width, Height, ColorComponents.RedGreenBlueAlpha, stream);
|
||||
}
|
||||
}
|
||||
|
||||
public int Height { get; }
|
||||
public int Width { get; }
|
||||
public int ByteSize => CalculateByteSize(Width, Height);
|
||||
|
||||
@@ -10,65 +10,75 @@ using AssetRipper.TextureDecoder.Yuy2;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.ConsoleApp;
|
||||
|
||||
internal static class Program
|
||||
internal static partial class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Length < 4)
|
||||
{
|
||||
Console.WriteLine("Format: {path} {type} {width} {height} {args4} {args5}");
|
||||
Console.WriteLine("Format: {path} {inputType} {outputType} {width} {height} {args5} {args6}");
|
||||
return;
|
||||
}
|
||||
string path = args[0];
|
||||
string type = args[1].ToLowerInvariant();
|
||||
int width = int.Parse(args[2]);
|
||||
int height = int.Parse(args[3]);
|
||||
string args4 = args.GetArgument(4);
|
||||
string inputType = args[1].ToLowerInvariant();
|
||||
string outputType = args[2].ToLowerInvariant();
|
||||
int width = int.Parse(args[3]);
|
||||
int height = int.Parse(args[4]);
|
||||
string args5 = args.GetArgument(5);
|
||||
string args6 = args.GetArgument(6);
|
||||
byte[] data = File.ReadAllBytes(path);
|
||||
|
||||
DirectBitmap<ColorBGRA32, byte> bitmap = new DirectBitmap<ColorBGRA32, byte>(width, height);
|
||||
switch (type)
|
||||
switch (inputType)
|
||||
{
|
||||
case "astc":
|
||||
DecodeAstc(data, width, height, args4, args5, bitmap.Bits);
|
||||
DecodeAstc(data, width, height, args5, args6, bitmap.Bits);
|
||||
break;
|
||||
case "atc":
|
||||
DecodeAtc(data, width, height, args4, bitmap.Bits);
|
||||
DecodeAtc(data, width, height, args5, bitmap.Bits);
|
||||
break;
|
||||
case "bc":
|
||||
DecodeBc(data, width, height, args4, args5, bitmap.Bits);
|
||||
DecodeBc(data, width, height, args5, args6, bitmap.Bits);
|
||||
break;
|
||||
case "dxt":
|
||||
DecodeDxt(data, width, height, args4, bitmap.Bits);
|
||||
DecodeDxt(data, width, height, args5, bitmap.Bits);
|
||||
break;
|
||||
case "etc":
|
||||
DecodeEtc(data, width, height, args4, bitmap.Bits);
|
||||
DecodeEtc(data, width, height, args5, bitmap.Bits);
|
||||
break;
|
||||
case "pvrtc":
|
||||
DecodePvrtc(data, width, height, args4, bitmap.Bits);
|
||||
DecodePvrtc(data, width, height, args5, bitmap.Bits);
|
||||
break;
|
||||
case "rgb":
|
||||
DecodeRgb(data, width, height, args4, bitmap.Bits);
|
||||
DecodeRgb(data, width, height, args5, bitmap.Bits);
|
||||
break;
|
||||
case "yuy2":
|
||||
Yuy2Decoder.DecompressYUY2(data, width, height, bitmap.Bits);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(type);
|
||||
throw new NotSupportedException(inputType);
|
||||
}
|
||||
|
||||
string dirPath = Path.GetDirectoryName(path) ?? Environment.CurrentDirectory;
|
||||
string name = Path.GetFileNameWithoutExtension(path);
|
||||
string newPath = Path.Combine(dirPath, name + ".png");
|
||||
if (OperatingSystem.IsWindows())
|
||||
string name = Path.GetFileName(path);
|
||||
|
||||
switch (outputType)
|
||||
{
|
||||
bitmap.FlipY();
|
||||
bitmap.SaveAsPng(newPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException("Only supported on Windows");
|
||||
case "png":
|
||||
{
|
||||
string newPath = Path.Combine(dirPath, name + ".png");
|
||||
bitmap.FlipY();
|
||||
bitmap.SaveAsPng(newPath);
|
||||
}
|
||||
break;
|
||||
case "bgra":
|
||||
{
|
||||
string newPath = Path.Combine(dirPath, name + ".bgra");
|
||||
WriteAllBytes(newPath, bitmap.Bits);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(outputType);
|
||||
}
|
||||
|
||||
Console.WriteLine("Done!");
|
||||
@@ -81,8 +91,8 @@ internal static class Program
|
||||
|
||||
private static void DecodeAstc(ReadOnlySpan<byte> input, int width, int height, string blockXSizeString, string blockYSizeString, Span<byte> output)
|
||||
{
|
||||
Console.WriteLine("Arg at index 4 : blockXSize");
|
||||
Console.WriteLine("Arg at index 5 : blockYSize");
|
||||
Console.WriteLine("Arg at index 5 : blockXSize");
|
||||
Console.WriteLine("Arg at index 6 : blockYSize");
|
||||
int blockXSize = int.Parse(blockXSizeString);
|
||||
int blockYSize = int.Parse(blockYSizeString);
|
||||
AstcDecoder.DecodeASTC(input, width, height, blockXSize, blockYSize, output);
|
||||
@@ -90,7 +100,7 @@ internal static class Program
|
||||
|
||||
private static void DecodeAtc(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)
|
||||
{
|
||||
Console.WriteLine("Arg at index 4 : mode");
|
||||
Console.WriteLine("Arg at index 5 : mode");
|
||||
Console.WriteLine(" 0 - ATC RGB4");
|
||||
Console.WriteLine(" 1 - ATC RGBA8");
|
||||
int mode = int.Parse(modeString);
|
||||
@@ -110,7 +120,7 @@ internal static class Program
|
||||
|
||||
private static void DecodeBc(ReadOnlySpan<byte> input, int width, int height, string modeString, string isSignedString, Span<byte> output)
|
||||
{
|
||||
Console.WriteLine("Arg at index 4 : mode");
|
||||
Console.WriteLine("Arg at index 5 : mode");
|
||||
Console.WriteLine(" 1 - BC1");
|
||||
Console.WriteLine(" 2 - BC2");
|
||||
Console.WriteLine(" 3 - BC3");
|
||||
@@ -118,30 +128,30 @@ internal static class Program
|
||||
Console.WriteLine(" 5 - BC5");
|
||||
Console.WriteLine(" 6 - BC6H");
|
||||
Console.WriteLine(" 7 - BC7");
|
||||
Console.WriteLine("Arg at index 5 : isSigned (BC6H only)");
|
||||
Console.WriteLine("Arg at index 6 : isSigned (BC6H only)");
|
||||
int mode = int.Parse(modeString);
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
BcDecoder.DecompressBC1(input, width, height, output);
|
||||
Bc1.Decompress(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
BcDecoder.DecompressBC2(input, width, height, output);
|
||||
Bc2.Decompress(input, width, height, output);
|
||||
break;
|
||||
case 3:
|
||||
BcDecoder.DecompressBC3(input, width, height, output);
|
||||
Bc3.Decompress(input, width, height, output);
|
||||
break;
|
||||
case 4:
|
||||
BcDecoder.DecompressBC4(input, width, height, output);
|
||||
Bc4.Decompress(input, width, height, output);
|
||||
break;
|
||||
case 5:
|
||||
BcDecoder.DecompressBC5(input, width, height, output);
|
||||
Bc5.Decompress(input, width, height, output);
|
||||
break;
|
||||
case 6:
|
||||
BcDecoder.DecompressBC6H(input, width, height, bool.Parse(isSignedString), output);
|
||||
Bc6h.Decompress(input, width, height, bool.Parse(isSignedString), output);
|
||||
break;
|
||||
case 7:
|
||||
BcDecoder.DecompressBC7(input, width, height, output);
|
||||
Bc7.Decompress(input, width, height, output);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -151,7 +161,7 @@ internal static class Program
|
||||
|
||||
private static void DecodeDxt(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)
|
||||
{
|
||||
Console.WriteLine("Arg at index 4 : mode");
|
||||
Console.WriteLine("Arg at index 5 : mode");
|
||||
Console.WriteLine(" 0 - DXT1");
|
||||
Console.WriteLine(" 1 - DXT3");
|
||||
Console.WriteLine(" 2 - DXT5");
|
||||
@@ -175,7 +185,7 @@ internal static class Program
|
||||
|
||||
private static void DecodeEtc(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)
|
||||
{
|
||||
Console.WriteLine("Arg at index 4 : mode");
|
||||
Console.WriteLine("Arg at index 5 : mode");
|
||||
Console.WriteLine(" 0 - ETC");
|
||||
Console.WriteLine(" 1 - ETC2");
|
||||
Console.WriteLine(" 2 - ETC2a1");
|
||||
@@ -219,104 +229,15 @@ internal static class Program
|
||||
|
||||
private static void DecodePvrtc(ReadOnlySpan<byte> input, int width, int height, string do2bitModeString, Span<byte> output)
|
||||
{
|
||||
Console.WriteLine("Arg at index 4 : 2bitMode");
|
||||
Console.WriteLine("Arg at index 5 : 2bitMode");
|
||||
bool do2bit = bool.Parse(do2bitModeString);
|
||||
PvrtcDecoder.DecompressPVRTC(input, width, height, do2bit, output);
|
||||
}
|
||||
|
||||
private static void DecodeRgb(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)
|
||||
public static void WriteAllBytes(string path, ReadOnlySpan<byte> bytes)
|
||||
{
|
||||
Console.WriteLine("Arg at index 4 : mode");
|
||||
Console.WriteLine(" 0 - Alpha8");
|
||||
Console.WriteLine(" 1 - Argb4444");
|
||||
Console.WriteLine(" 2 - Rgb24");
|
||||
Console.WriteLine(" 3 - Rgba32");
|
||||
Console.WriteLine(" 4 - Argb32");
|
||||
Console.WriteLine(" 5 - Rbg16");
|
||||
Console.WriteLine(" 6 - R16");
|
||||
Console.WriteLine(" 7 - Rgba4444");
|
||||
Console.WriteLine(" 8 - Bgra32");
|
||||
Console.WriteLine(" 9 - Rg16");
|
||||
Console.WriteLine(" 10 - R8");
|
||||
Console.WriteLine(" 11 - RHalf");
|
||||
Console.WriteLine(" 12 - RGHalf");
|
||||
Console.WriteLine(" 13 - RGBAHalf");
|
||||
Console.WriteLine(" 14 - RFloat");
|
||||
Console.WriteLine(" 15 - RGFloat");
|
||||
Console.WriteLine(" 16 - RGBAFloat");
|
||||
Console.WriteLine(" 17 - RGB9e5Float");
|
||||
Console.WriteLine(" 18 - RG32");
|
||||
Console.WriteLine(" 19 - RGB48");
|
||||
Console.WriteLine(" 20 - RGBA64");
|
||||
int mode = int.Parse(modeString);
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
RgbConverter.A8ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 1:
|
||||
RgbConverter.ARGB16ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
RgbConverter.RGB24ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 3:
|
||||
RgbConverter.RGBA32ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 4:
|
||||
RgbConverter.ARGB32ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 5:
|
||||
RgbConverter.RGB16ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 6:
|
||||
RgbConverter.R16ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 7:
|
||||
RgbConverter.RGBA16ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 8:
|
||||
input.CopyTo(output);
|
||||
break;
|
||||
case 9:
|
||||
RgbConverter.RG16ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 10:
|
||||
RgbConverter.R8ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 11:
|
||||
RgbConverter.RHalfToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 12:
|
||||
RgbConverter.RGHalfToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 13:
|
||||
RgbConverter.RGBAHalfToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 14:
|
||||
RgbConverter.RFloatToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 15:
|
||||
RgbConverter.RGFloatToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 16:
|
||||
RgbConverter.RGBAFloatToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 17:
|
||||
RgbConverter.RGB9e5FloatToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 18:
|
||||
RgbConverter.RG32ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 19:
|
||||
RgbConverter.RGB48ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
case 20:
|
||||
RgbConverter.RGBA64ToBGRA32(input, width, height, output);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(mode.ToString());
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(path, nameof(path));
|
||||
using Microsoft.Win32.SafeHandles.SafeFileHandle sfh = File.OpenHandle(path, FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||
RandomAccess.Write(sfh, bytes, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.ConsoleApp;
|
||||
static partial class Program
|
||||
{
|
||||
private static void DecodeRgb(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)
|
||||
{
|
||||
Console.WriteLine("Arg at index 5 : mode");
|
||||
Console.WriteLine(" 0 - A8");
|
||||
Console.WriteLine(" 1 - ARGB16");
|
||||
Console.WriteLine(" 2 - ARGB32");
|
||||
Console.WriteLine(" 3 - BGRA32");
|
||||
Console.WriteLine(" 4 - R16");
|
||||
Console.WriteLine(" 5 - R16Half");
|
||||
Console.WriteLine(" 6 - R16Signed");
|
||||
Console.WriteLine(" 7 - R32Single");
|
||||
Console.WriteLine(" 8 - R64Double");
|
||||
Console.WriteLine(" 9 - R8");
|
||||
Console.WriteLine(" 10 - R8Signed");
|
||||
Console.WriteLine(" 11 - RG16");
|
||||
Console.WriteLine(" 12 - RG32Half");
|
||||
Console.WriteLine(" 13 - RG16Signed");
|
||||
Console.WriteLine(" 14 - RG32");
|
||||
Console.WriteLine(" 15 - RG32Signed");
|
||||
Console.WriteLine(" 16 - RG64Single");
|
||||
Console.WriteLine(" 17 - RG128Double");
|
||||
Console.WriteLine(" 18 - RGB16");
|
||||
Console.WriteLine(" 19 - RGB24");
|
||||
Console.WriteLine(" 20 - RGB24Signed");
|
||||
Console.WriteLine(" 21 - RGB32Half");
|
||||
Console.WriteLine(" 22 - RGB48");
|
||||
Console.WriteLine(" 23 - RGB48Half");
|
||||
Console.WriteLine(" 24 - RGB48Signed");
|
||||
Console.WriteLine(" 25 - RGB96Single");
|
||||
Console.WriteLine(" 26 - RGB192Double");
|
||||
Console.WriteLine(" 27 - RGB9e5");
|
||||
Console.WriteLine(" 28 - RGBA128Single");
|
||||
Console.WriteLine(" 29 - RGBA16");
|
||||
Console.WriteLine(" 30 - RGBA256Double");
|
||||
Console.WriteLine(" 31 - RGBA32");
|
||||
Console.WriteLine(" 32 - RGBA32Signed");
|
||||
Console.WriteLine(" 33 - RGBA64");
|
||||
Console.WriteLine(" 34 - RGBA64Half");
|
||||
Console.WriteLine(" 35 - RGBA64Signed");
|
||||
int mode = int.Parse(modeString);
|
||||
switch(mode)
|
||||
{
|
||||
case 0:
|
||||
RgbConverter.Convert<ColorA8, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 1:
|
||||
RgbConverter.Convert<ColorARGB16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
RgbConverter.Convert<ColorARGB32, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 3:
|
||||
RgbConverter.Convert<ColorBGRA32, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 4:
|
||||
RgbConverter.Convert<ColorR16, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 5:
|
||||
RgbConverter.Convert<ColorR16Half, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 6:
|
||||
RgbConverter.Convert<ColorR16Signed, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 7:
|
||||
RgbConverter.Convert<ColorR32Single, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 8:
|
||||
RgbConverter.Convert<ColorR64Double, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 9:
|
||||
RgbConverter.Convert<ColorR8, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 10:
|
||||
RgbConverter.Convert<ColorR8Signed, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 11:
|
||||
RgbConverter.Convert<ColorRG16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 12:
|
||||
RgbConverter.Convert<ColorRG32Half, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 13:
|
||||
RgbConverter.Convert<ColorRG16Signed, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 14:
|
||||
RgbConverter.Convert<ColorRG32, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 15:
|
||||
RgbConverter.Convert<ColorRG32Signed, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 16:
|
||||
RgbConverter.Convert<ColorRG64Single, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 17:
|
||||
RgbConverter.Convert<ColorRG128Double, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 18:
|
||||
RgbConverter.Convert<ColorRGB16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 19:
|
||||
RgbConverter.Convert<ColorRGB24, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 20:
|
||||
RgbConverter.Convert<ColorRGB24Signed, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 21:
|
||||
RgbConverter.Convert<ColorRGB32Half, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 22:
|
||||
RgbConverter.Convert<ColorRGB48, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 23:
|
||||
RgbConverter.Convert<ColorRGB48Half, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 24:
|
||||
RgbConverter.Convert<ColorRGB48Signed, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 25:
|
||||
RgbConverter.Convert<ColorRGB96Single, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 26:
|
||||
RgbConverter.Convert<ColorRGB192Double, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 27:
|
||||
RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 28:
|
||||
RgbConverter.Convert<ColorRGBA128Single, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 29:
|
||||
RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 30:
|
||||
RgbConverter.Convert<ColorRGBA256Double, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 31:
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 32:
|
||||
RgbConverter.Convert<ColorRGBA32Signed, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 33:
|
||||
RgbConverter.Convert<ColorRGBA64, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 34:
|
||||
RgbConverter.Convert<ColorRGBA64Half, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
case 35:
|
||||
RgbConverter.Convert<ColorRGBA64Signed, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(mode.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,16 +1,125 @@
|
||||
namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
{
|
||||
internal struct GenerationData
|
||||
{
|
||||
public Type ColorType;
|
||||
public Type ChannelType;
|
||||
public int ColorSize;
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using System.Reflection;
|
||||
|
||||
public GenerationData(Type colorType, Type channelType, int colorSize)
|
||||
namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
{
|
||||
internal readonly struct GenerationData
|
||||
{
|
||||
public Type ColorType { get; }
|
||||
public Type ChannelType { get; }
|
||||
public int ColorSize { get; }
|
||||
|
||||
public bool RedChannel { get; }
|
||||
public bool GreenChannel { get; }
|
||||
public bool BlueChannel { get; }
|
||||
public bool AlphaChannel { get; }
|
||||
public bool FullyUtilizedChannels { get; }
|
||||
|
||||
public bool IsFloatingPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return ChannelType == typeof(Half) || ChannelType == typeof(float) || ChannelType == typeof(double);
|
||||
}
|
||||
}
|
||||
|
||||
public int BitSizePerChannel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ChannelType == typeof(byte) || ChannelType == typeof(sbyte))
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
else if (ChannelType == typeof(ushort) || ChannelType == typeof(short) || ChannelType == typeof(Half))
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
else if (ChannelType == typeof(float))
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
else if (ChannelType == typeof(double))
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException(ChannelType.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ChannelTypeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return ChannelType.Name switch
|
||||
{
|
||||
"Byte" => "byte",
|
||||
"SByte" => "sbyte",
|
||||
"UInt16" => "ushort",
|
||||
"Int16" => "short",
|
||||
"Single" => "float",
|
||||
"Double" => "double",
|
||||
_ => ChannelType.Name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public GenerationData(Type colorType, int colorSize)
|
||||
{
|
||||
ColorType = colorType;
|
||||
ChannelType = channelType;
|
||||
ChannelType = ColorType.GetInterfaces().Single(t => t.Name == $"{nameof(IColor<byte>)}`1").GenericTypeArguments[0];
|
||||
ColorSize = colorSize;
|
||||
|
||||
RgbaAttribute attribute = colorType.GetCustomAttribute<RgbaAttribute>() ?? throw new NullReferenceException(colorType.Name);
|
||||
RedChannel = attribute.RedChannel;
|
||||
GreenChannel = attribute.GreenChannel;
|
||||
BlueChannel = attribute.BlueChannel;
|
||||
AlphaChannel = attribute.AlphaChannel;
|
||||
FullyUtilizedChannels = attribute.FullyUtilizedChannels;
|
||||
}
|
||||
|
||||
public bool Contains(GenerationData other)
|
||||
{
|
||||
if (!FullyUtilizedChannels)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsFloatingPoint && other.IsFloatingPoint)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsFloatingPoint && !other.IsFloatingPoint)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.RedChannel && !RedChannel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.GreenChannel && !GreenChannel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.BlueChannel && !BlueChannel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.AlphaChannel && !AlphaChannel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return BitSizePerChannel >= other.BitSizePerChannel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
internal static class IndentedTextWriterExtensions
|
||||
{
|
||||
internal static void WriteSourceGenerationDisclaimer(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine($"//This code is source generated. Do not edit manually.");
|
||||
textWriter.WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -1,267 +1,118 @@
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private const string OutputNamespace = "AssetRipper.TextureDecoder.Tests.Formats";
|
||||
private const string OutputFolder = "../../../../AssetRipper.TextureDecoder.Tests/Formats/";
|
||||
|
||||
private static readonly char[] channels = new char[] { 'R', 'G', 'B', 'A' };
|
||||
|
||||
private static readonly List<GenerationData> dataList = new()
|
||||
internal static readonly List<GenerationData> dataList = new()
|
||||
{
|
||||
new GenerationData(typeof(ColorA8), typeof(byte), 1),
|
||||
new GenerationData(typeof(ColorARGB16), typeof(byte), 2),
|
||||
new GenerationData(typeof(ColorARGB32), typeof(byte), 4),
|
||||
new GenerationData(typeof(ColorR16), typeof(ushort), 2),
|
||||
new GenerationData(typeof(ColorR8), typeof(byte), 1),
|
||||
new GenerationData(typeof(ColorRG16), typeof(byte), 2),
|
||||
new GenerationData(typeof(ColorRG32), typeof(ushort), 4),
|
||||
new GenerationData(typeof(ColorRGB16), typeof(byte), 2),
|
||||
new GenerationData(typeof(ColorRGB24), typeof(byte), 3),
|
||||
new GenerationData(typeof(ColorRGB48), typeof(ushort), 6),
|
||||
new GenerationData(typeof(ColorRGB9e5), typeof(double), 4),
|
||||
new GenerationData(typeof(ColorRGBA16), typeof(byte), 2),
|
||||
new GenerationData(typeof(ColorRGBA32), typeof(byte), 4),
|
||||
new GenerationData(typeof(ColorRGBA64), typeof(ushort), 8),
|
||||
new GenerationData(typeof(ColorRGBAHalf), typeof(Half), 8),
|
||||
new GenerationData(typeof(ColorRGBASingle), typeof(float), 16),
|
||||
new GenerationData(typeof(ColorRGBHalf), typeof(Half), 6),
|
||||
new GenerationData(typeof(ColorRGBSingle), typeof(float), 12),
|
||||
new GenerationData(typeof(ColorRGHalf), typeof(Half), 4),
|
||||
new GenerationData(typeof(ColorRGSingle), typeof(float), 8),
|
||||
new GenerationData(typeof(ColorRHalf), typeof(Half), 2),
|
||||
new GenerationData(typeof(ColorRSingle), typeof(float), 4),
|
||||
new GenerationData(typeof(ColorA8), 1),
|
||||
new GenerationData(typeof(ColorARGB16), 2),
|
||||
new GenerationData(typeof(ColorARGB32), 4),
|
||||
new GenerationData(typeof(ColorBGRA32), 4),
|
||||
new GenerationData(typeof(ColorR16), 2),
|
||||
new GenerationData(typeof(ColorR16Half), 2),
|
||||
new GenerationData(typeof(ColorR16Signed), 2),
|
||||
new GenerationData(typeof(ColorR32Single), 4),
|
||||
new GenerationData(typeof(ColorR64Double), 8),
|
||||
new GenerationData(typeof(ColorR8), 1),
|
||||
new GenerationData(typeof(ColorR8Signed), 1),
|
||||
new GenerationData(typeof(ColorRG16), 2),
|
||||
new GenerationData(typeof(ColorRG32Half), 4),
|
||||
new GenerationData(typeof(ColorRG16Signed), 2),
|
||||
new GenerationData(typeof(ColorRG32), 4),
|
||||
new GenerationData(typeof(ColorRG32Signed), 4),
|
||||
new GenerationData(typeof(ColorRG64Single), 8),
|
||||
new GenerationData(typeof(ColorRG128Double), 16),
|
||||
new GenerationData(typeof(ColorRGB16), 2),
|
||||
new GenerationData(typeof(ColorRGB24), 3),
|
||||
new GenerationData(typeof(ColorRGB24Signed), 3),
|
||||
new GenerationData(typeof(ColorRGB32Half), 4),
|
||||
new GenerationData(typeof(ColorRGB48), 6),
|
||||
new GenerationData(typeof(ColorRGB48Half), 6),
|
||||
new GenerationData(typeof(ColorRGB48Signed), 6),
|
||||
new GenerationData(typeof(ColorRGB96Single), 12),
|
||||
new GenerationData(typeof(ColorRGB192Double), 24),
|
||||
new GenerationData(typeof(ColorRGB9e5), 4),
|
||||
new GenerationData(typeof(ColorRGBA128Single), 16),
|
||||
new GenerationData(typeof(ColorRGBA16), 2),
|
||||
new GenerationData(typeof(ColorRGBA256Double), 32),
|
||||
new GenerationData(typeof(ColorRGBA32), 4),
|
||||
new GenerationData(typeof(ColorRGBA32Signed), 4),
|
||||
new GenerationData(typeof(ColorRGBA64), 8),
|
||||
new GenerationData(typeof(ColorRGBA64Half), 8),
|
||||
new GenerationData(typeof(ColorRGBA64Signed), 8),
|
||||
};
|
||||
|
||||
private static readonly Dictionary<Type, ColorRandomValues> randomValueDictionary = new()
|
||||
static void Main()
|
||||
{
|
||||
{ typeof(byte), new ColorRandomValues("0b11010101", "0b01110010", "0b10001111", "0b11000111", "0b01001110") },
|
||||
{ typeof(ushort), new ColorRandomValues("44000", "21354", "60080", "347", "33871") },
|
||||
{ typeof(Half), new ColorRandomValues("(Half)0.447f", "(Half)0.224f", "(Half)0.95f", "(Half)0.897f", "(Half)0.333f") },
|
||||
{ typeof(float), new ColorRandomValues("0.447f", "0.224f", "0.95f", "0.897f", "0.333f") },
|
||||
{ typeof(double), new ColorRandomValues("0.447", "0.224", "0.95", "0.897", "0.333") },
|
||||
};
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Directory.CreateDirectory(OutputFolder);
|
||||
|
||||
foreach (GenerationData data in dataList)
|
||||
{
|
||||
using MemoryStream memoryStream = new();
|
||||
using StreamWriter streamWriter = new StreamWriter(memoryStream);
|
||||
using IndentedTextWriter textWriter = new IndentedTextWriter(streamWriter, "\t");
|
||||
textWriter.NewLine = "\r\n";
|
||||
|
||||
textWriter.WriteSourceGenerationDisclaimer();
|
||||
textWriter.WriteNamespaceUsings(data);
|
||||
textWriter.WriteFileScopedNamespace();
|
||||
textWriter.WriteClassDefinitionOpen(data);
|
||||
textWriter.Indent += 1;
|
||||
|
||||
textWriter.WriteCorrectSizeTest(data);
|
||||
textWriter.WriteLine();
|
||||
textWriter.WritePropertySymmetryTests(data);
|
||||
textWriter.WriteIndependenceTests(data);
|
||||
textWriter.WriteGetMethodMatchesProperties();
|
||||
textWriter.WriteLine();
|
||||
textWriter.WriteMethodSymmetryTest();
|
||||
textWriter.WriteLine();
|
||||
textWriter.WriteMakeRandomColor(data);
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteClassDefinitionClose();
|
||||
|
||||
textWriter.Flush();
|
||||
streamWriter.Flush();
|
||||
|
||||
string outputFilePath = $"{OutputFolder}{data.ColorType.Name}Tests.g.cs";
|
||||
File.WriteAllBytes(outputFilePath, memoryStream.ToArray());
|
||||
Console.WriteLine(outputFilePath);
|
||||
}
|
||||
|
||||
TestClassGenerator.GenerateTestClasses();
|
||||
GenerateRgbConsoleMethod();
|
||||
Console.WriteLine("Done!");
|
||||
}
|
||||
|
||||
private static void WriteNamespaceUsings(this IndentedTextWriter textWriter, GenerationData data)
|
||||
private static void GenerateRgbConsoleMethod()
|
||||
{
|
||||
textWriter.WriteLine($"using {data.ColorType.Namespace};");
|
||||
textWriter.WriteLine($"using {typeof(System.Runtime.CompilerServices.Unsafe).Namespace};");
|
||||
textWriter.WriteLine();//An empty line after the usings
|
||||
}
|
||||
StringWriter streamWriter = new();
|
||||
IndentedTextWriter textWriter = new IndentedTextWriter(streamWriter, "\t");
|
||||
streamWriter.NewLine = "\n";
|
||||
textWriter.NewLine = "\n";
|
||||
|
||||
private static void WriteFileScopedNamespace(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine($"namespace {OutputNamespace};");
|
||||
textWriter.WriteLine();//An empty line after the namespace declaration
|
||||
}
|
||||
|
||||
private static void WriteSourceGenerationDisclaimer(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine($"//This code is source generated. Do not edit manually.");
|
||||
textWriter.WriteSourceGenerationDisclaimer();
|
||||
textWriter.WriteLine($"using {typeof(RgbConverter).Namespace};");
|
||||
textWriter.WriteLine($"using {typeof(ColorBGRA32).Namespace};");
|
||||
textWriter.WriteLine();
|
||||
}
|
||||
|
||||
private static void WriteClassDefinitionOpen(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
textWriter.WriteLine($"public partial class {data.ColorType.Name}Tests");
|
||||
textWriter.WriteLine("namespace AssetRipper.TextureDecoder.ConsoleApp;");
|
||||
textWriter.WriteLine("static partial class Program");
|
||||
textWriter.WriteLine("{");
|
||||
}
|
||||
textWriter.Indent++;
|
||||
|
||||
private static void WriteClassDefinitionClose(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteCorrectSizeTest(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine("public void CorrectSizeTest()");
|
||||
textWriter.WriteLine("private static void DecodeRgb(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
textWriter.WriteLine($"Assert.That(Unsafe.SizeOf<{data.ColorType.Name}>(), Is.EqualTo({data.ColorSize}));");
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
textWriter.Indent++;
|
||||
|
||||
private static void WriteMakeRandomColor(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
textWriter.WriteLine($"public static {data.ColorType.Name} MakeRandomColor()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
textWriter.WriteLine("return new()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
ColorRandomValues randomValues = randomValueDictionary[data.ChannelType];
|
||||
textWriter.WriteLine($"R = {randomValues.DefaultR},");
|
||||
textWriter.WriteLine($"G = {randomValues.DefaultG},");
|
||||
textWriter.WriteLine($"B = {randomValues.DefaultB},");
|
||||
textWriter.WriteLine($"A = {randomValues.DefaultA},");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("};");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WritePropertySymmetryTests(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
foreach(char channel in channels)
|
||||
textWriter.WriteLine("Console.WriteLine(\"Arg at index 5 : mode\");");
|
||||
for (int i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
textWriter.WritePropertySymmetryTest(data, channel);
|
||||
textWriter.WriteLine();
|
||||
textWriter.WriteLine($"Console.WriteLine(\" {i} - {dataList[i].ColorType.Name.Substring(5)}\");");
|
||||
}
|
||||
}
|
||||
|
||||
private static void WritePropertySymmetryTest(this IndentedTextWriter textWriter, GenerationData data, char channel)
|
||||
{
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine($"public void PropertyIsSymmetric_{channel}()");
|
||||
textWriter.WriteLine("int mode = int.Parse(modeString);");
|
||||
textWriter.WriteLine("switch(mode)");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
textWriter.WriteLine("var color = MakeRandomColor();");
|
||||
char variableName = char.ToLowerInvariant(channel);
|
||||
textWriter.WriteLine($"var {variableName} = color.{channel};");
|
||||
textWriter.WriteLine($"color.{channel} = {variableName};");
|
||||
textWriter.WriteLine($"Assert.That(color.{channel}, Is.EqualTo({variableName}));");
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
textWriter.Indent++;
|
||||
|
||||
private static void WriteIndependenceTests(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
foreach (char channel in channels)
|
||||
for (int i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
textWriter.WriteIndependenceTest(data, channel);
|
||||
textWriter.WriteLine();
|
||||
textWriter.WriteLine($"case {i}:");
|
||||
textWriter.Indent++;
|
||||
GenerationData data = dataList[i];
|
||||
textWriter.WriteLine($"RgbConverter.Convert<{data.ColorType.Name}, {data.ChannelTypeName}, ColorBGRA32, byte>(input, width, height, output);");
|
||||
textWriter.WriteLine("break;");
|
||||
textWriter.Indent--;
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteIndependenceTest(this IndentedTextWriter textWriter, GenerationData data, char channel)
|
||||
{
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine($"public void ChannelsAreIndependent_{channel}()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
textWriter.WriteLine("var color = MakeRandomColor();");
|
||||
foreach(char otherChannel in channels.Where(c => c != channel))
|
||||
{
|
||||
textWriter.WriteLine($"var {char.ToLowerInvariant(otherChannel)} = color.{otherChannel};");
|
||||
}
|
||||
textWriter.WriteLine($"color.{channel} = {randomValueDictionary[data.ChannelType].SetValue};");
|
||||
|
||||
textWriter.WriteLine("Assert.Multiple(() =>");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
foreach (char otherChannel in channels.Where(c => c != channel))
|
||||
{
|
||||
textWriter.WriteLine($"Assert.That(color.{otherChannel}, Is.EqualTo({char.ToLowerInvariant(otherChannel)}));");
|
||||
textWriter.WriteLine("default:");
|
||||
textWriter.Indent++;
|
||||
textWriter.WriteLine("throw new NotSupportedException(mode.ToString());");
|
||||
textWriter.Indent--;
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.Indent--;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteGetMethodMatchesProperties(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine($"public void GetMethodMatchesProperties()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
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("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
foreach (char channel in channels)
|
||||
{
|
||||
textWriter.WriteLine($"Assert.That(color.{channel}, Is.EqualTo({char.ToLowerInvariant(channel)}));");
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.Indent--;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteMethodSymmetryTest(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine($"public void MethodsAreSymmetric()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
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("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
foreach (char channel in channels)
|
||||
{
|
||||
textWriter.WriteLine($"Assert.That(color.{channel}, Is.EqualTo({char.ToLowerInvariant(channel)}));");
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.Indent--;
|
||||
textWriter.WriteLine("}");
|
||||
|
||||
textWriter.Flush();
|
||||
streamWriter.Flush();
|
||||
File.WriteAllText("../../../../AssetRipper.TextureDecoder.ConsoleApp/Program.g.cs", streamWriter.ToString());
|
||||
Console.WriteLine("Program");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.TestGenerator;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
internal static class TestClassGenerator
|
||||
{
|
||||
private const string OutputNamespace = "AssetRipper.TextureDecoder.Tests.Formats";
|
||||
private const string OutputFolder = "../../../../AssetRipper.TextureDecoder.Tests/Formats/";
|
||||
|
||||
private static readonly char[] channels = new char[] { 'R', 'G', 'B', 'A' };
|
||||
|
||||
private static readonly Dictionary<Type, ColorRandomValues> randomValueDictionary = new()
|
||||
{
|
||||
{ typeof(sbyte), new ColorRandomValues("-0b01010101", "0b01110010", "-0b00001111", "-0b01000111", "0b01001110") },
|
||||
{ typeof(byte), new ColorRandomValues("0b11010101", "0b01110010", "0b10001111", "0b11000111", "0b01001110") },
|
||||
{ typeof(short), new ColorRandomValues("-24000", "21354", "-80", "347", "31871") },
|
||||
{ typeof(ushort), new ColorRandomValues("44000", "21354", "60080", "347", "33871") },
|
||||
{ typeof(Half), new ColorRandomValues("(Half)0.447f", "(Half)0.224f", "(Half)0.95f", "(Half)0.897f", "(Half)0.333f") },
|
||||
{ typeof(float), new ColorRandomValues("0.447f", "0.224f", "0.95f", "0.897f", "0.333f") },
|
||||
{ typeof(double), new ColorRandomValues("0.447", "0.224", "0.95", "0.897", "0.333") },
|
||||
};
|
||||
|
||||
internal static void GenerateTestClasses()
|
||||
{
|
||||
Directory.CreateDirectory(OutputFolder);
|
||||
|
||||
foreach (GenerationData data in Program.dataList)
|
||||
{
|
||||
using StringWriter streamWriter = new();
|
||||
using IndentedTextWriter textWriter = new IndentedTextWriter(streamWriter, "\t");
|
||||
streamWriter.NewLine = "\n";
|
||||
textWriter.NewLine = "\n";
|
||||
textWriter.WriteSourceGenerationDisclaimer();
|
||||
textWriter.WriteNamespaceUsings(data);
|
||||
textWriter.WriteFileScopedNamespace();
|
||||
textWriter.WriteClassDefinitionOpen(data);
|
||||
textWriter.Indent++;
|
||||
textWriter.WriteCorrectSizeTest(data);
|
||||
textWriter.WriteLine();
|
||||
textWriter.WritePropertySymmetryTests(data);
|
||||
textWriter.WriteIndependenceTests(data);
|
||||
textWriter.WriteGetMethodMatchesProperties();
|
||||
textWriter.WriteLine();
|
||||
textWriter.WriteMethodSymmetryTest();
|
||||
textWriter.WriteLine();
|
||||
textWriter.WriteMakeRandomColor(data);
|
||||
|
||||
foreach (GenerationData otherData in Program.dataList)
|
||||
{
|
||||
if (otherData.Contains(data))
|
||||
{
|
||||
textWriter.WriteLine();
|
||||
textWriter.WriteLosslessConversionTest(data, otherData);
|
||||
}
|
||||
}
|
||||
|
||||
textWriter.Indent--;
|
||||
textWriter.WriteClassDefinitionClose();
|
||||
|
||||
textWriter.Flush();
|
||||
streamWriter.Flush();
|
||||
|
||||
string outputFilePath = $"{OutputFolder}{data.ColorType.Name}Tests.g.cs";
|
||||
File.WriteAllText(outputFilePath, streamWriter.ToString());
|
||||
Console.WriteLine(data.ColorType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteClassDefinitionClose(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteClassDefinitionOpen(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
textWriter.WriteLine($"public partial class {data.ColorType.Name}Tests");
|
||||
textWriter.WriteLine("{");
|
||||
}
|
||||
|
||||
private static void WriteCorrectSizeTest(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine("public void CorrectSizeTest()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
textWriter.WriteLine($"Assert.That(Unsafe.SizeOf<{data.ColorType.Name}>(), Is.EqualTo({data.ColorSize}));");
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteFileScopedNamespace(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine($"namespace {OutputNamespace};");
|
||||
textWriter.WriteLine();//An empty line after the namespace declaration
|
||||
}
|
||||
|
||||
private static void WriteGetMethodMatchesProperties(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine($"public void GetMethodMatchesProperties()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
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("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
foreach (char channel in channels)
|
||||
{
|
||||
textWriter.WriteLine($"Assert.That(color.{channel}, Is.EqualTo({char.ToLowerInvariant(channel)}));");
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteIndependenceTest(this IndentedTextWriter textWriter, GenerationData data, char channel)
|
||||
{
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine($"public void ChannelsAreIndependent_{channel}()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
textWriter.WriteLine("var color = MakeRandomColor();");
|
||||
foreach (char otherChannel in channels.Where(c => c != channel))
|
||||
{
|
||||
textWriter.WriteLine($"var {char.ToLowerInvariant(otherChannel)} = color.{otherChannel};");
|
||||
}
|
||||
textWriter.WriteLine($"color.{channel} = {randomValueDictionary[data.ChannelType].SetValue};");
|
||||
|
||||
textWriter.WriteLine("Assert.Multiple(() =>");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
foreach (char otherChannel in channels.Where(c => c != channel))
|
||||
{
|
||||
textWriter.WriteLine($"Assert.That(color.{otherChannel}, Is.EqualTo({char.ToLowerInvariant(otherChannel)}));");
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteIndependenceTests(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
foreach (char channel in channels)
|
||||
{
|
||||
textWriter.WriteIndependenceTest(data, channel);
|
||||
textWriter.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteLosslessConversionTest(this IndentedTextWriter textWriter, GenerationData currentData, GenerationData containingData)
|
||||
{
|
||||
string currentName = currentData.ColorType.Name;
|
||||
string containingName = containingData.ColorType.Name;
|
||||
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine($"public void ConversionTo{containingName}IsLossless()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
textWriter.WriteLine($"{currentName} original = MakeRandomColor();");
|
||||
textWriter.WriteLine($"{containingName} converted = original.{nameof(ColorExtensions.Convert)}<{currentName}, {currentData.ChannelTypeName}, {containingName}, {containingData.ChannelTypeName}>();");
|
||||
textWriter.WriteLine($"{currentName} convertedBack = converted.{nameof(ColorExtensions.Convert)}<{containingName}, {containingData.ChannelTypeName}, {currentName}, {currentData.ChannelTypeName}>();");
|
||||
textWriter.WriteLine("Assert.That(convertedBack, Is.EqualTo(original));");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteMakeRandomColor(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
textWriter.WriteLine($"public static {data.ColorType.Name} MakeRandomColor()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
textWriter.WriteLine("return new()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
ColorRandomValues randomValues = randomValueDictionary[data.ChannelType];
|
||||
textWriter.WriteLine($"R = {randomValues.DefaultR},");
|
||||
textWriter.WriteLine($"G = {randomValues.DefaultG},");
|
||||
textWriter.WriteLine($"B = {randomValues.DefaultB},");
|
||||
textWriter.WriteLine($"A = {randomValues.DefaultA},");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("};");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteMethodSymmetryTest(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine($"public void MethodsAreSymmetric()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
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("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
foreach (char channel in channels)
|
||||
{
|
||||
textWriter.WriteLine($"Assert.That(color.{channel}, Is.EqualTo({char.ToLowerInvariant(channel)}));");
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteNamespaceUsings(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
textWriter.WriteLine($"using {typeof(ColorExtensions).Namespace};");
|
||||
textWriter.WriteLine($"using {data.ColorType.Namespace};");
|
||||
textWriter.WriteLine($"using {typeof(System.Runtime.CompilerServices.Unsafe).Namespace};");
|
||||
textWriter.WriteLine();//An empty line after the usings
|
||||
}
|
||||
|
||||
private static void WritePropertySymmetryTest(this IndentedTextWriter textWriter, GenerationData data, char channel)
|
||||
{
|
||||
textWriter.WriteLine("[Test]");
|
||||
textWriter.WriteLine($"public void PropertyIsSymmetric_{channel}()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
textWriter.WriteLine("var color = MakeRandomColor();");
|
||||
char variableName = char.ToLowerInvariant(channel);
|
||||
textWriter.WriteLine($"var {variableName} = color.{channel};");
|
||||
textWriter.WriteLine($"color.{channel} = {variableName};");
|
||||
textWriter.WriteLine($"Assert.That(color.{channel}, Is.EqualTo({variableName}));");
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WritePropertySymmetryTests(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
foreach (char channel in channels)
|
||||
{
|
||||
textWriter.WritePropertySymmetryTest(data, channel);
|
||||
textWriter.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -25,7 +25,7 @@ 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 = BcDecoder.DecompressBC1(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
int bytesRead = Bc1.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT1(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
|
||||
@@ -40,7 +40,7 @@ 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 = BcDecoder.DecompressBC2(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
int bytesRead = Bc2.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT3(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
|
||||
@@ -55,7 +55,7 @@ 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 = BcDecoder.DecompressBC3(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
int bytesRead = Bc3.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT5(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
|
||||
@@ -67,7 +67,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
public void DecompressBC4Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.BcTestFilesFolder + "test.bc4");
|
||||
int bytesRead = BcDecoder.DecompressBC4(data, 512, 512, out _);
|
||||
int bytesRead = Bc4.Decompress(data, 512, 512, out _);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
public void DecompressBC5Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.BcTestFilesFolder + "test.bc5");
|
||||
int bytesRead = BcDecoder.DecompressBC5(data, 512, 512, out _);
|
||||
int bytesRead = Bc5.Decompress(data, 512, 512, out _);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
private static void AssertCorrectBC6HDecompression(string path, int width, int height, bool isSigned)
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(path);
|
||||
int bytesRead = BcDecoder.DecompressBC6H(data, width, height, isSigned, out byte[] decodedData);
|
||||
int bytesRead = Bc6h.Decompress(data, width, height, isSigned, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
AssertMinimalDeviation(decodedData, originalBgra32LogoData, MaxMeanDeviationBc6h, MaxStandardDeviationBc6h);
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
private static void AssertCorrectBC7Decompression(string path, int width, int height)
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(path);
|
||||
int bytesRead = BcDecoder.DecompressBC7(data, width, height, out byte[] decodedData);
|
||||
int bytesRead = Bc7.Decompress(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
AssertMinimalDeviation(decodedData, originalBgra32LogoData, MaxMeanDeviationBc7, MaxStandardDeviationBc7);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,67 @@ public partial class ColorA8Tests
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorA8IsLossless()
|
||||
{
|
||||
ColorA8 original = MakeRandomColor();
|
||||
ColorA8 converted = original.Convert<ColorA8, byte, ColorA8, byte>();
|
||||
ColorA8 convertedBack = converted.Convert<ColorA8, byte, ColorA8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorA8 original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorA8, byte, ColorARGB32, byte>();
|
||||
ColorA8 convertedBack = converted.Convert<ColorARGB32, byte, ColorA8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorA8 original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorA8, byte, ColorBGRA32, byte>();
|
||||
ColorA8 convertedBack = converted.Convert<ColorBGRA32, byte, ColorA8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorA8 original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorA8, byte, ColorRGBA32, byte>();
|
||||
ColorA8 convertedBack = converted.Convert<ColorRGBA32, byte, ColorA8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorA8 original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorA8, byte, ColorRGBA32Signed, sbyte>();
|
||||
ColorA8 convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorA8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorA8 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorA8, byte, ColorRGBA64, ushort>();
|
||||
ColorA8 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorA8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorA8 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorA8, byte, ColorRGBA64Signed, short>();
|
||||
ColorA8 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorA8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,58 @@ public partial class ColorARGB16Tests
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorARGB16 original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorARGB16, byte, ColorARGB32, byte>();
|
||||
ColorARGB16 convertedBack = converted.Convert<ColorARGB32, byte, ColorARGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorARGB16 original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorARGB16, byte, ColorBGRA32, byte>();
|
||||
ColorARGB16 convertedBack = converted.Convert<ColorBGRA32, byte, ColorARGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorARGB16 original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorARGB16, byte, ColorRGBA32, byte>();
|
||||
ColorARGB16 convertedBack = converted.Convert<ColorRGBA32, byte, ColorARGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorARGB16 original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorARGB16, byte, ColorRGBA32Signed, sbyte>();
|
||||
ColorARGB16 convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorARGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorARGB16 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorARGB16, byte, ColorRGBA64, ushort>();
|
||||
ColorARGB16 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorARGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorARGB16 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorARGB16, byte, ColorRGBA64Signed, short>();
|
||||
ColorARGB16 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorARGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,58 @@ public partial class ColorARGB32Tests
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorARGB32 original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorARGB32, byte, ColorARGB32, byte>();
|
||||
ColorARGB32 convertedBack = converted.Convert<ColorARGB32, byte, ColorARGB32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorARGB32 original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorARGB32, byte, ColorBGRA32, byte>();
|
||||
ColorARGB32 convertedBack = converted.Convert<ColorBGRA32, byte, ColorARGB32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorARGB32 original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorARGB32, byte, ColorRGBA32, byte>();
|
||||
ColorARGB32 convertedBack = converted.Convert<ColorRGBA32, byte, ColorARGB32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorARGB32 original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorARGB32, byte, ColorRGBA32Signed, sbyte>();
|
||||
ColorARGB32 convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorARGB32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorARGB32 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorARGB32, byte, ColorRGBA64, ushort>();
|
||||
ColorARGB32 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorARGB32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorARGB32 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorARGB32, byte, ColorRGBA64Signed, short>();
|
||||
ColorARGB32 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorARGB32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0b11010101,
|
||||
G = 0b01110010,
|
||||
B = 0b10001111,
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorBGRA32 original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorBGRA32, byte, ColorARGB32, byte>();
|
||||
ColorBGRA32 convertedBack = converted.Convert<ColorARGB32, byte, ColorBGRA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorBGRA32 original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorBGRA32, byte, ColorBGRA32, byte>();
|
||||
ColorBGRA32 convertedBack = converted.Convert<ColorBGRA32, byte, ColorBGRA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorBGRA32 original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorBGRA32, byte, ColorRGBA32, byte>();
|
||||
ColorBGRA32 convertedBack = converted.Convert<ColorRGBA32, byte, ColorBGRA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorBGRA32 original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorBGRA32, byte, ColorRGBA32Signed, sbyte>();
|
||||
ColorBGRA32 convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorBGRA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorBGRA32 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorBGRA32, byte, ColorRGBA64, ushort>();
|
||||
ColorBGRA32 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorBGRA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorBGRA32 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorBGRA32, byte, ColorRGBA64Signed, short>();
|
||||
ColorBGRA32 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorBGRA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorR16HalfTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorR16Half>(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[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 = (Half)0.333f;
|
||||
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 = (Half)0.333f;
|
||||
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 = (Half)0.333f;
|
||||
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 = (Half)0.333f;
|
||||
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 ColorR16Half MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = (Half)0.447f,
|
||||
G = (Half)0.224f,
|
||||
B = (Half)0.95f,
|
||||
A = (Half)0.897f,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR16HalfIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorR16Half converted = original.Convert<ColorR16Half, Half, ColorR16Half, Half>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorR16Half, Half, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR32SingleIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorR32Single converted = original.Convert<ColorR16Half, Half, ColorR32Single, float>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorR32Single, float, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR64DoubleIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorR64Double converted = original.Convert<ColorR16Half, Half, ColorR64Double, double>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorR64Double, double, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32HalfIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorRG32Half converted = original.Convert<ColorR16Half, Half, ColorRG32Half, Half>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorRG32Half, Half, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG64SingleIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorRG64Single converted = original.Convert<ColorR16Half, Half, ColorRG64Single, float>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorRG64Single, float, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG128DoubleIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorRG128Double converted = original.Convert<ColorR16Half, Half, ColorRG128Double, double>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorRG128Double, double, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48HalfIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorRGB48Half converted = original.Convert<ColorR16Half, Half, ColorRGB48Half, Half>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorRGB48Half, Half, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB96SingleIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorRGB96Single converted = original.Convert<ColorR16Half, Half, ColorRGB96Single, float>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorRGB96Single, float, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorR16Half, Half, ColorRGB192Double, double>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorRGB192Double, double, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA128SingleIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorRGBA128Single converted = original.Convert<ColorR16Half, Half, ColorRGBA128Single, float>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorRGBA128Single, float, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorR16Half, Half, ColorRGBA256Double, double>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorRGBA256Double, double, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64HalfIsLossless()
|
||||
{
|
||||
ColorR16Half original = MakeRandomColor();
|
||||
ColorRGBA64Half converted = original.Convert<ColorR16Half, Half, ColorRGBA64Half, Half>();
|
||||
ColorR16Half convertedBack = converted.Convert<ColorRGBA64Half, Half, ColorR16Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorR16SignedTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorR16Signed>(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[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 = 31871;
|
||||
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 = 31871;
|
||||
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 = 31871;
|
||||
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 = 31871;
|
||||
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 ColorR16Signed MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = -24000,
|
||||
G = 21354,
|
||||
B = -80,
|
||||
A = 347,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR16IsLossless()
|
||||
{
|
||||
ColorR16Signed original = MakeRandomColor();
|
||||
ColorR16 converted = original.Convert<ColorR16Signed, short, ColorR16, ushort>();
|
||||
ColorR16Signed convertedBack = converted.Convert<ColorR16, ushort, ColorR16Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR16SignedIsLossless()
|
||||
{
|
||||
ColorR16Signed original = MakeRandomColor();
|
||||
ColorR16Signed converted = original.Convert<ColorR16Signed, short, ColorR16Signed, short>();
|
||||
ColorR16Signed convertedBack = converted.Convert<ColorR16Signed, short, ColorR16Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32IsLossless()
|
||||
{
|
||||
ColorR16Signed original = MakeRandomColor();
|
||||
ColorRG32 converted = original.Convert<ColorR16Signed, short, ColorRG32, ushort>();
|
||||
ColorR16Signed convertedBack = converted.Convert<ColorRG32, ushort, ColorR16Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32SignedIsLossless()
|
||||
{
|
||||
ColorR16Signed original = MakeRandomColor();
|
||||
ColorRG32Signed converted = original.Convert<ColorR16Signed, short, ColorRG32Signed, short>();
|
||||
ColorR16Signed convertedBack = converted.Convert<ColorRG32Signed, short, ColorR16Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorR16Signed original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorR16Signed, short, ColorRGB48, ushort>();
|
||||
ColorR16Signed convertedBack = converted.Convert<ColorRGB48, ushort, ColorR16Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorR16Signed original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorR16Signed, short, ColorRGB48Signed, short>();
|
||||
ColorR16Signed convertedBack = converted.Convert<ColorRGB48Signed, short, ColorR16Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorR16Signed original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorR16Signed, short, ColorRGBA64, ushort>();
|
||||
ColorR16Signed convertedBack = converted.Convert<ColorRGBA64, ushort, ColorR16Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorR16Signed original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorR16Signed, short, ColorRGBA64Signed, short>();
|
||||
ColorR16Signed convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorR16Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,76 @@ public partial class ColorR16Tests
|
||||
A = 347,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR16IsLossless()
|
||||
{
|
||||
ColorR16 original = MakeRandomColor();
|
||||
ColorR16 converted = original.Convert<ColorR16, ushort, ColorR16, ushort>();
|
||||
ColorR16 convertedBack = converted.Convert<ColorR16, ushort, ColorR16, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR16SignedIsLossless()
|
||||
{
|
||||
ColorR16 original = MakeRandomColor();
|
||||
ColorR16Signed converted = original.Convert<ColorR16, ushort, ColorR16Signed, short>();
|
||||
ColorR16 convertedBack = converted.Convert<ColorR16Signed, short, ColorR16, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32IsLossless()
|
||||
{
|
||||
ColorR16 original = MakeRandomColor();
|
||||
ColorRG32 converted = original.Convert<ColorR16, ushort, ColorRG32, ushort>();
|
||||
ColorR16 convertedBack = converted.Convert<ColorRG32, ushort, ColorR16, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32SignedIsLossless()
|
||||
{
|
||||
ColorR16 original = MakeRandomColor();
|
||||
ColorRG32Signed converted = original.Convert<ColorR16, ushort, ColorRG32Signed, short>();
|
||||
ColorR16 convertedBack = converted.Convert<ColorRG32Signed, short, ColorR16, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorR16 original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorR16, ushort, ColorRGB48, ushort>();
|
||||
ColorR16 convertedBack = converted.Convert<ColorRGB48, ushort, ColorR16, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorR16 original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorR16, ushort, ColorRGB48Signed, short>();
|
||||
ColorR16 convertedBack = converted.Convert<ColorRGB48Signed, short, ColorR16, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorR16 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorR16, ushort, ColorRGBA64, ushort>();
|
||||
ColorR16 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorR16, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorR16 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorR16, ushort, ColorRGBA64Signed, short>();
|
||||
ColorR16 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorR16, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorR32SingleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorR32Single>(), 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 = 0.333f;
|
||||
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 = 0.333f;
|
||||
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 = 0.333f;
|
||||
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 = 0.333f;
|
||||
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 ColorR32Single MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0.447f,
|
||||
G = 0.224f,
|
||||
B = 0.95f,
|
||||
A = 0.897f,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR32SingleIsLossless()
|
||||
{
|
||||
ColorR32Single original = MakeRandomColor();
|
||||
ColorR32Single converted = original.Convert<ColorR32Single, float, ColorR32Single, float>();
|
||||
ColorR32Single convertedBack = converted.Convert<ColorR32Single, float, ColorR32Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR64DoubleIsLossless()
|
||||
{
|
||||
ColorR32Single original = MakeRandomColor();
|
||||
ColorR64Double converted = original.Convert<ColorR32Single, float, ColorR64Double, double>();
|
||||
ColorR32Single convertedBack = converted.Convert<ColorR64Double, double, ColorR32Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG64SingleIsLossless()
|
||||
{
|
||||
ColorR32Single original = MakeRandomColor();
|
||||
ColorRG64Single converted = original.Convert<ColorR32Single, float, ColorRG64Single, float>();
|
||||
ColorR32Single convertedBack = converted.Convert<ColorRG64Single, float, ColorR32Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG128DoubleIsLossless()
|
||||
{
|
||||
ColorR32Single original = MakeRandomColor();
|
||||
ColorRG128Double converted = original.Convert<ColorR32Single, float, ColorRG128Double, double>();
|
||||
ColorR32Single convertedBack = converted.Convert<ColorRG128Double, double, ColorR32Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB96SingleIsLossless()
|
||||
{
|
||||
ColorR32Single original = MakeRandomColor();
|
||||
ColorRGB96Single converted = original.Convert<ColorR32Single, float, ColorRGB96Single, float>();
|
||||
ColorR32Single convertedBack = converted.Convert<ColorRGB96Single, float, ColorR32Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorR32Single original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorR32Single, float, ColorRGB192Double, double>();
|
||||
ColorR32Single convertedBack = converted.Convert<ColorRGB192Double, double, ColorR32Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA128SingleIsLossless()
|
||||
{
|
||||
ColorR32Single original = MakeRandomColor();
|
||||
ColorRGBA128Single converted = original.Convert<ColorR32Single, float, ColorRGBA128Single, float>();
|
||||
ColorR32Single convertedBack = converted.Convert<ColorRGBA128Single, float, ColorR32Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorR32Single original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorR32Single, float, ColorRGBA256Double, double>();
|
||||
ColorR32Single convertedBack = converted.Convert<ColorRGBA256Double, double, ColorR32Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorR64DoubleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorR64Double>(), Is.EqualTo(8));
|
||||
}
|
||||
|
||||
[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 = 0.333;
|
||||
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 = 0.333;
|
||||
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 = 0.333;
|
||||
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 = 0.333;
|
||||
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 ColorR64Double MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0.447,
|
||||
G = 0.224,
|
||||
B = 0.95,
|
||||
A = 0.897,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR64DoubleIsLossless()
|
||||
{
|
||||
ColorR64Double original = MakeRandomColor();
|
||||
ColorR64Double converted = original.Convert<ColorR64Double, double, ColorR64Double, double>();
|
||||
ColorR64Double convertedBack = converted.Convert<ColorR64Double, double, ColorR64Double, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG128DoubleIsLossless()
|
||||
{
|
||||
ColorR64Double original = MakeRandomColor();
|
||||
ColorRG128Double converted = original.Convert<ColorR64Double, double, ColorRG128Double, double>();
|
||||
ColorR64Double convertedBack = converted.Convert<ColorRG128Double, double, ColorR64Double, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorR64Double original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorR64Double, double, ColorRGB192Double, double>();
|
||||
ColorR64Double convertedBack = converted.Convert<ColorRGB192Double, double, ColorR64Double, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorR64Double original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorR64Double, double, ColorRGBA256Double, double>();
|
||||
ColorR64Double convertedBack = converted.Convert<ColorRGBA256Double, double, ColorR64Double, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorR8SignedTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorR8Signed>(), Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 ColorR8Signed MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = -0b01010101,
|
||||
G = 0b01110010,
|
||||
B = -0b00001111,
|
||||
A = -0b01000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorR8Signed, sbyte, ColorARGB32, byte>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorARGB32, byte, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorR8Signed, sbyte, ColorBGRA32, byte>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorBGRA32, byte, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR16IsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorR16 converted = original.Convert<ColorR8Signed, sbyte, ColorR16, ushort>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorR16, ushort, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR16SignedIsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorR16Signed converted = original.Convert<ColorR8Signed, sbyte, ColorR16Signed, short>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorR16Signed, short, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR8IsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorR8 converted = original.Convert<ColorR8Signed, sbyte, ColorR8, byte>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorR8, byte, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR8SignedIsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorR8Signed converted = original.Convert<ColorR8Signed, sbyte, ColorR8Signed, sbyte>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorR8Signed, sbyte, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG16IsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRG16 converted = original.Convert<ColorR8Signed, sbyte, ColorRG16, byte>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRG16, byte, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG16SignedIsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRG16Signed converted = original.Convert<ColorR8Signed, sbyte, ColorRG16Signed, sbyte>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRG16Signed, sbyte, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32IsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRG32 converted = original.Convert<ColorR8Signed, sbyte, ColorRG32, ushort>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRG32, ushort, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32SignedIsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRG32Signed converted = original.Convert<ColorR8Signed, sbyte, ColorRG32Signed, short>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRG32Signed, short, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24IsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRGB24 converted = original.Convert<ColorR8Signed, sbyte, ColorRGB24, byte>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRGB24, byte, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24SignedIsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRGB24Signed converted = original.Convert<ColorR8Signed, sbyte, ColorRGB24Signed, sbyte>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRGB24Signed, sbyte, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorR8Signed, sbyte, ColorRGB48, ushort>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRGB48, ushort, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorR8Signed, sbyte, ColorRGB48Signed, short>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRGB48Signed, short, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorR8Signed, sbyte, ColorRGBA32, byte>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRGBA32, byte, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorR8Signed, sbyte, ColorRGBA32Signed, sbyte>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorR8Signed, sbyte, ColorRGBA64, ushort>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRGBA64, ushort, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorR8Signed original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorR8Signed, sbyte, ColorRGBA64Signed, short>();
|
||||
ColorR8Signed convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorR8Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,166 @@ public partial class ColorR8Tests
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorR8, byte, ColorARGB32, byte>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorARGB32, byte, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorR8, byte, ColorBGRA32, byte>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorBGRA32, byte, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR16IsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorR16 converted = original.Convert<ColorR8, byte, ColorR16, ushort>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorR16, ushort, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR16SignedIsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorR16Signed converted = original.Convert<ColorR8, byte, ColorR16Signed, short>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorR16Signed, short, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR8IsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorR8 converted = original.Convert<ColorR8, byte, ColorR8, byte>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorR8, byte, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorR8SignedIsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorR8Signed converted = original.Convert<ColorR8, byte, ColorR8Signed, sbyte>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorR8Signed, sbyte, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG16IsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRG16 converted = original.Convert<ColorR8, byte, ColorRG16, byte>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRG16, byte, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG16SignedIsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRG16Signed converted = original.Convert<ColorR8, byte, ColorRG16Signed, sbyte>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRG16Signed, sbyte, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32IsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRG32 converted = original.Convert<ColorR8, byte, ColorRG32, ushort>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRG32, ushort, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32SignedIsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRG32Signed converted = original.Convert<ColorR8, byte, ColorRG32Signed, short>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRG32Signed, short, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24IsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRGB24 converted = original.Convert<ColorR8, byte, ColorRGB24, byte>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRGB24, byte, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24SignedIsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRGB24Signed converted = original.Convert<ColorR8, byte, ColorRGB24Signed, sbyte>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRGB24Signed, sbyte, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorR8, byte, ColorRGB48, ushort>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRGB48, ushort, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorR8, byte, ColorRGB48Signed, short>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRGB48Signed, short, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorR8, byte, ColorRGBA32, byte>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRGBA32, byte, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorR8, byte, ColorRGBA32Signed, sbyte>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorR8, byte, ColorRGBA64, ushort>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorR8 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorR8, byte, ColorRGBA64Signed, short>();
|
||||
ColorR8 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorR8, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
+39
-11
@@ -1,16 +1,17 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRGBHalfTests
|
||||
public partial class ColorRG128DoubleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBHalf>(), Is.EqualTo(6));
|
||||
Assert.That(Unsafe.SizeOf<ColorRG128Double>(), Is.EqualTo(16));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -56,7 +57,7 @@ public partial class ColorRGBHalfTests
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = (Half)0.333f;
|
||||
color.R = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
@@ -72,7 +73,7 @@ public partial class ColorRGBHalfTests
|
||||
var r = color.R;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = (Half)0.333f;
|
||||
color.G = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -88,7 +89,7 @@ public partial class ColorRGBHalfTests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = (Half)0.333f;
|
||||
color.B = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -104,7 +105,7 @@ public partial class ColorRGBHalfTests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = (Half)0.333f;
|
||||
color.A = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -142,14 +143,41 @@ public partial class ColorRGBHalfTests
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRGBHalf MakeRandomColor()
|
||||
public static ColorRG128Double MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = (Half)0.447f,
|
||||
G = (Half)0.224f,
|
||||
B = (Half)0.95f,
|
||||
A = (Half)0.897f,
|
||||
R = 0.447,
|
||||
G = 0.224,
|
||||
B = 0.95,
|
||||
A = 0.897,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG128DoubleIsLossless()
|
||||
{
|
||||
ColorRG128Double original = MakeRandomColor();
|
||||
ColorRG128Double converted = original.Convert<ColorRG128Double, double, ColorRG128Double, double>();
|
||||
ColorRG128Double convertedBack = converted.Convert<ColorRG128Double, double, ColorRG128Double, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorRG128Double original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorRG128Double, double, ColorRGB192Double, double>();
|
||||
ColorRG128Double convertedBack = converted.Convert<ColorRGB192Double, double, ColorRG128Double, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRG128Double original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRG128Double, double, ColorRGBA256Double, double>();
|
||||
ColorRG128Double convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRG128Double, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRG16SignedTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRG16Signed>(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 ColorRG16Signed MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = -0b01010101,
|
||||
G = 0b01110010,
|
||||
B = -0b00001111,
|
||||
A = -0b01000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorRG16Signed, sbyte, ColorARGB32, byte>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorARGB32, byte, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorRG16Signed, sbyte, ColorBGRA32, byte>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorBGRA32, byte, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG16IsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRG16 converted = original.Convert<ColorRG16Signed, sbyte, ColorRG16, byte>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRG16, byte, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG16SignedIsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRG16Signed converted = original.Convert<ColorRG16Signed, sbyte, ColorRG16Signed, sbyte>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRG16Signed, sbyte, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32IsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRG32 converted = original.Convert<ColorRG16Signed, sbyte, ColorRG32, ushort>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRG32, ushort, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32SignedIsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRG32Signed converted = original.Convert<ColorRG16Signed, sbyte, ColorRG32Signed, short>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRG32Signed, short, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24IsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRGB24 converted = original.Convert<ColorRG16Signed, sbyte, ColorRGB24, byte>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRGB24, byte, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24SignedIsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRGB24Signed converted = original.Convert<ColorRG16Signed, sbyte, ColorRGB24Signed, sbyte>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRGB24Signed, sbyte, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorRG16Signed, sbyte, ColorRGB48, ushort>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRGB48, ushort, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorRG16Signed, sbyte, ColorRGB48Signed, short>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRGB48Signed, short, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorRG16Signed, sbyte, ColorRGBA32, byte>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRGBA32, byte, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorRG16Signed, sbyte, ColorRGBA32Signed, sbyte>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRG16Signed, sbyte, ColorRGBA64, ushort>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRG16Signed original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRG16Signed, sbyte, ColorRGBA64Signed, short>();
|
||||
ColorRG16Signed convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRG16Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,130 @@ public partial class ColorRG16Tests
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorRG16, byte, ColorARGB32, byte>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorARGB32, byte, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorRG16, byte, ColorBGRA32, byte>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorBGRA32, byte, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG16IsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRG16 converted = original.Convert<ColorRG16, byte, ColorRG16, byte>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRG16, byte, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG16SignedIsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRG16Signed converted = original.Convert<ColorRG16, byte, ColorRG16Signed, sbyte>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRG16Signed, sbyte, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32IsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRG32 converted = original.Convert<ColorRG16, byte, ColorRG32, ushort>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRG32, ushort, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32SignedIsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRG32Signed converted = original.Convert<ColorRG16, byte, ColorRG32Signed, short>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRG32Signed, short, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24IsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRGB24 converted = original.Convert<ColorRG16, byte, ColorRGB24, byte>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRGB24, byte, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24SignedIsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRGB24Signed converted = original.Convert<ColorRG16, byte, ColorRGB24Signed, sbyte>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRGB24Signed, sbyte, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorRG16, byte, ColorRGB48, ushort>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRGB48, ushort, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorRG16, byte, ColorRGB48Signed, short>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRGB48Signed, short, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorRG16, byte, ColorRGBA32, byte>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRGBA32, byte, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorRG16, byte, ColorRGBA32Signed, sbyte>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRG16, byte, ColorRGBA64, ushort>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRG16 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRG16, byte, ColorRGBA64Signed, short>();
|
||||
ColorRG16 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRG16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRG32HalfTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRG32Half>(), 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 = (Half)0.333f;
|
||||
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 = (Half)0.333f;
|
||||
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 = (Half)0.333f;
|
||||
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 = (Half)0.333f;
|
||||
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 ColorRG32Half MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = (Half)0.447f,
|
||||
G = (Half)0.224f,
|
||||
B = (Half)0.95f,
|
||||
A = (Half)0.897f,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32HalfIsLossless()
|
||||
{
|
||||
ColorRG32Half original = MakeRandomColor();
|
||||
ColorRG32Half converted = original.Convert<ColorRG32Half, Half, ColorRG32Half, Half>();
|
||||
ColorRG32Half convertedBack = converted.Convert<ColorRG32Half, Half, ColorRG32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG64SingleIsLossless()
|
||||
{
|
||||
ColorRG32Half original = MakeRandomColor();
|
||||
ColorRG64Single converted = original.Convert<ColorRG32Half, Half, ColorRG64Single, float>();
|
||||
ColorRG32Half convertedBack = converted.Convert<ColorRG64Single, float, ColorRG32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG128DoubleIsLossless()
|
||||
{
|
||||
ColorRG32Half original = MakeRandomColor();
|
||||
ColorRG128Double converted = original.Convert<ColorRG32Half, Half, ColorRG128Double, double>();
|
||||
ColorRG32Half convertedBack = converted.Convert<ColorRG128Double, double, ColorRG32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48HalfIsLossless()
|
||||
{
|
||||
ColorRG32Half original = MakeRandomColor();
|
||||
ColorRGB48Half converted = original.Convert<ColorRG32Half, Half, ColorRGB48Half, Half>();
|
||||
ColorRG32Half convertedBack = converted.Convert<ColorRGB48Half, Half, ColorRG32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB96SingleIsLossless()
|
||||
{
|
||||
ColorRG32Half original = MakeRandomColor();
|
||||
ColorRGB96Single converted = original.Convert<ColorRG32Half, Half, ColorRGB96Single, float>();
|
||||
ColorRG32Half convertedBack = converted.Convert<ColorRGB96Single, float, ColorRG32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorRG32Half original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorRG32Half, Half, ColorRGB192Double, double>();
|
||||
ColorRG32Half convertedBack = converted.Convert<ColorRGB192Double, double, ColorRG32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA128SingleIsLossless()
|
||||
{
|
||||
ColorRG32Half original = MakeRandomColor();
|
||||
ColorRGBA128Single converted = original.Convert<ColorRG32Half, Half, ColorRGBA128Single, float>();
|
||||
ColorRG32Half convertedBack = converted.Convert<ColorRGBA128Single, float, ColorRG32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRG32Half original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRG32Half, Half, ColorRGBA256Double, double>();
|
||||
ColorRG32Half convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRG32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64HalfIsLossless()
|
||||
{
|
||||
ColorRG32Half original = MakeRandomColor();
|
||||
ColorRGBA64Half converted = original.Convert<ColorRG32Half, Half, ColorRGBA64Half, Half>();
|
||||
ColorRG32Half convertedBack = converted.Convert<ColorRGBA64Half, Half, ColorRG32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRG32SignedTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRG32Signed>(), 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 = 31871;
|
||||
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 = 31871;
|
||||
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 = 31871;
|
||||
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 = 31871;
|
||||
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 ColorRG32Signed MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = -24000,
|
||||
G = 21354,
|
||||
B = -80,
|
||||
A = 347,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32IsLossless()
|
||||
{
|
||||
ColorRG32Signed original = MakeRandomColor();
|
||||
ColorRG32 converted = original.Convert<ColorRG32Signed, short, ColorRG32, ushort>();
|
||||
ColorRG32Signed convertedBack = converted.Convert<ColorRG32, ushort, ColorRG32Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32SignedIsLossless()
|
||||
{
|
||||
ColorRG32Signed original = MakeRandomColor();
|
||||
ColorRG32Signed converted = original.Convert<ColorRG32Signed, short, ColorRG32Signed, short>();
|
||||
ColorRG32Signed convertedBack = converted.Convert<ColorRG32Signed, short, ColorRG32Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorRG32Signed original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorRG32Signed, short, ColorRGB48, ushort>();
|
||||
ColorRG32Signed convertedBack = converted.Convert<ColorRGB48, ushort, ColorRG32Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorRG32Signed original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorRG32Signed, short, ColorRGB48Signed, short>();
|
||||
ColorRG32Signed convertedBack = converted.Convert<ColorRGB48Signed, short, ColorRG32Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRG32Signed original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRG32Signed, short, ColorRGBA64, ushort>();
|
||||
ColorRG32Signed convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRG32Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRG32Signed original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRG32Signed, short, ColorRGBA64Signed, short>();
|
||||
ColorRG32Signed convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRG32Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,58 @@ public partial class ColorRG32Tests
|
||||
A = 347,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32IsLossless()
|
||||
{
|
||||
ColorRG32 original = MakeRandomColor();
|
||||
ColorRG32 converted = original.Convert<ColorRG32, ushort, ColorRG32, ushort>();
|
||||
ColorRG32 convertedBack = converted.Convert<ColorRG32, ushort, ColorRG32, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG32SignedIsLossless()
|
||||
{
|
||||
ColorRG32 original = MakeRandomColor();
|
||||
ColorRG32Signed converted = original.Convert<ColorRG32, ushort, ColorRG32Signed, short>();
|
||||
ColorRG32 convertedBack = converted.Convert<ColorRG32Signed, short, ColorRG32, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorRG32 original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorRG32, ushort, ColorRGB48, ushort>();
|
||||
ColorRG32 convertedBack = converted.Convert<ColorRGB48, ushort, ColorRG32, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorRG32 original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorRG32, ushort, ColorRGB48Signed, short>();
|
||||
ColorRG32 convertedBack = converted.Convert<ColorRGB48Signed, short, ColorRG32, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRG32 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRG32, ushort, ColorRGBA64, ushort>();
|
||||
ColorRG32 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRG32, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRG32 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRG32, ushort, ColorRGBA64Signed, short>();
|
||||
ColorRG32 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRG32, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRG64SingleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRG64Single>(), Is.EqualTo(8));
|
||||
}
|
||||
|
||||
[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 = 0.333f;
|
||||
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 = 0.333f;
|
||||
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 = 0.333f;
|
||||
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 = 0.333f;
|
||||
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 ColorRG64Single MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0.447f,
|
||||
G = 0.224f,
|
||||
B = 0.95f,
|
||||
A = 0.897f,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG64SingleIsLossless()
|
||||
{
|
||||
ColorRG64Single original = MakeRandomColor();
|
||||
ColorRG64Single converted = original.Convert<ColorRG64Single, float, ColorRG64Single, float>();
|
||||
ColorRG64Single convertedBack = converted.Convert<ColorRG64Single, float, ColorRG64Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRG128DoubleIsLossless()
|
||||
{
|
||||
ColorRG64Single original = MakeRandomColor();
|
||||
ColorRG128Double converted = original.Convert<ColorRG64Single, float, ColorRG128Double, double>();
|
||||
ColorRG64Single convertedBack = converted.Convert<ColorRG128Double, double, ColorRG64Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB96SingleIsLossless()
|
||||
{
|
||||
ColorRG64Single original = MakeRandomColor();
|
||||
ColorRGB96Single converted = original.Convert<ColorRG64Single, float, ColorRGB96Single, float>();
|
||||
ColorRG64Single convertedBack = converted.Convert<ColorRGB96Single, float, ColorRG64Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorRG64Single original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorRG64Single, float, ColorRGB192Double, double>();
|
||||
ColorRG64Single convertedBack = converted.Convert<ColorRGB192Double, double, ColorRG64Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA128SingleIsLossless()
|
||||
{
|
||||
ColorRG64Single original = MakeRandomColor();
|
||||
ColorRGBA128Single converted = original.Convert<ColorRG64Single, float, ColorRGBA128Single, float>();
|
||||
ColorRG64Single convertedBack = converted.Convert<ColorRGBA128Single, float, ColorRG64Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRG64Single original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRG64Single, float, ColorRGBA256Double, double>();
|
||||
ColorRG64Single convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRG64Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,94 @@ public partial class ColorRGB16Tests
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorRGB16 original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorRGB16, byte, ColorARGB32, byte>();
|
||||
ColorRGB16 convertedBack = converted.Convert<ColorARGB32, byte, ColorRGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorRGB16 original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorRGB16, byte, ColorBGRA32, byte>();
|
||||
ColorRGB16 convertedBack = converted.Convert<ColorBGRA32, byte, ColorRGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24IsLossless()
|
||||
{
|
||||
ColorRGB16 original = MakeRandomColor();
|
||||
ColorRGB24 converted = original.Convert<ColorRGB16, byte, ColorRGB24, byte>();
|
||||
ColorRGB16 convertedBack = converted.Convert<ColorRGB24, byte, ColorRGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24SignedIsLossless()
|
||||
{
|
||||
ColorRGB16 original = MakeRandomColor();
|
||||
ColorRGB24Signed converted = original.Convert<ColorRGB16, byte, ColorRGB24Signed, sbyte>();
|
||||
ColorRGB16 convertedBack = converted.Convert<ColorRGB24Signed, sbyte, ColorRGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorRGB16 original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorRGB16, byte, ColorRGB48, ushort>();
|
||||
ColorRGB16 convertedBack = converted.Convert<ColorRGB48, ushort, ColorRGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorRGB16 original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorRGB16, byte, ColorRGB48Signed, short>();
|
||||
ColorRGB16 convertedBack = converted.Convert<ColorRGB48Signed, short, ColorRGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorRGB16 original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorRGB16, byte, ColorRGBA32, byte>();
|
||||
ColorRGB16 convertedBack = converted.Convert<ColorRGBA32, byte, ColorRGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorRGB16 original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorRGB16, byte, ColorRGBA32Signed, sbyte>();
|
||||
ColorRGB16 convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorRGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRGB16 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRGB16, byte, ColorRGBA64, ushort>();
|
||||
ColorRGB16 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRGB16 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRGB16, byte, ColorRGBA64Signed, short>();
|
||||
ColorRGB16 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRGB16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
+30
-11
@@ -1,16 +1,17 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRGBASingleTests
|
||||
public partial class ColorRGB192DoubleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBASingle>(), Is.EqualTo(16));
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB192Double>(), Is.EqualTo(24));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -56,7 +57,7 @@ public partial class ColorRGBASingleTests
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = 0.333f;
|
||||
color.R = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
@@ -72,7 +73,7 @@ public partial class ColorRGBASingleTests
|
||||
var r = color.R;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = 0.333f;
|
||||
color.G = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -88,7 +89,7 @@ public partial class ColorRGBASingleTests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = 0.333f;
|
||||
color.B = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -104,7 +105,7 @@ public partial class ColorRGBASingleTests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = 0.333f;
|
||||
color.A = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -142,14 +143,32 @@ public partial class ColorRGBASingleTests
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRGBASingle MakeRandomColor()
|
||||
public static ColorRGB192Double MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0.447f,
|
||||
G = 0.224f,
|
||||
B = 0.95f,
|
||||
A = 0.897f,
|
||||
R = 0.447,
|
||||
G = 0.224,
|
||||
B = 0.95,
|
||||
A = 0.897,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorRGB192Double original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorRGB192Double, double, ColorRGB192Double, double>();
|
||||
ColorRGB192Double convertedBack = converted.Convert<ColorRGB192Double, double, ColorRGB192Double, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRGB192Double original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRGB192Double, double, ColorRGBA256Double, double>();
|
||||
ColorRGB192Double convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRGB192Double, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRGB24SignedTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB24Signed>(), Is.EqualTo(3));
|
||||
}
|
||||
|
||||
[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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 ColorRGB24Signed MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = -0b01010101,
|
||||
G = 0b01110010,
|
||||
B = -0b00001111,
|
||||
A = -0b01000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorRGB24Signed original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorRGB24Signed, sbyte, ColorARGB32, byte>();
|
||||
ColorRGB24Signed convertedBack = converted.Convert<ColorARGB32, byte, ColorRGB24Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorRGB24Signed original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorRGB24Signed, sbyte, ColorBGRA32, byte>();
|
||||
ColorRGB24Signed convertedBack = converted.Convert<ColorBGRA32, byte, ColorRGB24Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24IsLossless()
|
||||
{
|
||||
ColorRGB24Signed original = MakeRandomColor();
|
||||
ColorRGB24 converted = original.Convert<ColorRGB24Signed, sbyte, ColorRGB24, byte>();
|
||||
ColorRGB24Signed convertedBack = converted.Convert<ColorRGB24, byte, ColorRGB24Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24SignedIsLossless()
|
||||
{
|
||||
ColorRGB24Signed original = MakeRandomColor();
|
||||
ColorRGB24Signed converted = original.Convert<ColorRGB24Signed, sbyte, ColorRGB24Signed, sbyte>();
|
||||
ColorRGB24Signed convertedBack = converted.Convert<ColorRGB24Signed, sbyte, ColorRGB24Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorRGB24Signed original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorRGB24Signed, sbyte, ColorRGB48, ushort>();
|
||||
ColorRGB24Signed convertedBack = converted.Convert<ColorRGB48, ushort, ColorRGB24Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorRGB24Signed original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorRGB24Signed, sbyte, ColorRGB48Signed, short>();
|
||||
ColorRGB24Signed convertedBack = converted.Convert<ColorRGB48Signed, short, ColorRGB24Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorRGB24Signed original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorRGB24Signed, sbyte, ColorRGBA32, byte>();
|
||||
ColorRGB24Signed convertedBack = converted.Convert<ColorRGBA32, byte, ColorRGB24Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorRGB24Signed original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorRGB24Signed, sbyte, ColorRGBA32Signed, sbyte>();
|
||||
ColorRGB24Signed convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorRGB24Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRGB24Signed original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRGB24Signed, sbyte, ColorRGBA64, ushort>();
|
||||
ColorRGB24Signed convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRGB24Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRGB24Signed original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRGB24Signed, sbyte, ColorRGBA64Signed, short>();
|
||||
ColorRGB24Signed convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRGB24Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,94 @@ public partial class ColorRGB24Tests
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorRGB24 original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorRGB24, byte, ColorARGB32, byte>();
|
||||
ColorRGB24 convertedBack = converted.Convert<ColorARGB32, byte, ColorRGB24, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorRGB24 original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorRGB24, byte, ColorBGRA32, byte>();
|
||||
ColorRGB24 convertedBack = converted.Convert<ColorBGRA32, byte, ColorRGB24, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24IsLossless()
|
||||
{
|
||||
ColorRGB24 original = MakeRandomColor();
|
||||
ColorRGB24 converted = original.Convert<ColorRGB24, byte, ColorRGB24, byte>();
|
||||
ColorRGB24 convertedBack = converted.Convert<ColorRGB24, byte, ColorRGB24, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24SignedIsLossless()
|
||||
{
|
||||
ColorRGB24 original = MakeRandomColor();
|
||||
ColorRGB24Signed converted = original.Convert<ColorRGB24, byte, ColorRGB24Signed, sbyte>();
|
||||
ColorRGB24 convertedBack = converted.Convert<ColorRGB24Signed, sbyte, ColorRGB24, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorRGB24 original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorRGB24, byte, ColorRGB48, ushort>();
|
||||
ColorRGB24 convertedBack = converted.Convert<ColorRGB48, ushort, ColorRGB24, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorRGB24 original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorRGB24, byte, ColorRGB48Signed, short>();
|
||||
ColorRGB24 convertedBack = converted.Convert<ColorRGB48Signed, short, ColorRGB24, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorRGB24 original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorRGB24, byte, ColorRGBA32, byte>();
|
||||
ColorRGB24 convertedBack = converted.Convert<ColorRGBA32, byte, ColorRGB24, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorRGB24 original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorRGB24, byte, ColorRGBA32Signed, sbyte>();
|
||||
ColorRGB24 convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorRGB24, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRGB24 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRGB24, byte, ColorRGBA64, ushort>();
|
||||
ColorRGB24 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRGB24, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRGB24 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRGB24, byte, ColorRGBA64Signed, short>();
|
||||
ColorRGB24 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRGB24, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
+58
-3
@@ -1,16 +1,17 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRHalfTests
|
||||
public partial class ColorRGB32HalfTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRHalf>(), Is.EqualTo(2));
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB32Half>(), Is.EqualTo(4));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -142,7 +143,7 @@ public partial class ColorRHalfTests
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRHalf MakeRandomColor()
|
||||
public static ColorRGB32Half MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
@@ -152,4 +153,58 @@ public partial class ColorRHalfTests
|
||||
A = (Half)0.897f,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48HalfIsLossless()
|
||||
{
|
||||
ColorRGB32Half original = MakeRandomColor();
|
||||
ColorRGB48Half converted = original.Convert<ColorRGB32Half, Half, ColorRGB48Half, Half>();
|
||||
ColorRGB32Half convertedBack = converted.Convert<ColorRGB48Half, Half, ColorRGB32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB96SingleIsLossless()
|
||||
{
|
||||
ColorRGB32Half original = MakeRandomColor();
|
||||
ColorRGB96Single converted = original.Convert<ColorRGB32Half, Half, ColorRGB96Single, float>();
|
||||
ColorRGB32Half convertedBack = converted.Convert<ColorRGB96Single, float, ColorRGB32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorRGB32Half original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorRGB32Half, Half, ColorRGB192Double, double>();
|
||||
ColorRGB32Half convertedBack = converted.Convert<ColorRGB192Double, double, ColorRGB32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA128SingleIsLossless()
|
||||
{
|
||||
ColorRGB32Half original = MakeRandomColor();
|
||||
ColorRGBA128Single converted = original.Convert<ColorRGB32Half, Half, ColorRGBA128Single, float>();
|
||||
ColorRGB32Half convertedBack = converted.Convert<ColorRGBA128Single, float, ColorRGB32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRGB32Half original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRGB32Half, Half, ColorRGBA256Double, double>();
|
||||
ColorRGB32Half convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRGB32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64HalfIsLossless()
|
||||
{
|
||||
ColorRGB32Half original = MakeRandomColor();
|
||||
ColorRGBA64Half converted = original.Convert<ColorRGB32Half, Half, ColorRGBA64Half, Half>();
|
||||
ColorRGB32Half convertedBack = converted.Convert<ColorRGBA64Half, Half, ColorRGB32Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRGB48HalfTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB48Half>(), Is.EqualTo(6));
|
||||
}
|
||||
|
||||
[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 = (Half)0.333f;
|
||||
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 = (Half)0.333f;
|
||||
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 = (Half)0.333f;
|
||||
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 = (Half)0.333f;
|
||||
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 ColorRGB48Half MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = (Half)0.447f,
|
||||
G = (Half)0.224f,
|
||||
B = (Half)0.95f,
|
||||
A = (Half)0.897f,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48HalfIsLossless()
|
||||
{
|
||||
ColorRGB48Half original = MakeRandomColor();
|
||||
ColorRGB48Half converted = original.Convert<ColorRGB48Half, Half, ColorRGB48Half, Half>();
|
||||
ColorRGB48Half convertedBack = converted.Convert<ColorRGB48Half, Half, ColorRGB48Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB96SingleIsLossless()
|
||||
{
|
||||
ColorRGB48Half original = MakeRandomColor();
|
||||
ColorRGB96Single converted = original.Convert<ColorRGB48Half, Half, ColorRGB96Single, float>();
|
||||
ColorRGB48Half convertedBack = converted.Convert<ColorRGB96Single, float, ColorRGB48Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorRGB48Half original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorRGB48Half, Half, ColorRGB192Double, double>();
|
||||
ColorRGB48Half convertedBack = converted.Convert<ColorRGB192Double, double, ColorRGB48Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA128SingleIsLossless()
|
||||
{
|
||||
ColorRGB48Half original = MakeRandomColor();
|
||||
ColorRGBA128Single converted = original.Convert<ColorRGB48Half, Half, ColorRGBA128Single, float>();
|
||||
ColorRGB48Half convertedBack = converted.Convert<ColorRGBA128Single, float, ColorRGB48Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRGB48Half original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRGB48Half, Half, ColorRGBA256Double, double>();
|
||||
ColorRGB48Half convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRGB48Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64HalfIsLossless()
|
||||
{
|
||||
ColorRGB48Half original = MakeRandomColor();
|
||||
ColorRGBA64Half converted = original.Convert<ColorRGB48Half, Half, ColorRGBA64Half, Half>();
|
||||
ColorRGB48Half convertedBack = converted.Convert<ColorRGBA64Half, Half, ColorRGB48Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRGB48SignedTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB48Signed>(), Is.EqualTo(6));
|
||||
}
|
||||
|
||||
[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 = 31871;
|
||||
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 = 31871;
|
||||
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 = 31871;
|
||||
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 = 31871;
|
||||
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 ColorRGB48Signed MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = -24000,
|
||||
G = 21354,
|
||||
B = -80,
|
||||
A = 347,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorRGB48Signed original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorRGB48Signed, short, ColorRGB48, ushort>();
|
||||
ColorRGB48Signed convertedBack = converted.Convert<ColorRGB48, ushort, ColorRGB48Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorRGB48Signed original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorRGB48Signed, short, ColorRGB48Signed, short>();
|
||||
ColorRGB48Signed convertedBack = converted.Convert<ColorRGB48Signed, short, ColorRGB48Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRGB48Signed original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRGB48Signed, short, ColorRGBA64, ushort>();
|
||||
ColorRGB48Signed convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRGB48Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRGB48Signed original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRGB48Signed, short, ColorRGBA64Signed, short>();
|
||||
ColorRGB48Signed convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRGB48Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,40 @@ public partial class ColorRGB48Tests
|
||||
A = 347,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
{
|
||||
ColorRGB48 original = MakeRandomColor();
|
||||
ColorRGB48 converted = original.Convert<ColorRGB48, ushort, ColorRGB48, ushort>();
|
||||
ColorRGB48 convertedBack = converted.Convert<ColorRGB48, ushort, ColorRGB48, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
{
|
||||
ColorRGB48 original = MakeRandomColor();
|
||||
ColorRGB48Signed converted = original.Convert<ColorRGB48, ushort, ColorRGB48Signed, short>();
|
||||
ColorRGB48 convertedBack = converted.Convert<ColorRGB48Signed, short, ColorRGB48, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRGB48 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRGB48, ushort, ColorRGBA64, ushort>();
|
||||
ColorRGB48 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRGB48, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRGB48 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRGB48, ushort, ColorRGBA64Signed, short>();
|
||||
ColorRGB48 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRGB48, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
+40
-3
@@ -1,16 +1,17 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRSingleTests
|
||||
public partial class ColorRGB96SingleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRSingle>(), Is.EqualTo(4));
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB96Single>(), Is.EqualTo(12));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -142,7 +143,7 @@ public partial class ColorRSingleTests
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRSingle MakeRandomColor()
|
||||
public static ColorRGB96Single MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
@@ -152,4 +153,40 @@ public partial class ColorRSingleTests
|
||||
A = 0.897f,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB96SingleIsLossless()
|
||||
{
|
||||
ColorRGB96Single original = MakeRandomColor();
|
||||
ColorRGB96Single converted = original.Convert<ColorRGB96Single, float, ColorRGB96Single, float>();
|
||||
ColorRGB96Single convertedBack = converted.Convert<ColorRGB96Single, float, ColorRGB96Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorRGB96Single original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorRGB96Single, float, ColorRGB192Double, double>();
|
||||
ColorRGB96Single convertedBack = converted.Convert<ColorRGB192Double, double, ColorRGB96Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA128SingleIsLossless()
|
||||
{
|
||||
ColorRGB96Single original = MakeRandomColor();
|
||||
ColorRGBA128Single converted = original.Convert<ColorRGB96Single, float, ColorRGBA128Single, float>();
|
||||
ColorRGB96Single convertedBack = converted.Convert<ColorRGBA128Single, float, ColorRGB96Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRGB96Single original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRGB96Single, float, ColorRGBA256Double, double>();
|
||||
ColorRGB96Single convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRGB96Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,22 @@ public partial class ColorRGB9e5Tests
|
||||
A = 0.897,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
{
|
||||
ColorRGB9e5 original = MakeRandomColor();
|
||||
ColorRGB192Double converted = original.Convert<ColorRGB9e5, double, ColorRGB192Double, double>();
|
||||
ColorRGB9e5 convertedBack = converted.Convert<ColorRGB192Double, double, ColorRGB9e5, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRGB9e5 original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRGB9e5, double, ColorRGBA256Double, double>();
|
||||
ColorRGB9e5 convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRGB9e5, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
+22
-3
@@ -1,16 +1,17 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRGSingleTests
|
||||
public partial class ColorRGBA128SingleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGSingle>(), Is.EqualTo(8));
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA128Single>(), Is.EqualTo(16));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -142,7 +143,7 @@ public partial class ColorRGSingleTests
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRGSingle MakeRandomColor()
|
||||
public static ColorRGBA128Single MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
@@ -152,4 +153,22 @@ public partial class ColorRGSingleTests
|
||||
A = 0.897f,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA128SingleIsLossless()
|
||||
{
|
||||
ColorRGBA128Single original = MakeRandomColor();
|
||||
ColorRGBA128Single converted = original.Convert<ColorRGBA128Single, float, ColorRGBA128Single, float>();
|
||||
ColorRGBA128Single convertedBack = converted.Convert<ColorRGBA128Single, float, ColorRGBA128Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRGBA128Single original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRGBA128Single, float, ColorRGBA256Double, double>();
|
||||
ColorRGBA128Single convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRGBA128Single, float>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,58 @@ public partial class ColorRGBA16Tests
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorRGBA16 original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorRGBA16, byte, ColorARGB32, byte>();
|
||||
ColorRGBA16 convertedBack = converted.Convert<ColorARGB32, byte, ColorRGBA16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorRGBA16 original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorRGBA16, byte, ColorBGRA32, byte>();
|
||||
ColorRGBA16 convertedBack = converted.Convert<ColorBGRA32, byte, ColorRGBA16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorRGBA16 original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorRGBA16, byte, ColorRGBA32, byte>();
|
||||
ColorRGBA16 convertedBack = converted.Convert<ColorRGBA32, byte, ColorRGBA16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorRGBA16 original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorRGBA16, byte, ColorRGBA32Signed, sbyte>();
|
||||
ColorRGBA16 convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorRGBA16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRGBA16 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRGBA16, byte, ColorRGBA64, ushort>();
|
||||
ColorRGBA16 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRGBA16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRGBA16 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRGBA16, byte, ColorRGBA64Signed, short>();
|
||||
ColorRGBA16 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRGBA16, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
+21
-11
@@ -1,16 +1,17 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRGBSingleTests
|
||||
public partial class ColorRGBA256DoubleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBSingle>(), Is.EqualTo(12));
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA256Double>(), Is.EqualTo(32));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -56,7 +57,7 @@ public partial class ColorRGBSingleTests
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = 0.333f;
|
||||
color.R = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
@@ -72,7 +73,7 @@ public partial class ColorRGBSingleTests
|
||||
var r = color.R;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = 0.333f;
|
||||
color.G = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -88,7 +89,7 @@ public partial class ColorRGBSingleTests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = 0.333f;
|
||||
color.B = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -104,7 +105,7 @@ public partial class ColorRGBSingleTests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = 0.333f;
|
||||
color.A = 0.333;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -142,14 +143,23 @@ public partial class ColorRGBSingleTests
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRGBSingle MakeRandomColor()
|
||||
public static ColorRGBA256Double MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0.447f,
|
||||
G = 0.224f,
|
||||
B = 0.95f,
|
||||
A = 0.897f,
|
||||
R = 0.447,
|
||||
G = 0.224,
|
||||
B = 0.95,
|
||||
A = 0.897,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRGBA256Double original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRGBA256Double, double, ColorRGBA256Double, double>();
|
||||
ColorRGBA256Double convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRGBA256Double, double>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRGBA32SignedTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA32Signed>(), 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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 = 0b01001110;
|
||||
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 ColorRGBA32Signed MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = -0b01010101,
|
||||
G = 0b01110010,
|
||||
B = -0b00001111,
|
||||
A = -0b01000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorRGBA32Signed original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorRGBA32Signed, sbyte, ColorARGB32, byte>();
|
||||
ColorRGBA32Signed convertedBack = converted.Convert<ColorARGB32, byte, ColorRGBA32Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorRGBA32Signed original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorRGBA32Signed, sbyte, ColorBGRA32, byte>();
|
||||
ColorRGBA32Signed convertedBack = converted.Convert<ColorBGRA32, byte, ColorRGBA32Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorRGBA32Signed original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorRGBA32Signed, sbyte, ColorRGBA32, byte>();
|
||||
ColorRGBA32Signed convertedBack = converted.Convert<ColorRGBA32, byte, ColorRGBA32Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorRGBA32Signed original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorRGBA32Signed, sbyte, ColorRGBA32Signed, sbyte>();
|
||||
ColorRGBA32Signed convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorRGBA32Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRGBA32Signed original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRGBA32Signed, sbyte, ColorRGBA64, ushort>();
|
||||
ColorRGBA32Signed convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRGBA32Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRGBA32Signed original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRGBA32Signed, sbyte, ColorRGBA64Signed, short>();
|
||||
ColorRGBA32Signed convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRGBA32Signed, sbyte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,58 @@ public partial class ColorRGBA32Tests
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
{
|
||||
ColorRGBA32 original = MakeRandomColor();
|
||||
ColorARGB32 converted = original.Convert<ColorRGBA32, byte, ColorARGB32, byte>();
|
||||
ColorRGBA32 convertedBack = converted.Convert<ColorARGB32, byte, ColorRGBA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
{
|
||||
ColorRGBA32 original = MakeRandomColor();
|
||||
ColorBGRA32 converted = original.Convert<ColorRGBA32, byte, ColorBGRA32, byte>();
|
||||
ColorRGBA32 convertedBack = converted.Convert<ColorBGRA32, byte, ColorRGBA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
{
|
||||
ColorRGBA32 original = MakeRandomColor();
|
||||
ColorRGBA32 converted = original.Convert<ColorRGBA32, byte, ColorRGBA32, byte>();
|
||||
ColorRGBA32 convertedBack = converted.Convert<ColorRGBA32, byte, ColorRGBA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
{
|
||||
ColorRGBA32 original = MakeRandomColor();
|
||||
ColorRGBA32Signed converted = original.Convert<ColorRGBA32, byte, ColorRGBA32Signed, sbyte>();
|
||||
ColorRGBA32 convertedBack = converted.Convert<ColorRGBA32Signed, sbyte, ColorRGBA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRGBA32 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRGBA32, byte, ColorRGBA64, ushort>();
|
||||
ColorRGBA32 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRGBA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRGBA32 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRGBA32, byte, ColorRGBA64Signed, short>();
|
||||
ColorRGBA32 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRGBA32, byte>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
+31
-3
@@ -1,16 +1,17 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRGHalfTests
|
||||
public partial class ColorRGBA64HalfTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGHalf>(), Is.EqualTo(4));
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA64Half>(), Is.EqualTo(8));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -142,7 +143,7 @@ public partial class ColorRGHalfTests
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRGHalf MakeRandomColor()
|
||||
public static ColorRGBA64Half MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
@@ -152,4 +153,31 @@ public partial class ColorRGHalfTests
|
||||
A = (Half)0.897f,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA128SingleIsLossless()
|
||||
{
|
||||
ColorRGBA64Half original = MakeRandomColor();
|
||||
ColorRGBA128Single converted = original.Convert<ColorRGBA64Half, Half, ColorRGBA128Single, float>();
|
||||
ColorRGBA64Half convertedBack = converted.Convert<ColorRGBA128Single, float, ColorRGBA64Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
{
|
||||
ColorRGBA64Half original = MakeRandomColor();
|
||||
ColorRGBA256Double converted = original.Convert<ColorRGBA64Half, Half, ColorRGBA256Double, double>();
|
||||
ColorRGBA64Half convertedBack = converted.Convert<ColorRGBA256Double, double, ColorRGBA64Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64HalfIsLossless()
|
||||
{
|
||||
ColorRGBA64Half original = MakeRandomColor();
|
||||
ColorRGBA64Half converted = original.Convert<ColorRGBA64Half, Half, ColorRGBA64Half, Half>();
|
||||
ColorRGBA64Half convertedBack = converted.Convert<ColorRGBA64Half, Half, ColorRGBA64Half, Half>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
+30
-11
@@ -1,16 +1,17 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
|
||||
public partial class ColorRGBAHalfTests
|
||||
public partial class ColorRGBA64SignedTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBAHalf>(), Is.EqualTo(8));
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA64Signed>(), Is.EqualTo(8));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -56,7 +57,7 @@ public partial class ColorRGBAHalfTests
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = (Half)0.333f;
|
||||
color.R = 31871;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
@@ -72,7 +73,7 @@ public partial class ColorRGBAHalfTests
|
||||
var r = color.R;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = (Half)0.333f;
|
||||
color.G = 31871;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -88,7 +89,7 @@ public partial class ColorRGBAHalfTests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = (Half)0.333f;
|
||||
color.B = 31871;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -104,7 +105,7 @@ public partial class ColorRGBAHalfTests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = (Half)0.333f;
|
||||
color.A = 31871;
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
@@ -142,14 +143,32 @@ public partial class ColorRGBAHalfTests
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRGBAHalf MakeRandomColor()
|
||||
public static ColorRGBA64Signed MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = (Half)0.447f,
|
||||
G = (Half)0.224f,
|
||||
B = (Half)0.95f,
|
||||
A = (Half)0.897f,
|
||||
R = -24000,
|
||||
G = 21354,
|
||||
B = -80,
|
||||
A = 347,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRGBA64Signed original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRGBA64Signed, short, ColorRGBA64, ushort>();
|
||||
ColorRGBA64Signed convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRGBA64Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRGBA64Signed original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRGBA64Signed, short, ColorRGBA64Signed, short>();
|
||||
ColorRGBA64Signed convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRGBA64Signed, short>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -152,4 +153,22 @@ public partial class ColorRGBA64Tests
|
||||
A = 347,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
{
|
||||
ColorRGBA64 original = MakeRandomColor();
|
||||
ColorRGBA64 converted = original.Convert<ColorRGBA64, ushort, ColorRGBA64, ushort>();
|
||||
ColorRGBA64 convertedBack = converted.Convert<ColorRGBA64, ushort, ColorRGBA64, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
{
|
||||
ColorRGBA64 original = MakeRandomColor();
|
||||
ColorRGBA64Signed converted = original.Convert<ColorRGBA64, ushort, ColorRGBA64Signed, short>();
|
||||
ColorRGBA64 convertedBack = converted.Convert<ColorRGBA64Signed, short, ColorRGBA64, ushort>();
|
||||
Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -26,11 +27,10 @@ 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.ARGB16ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorARGB16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
int bytesRead = RgbConverter.Convert<ColorARGB16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -45,6 +45,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -99,10 +100,8 @@ 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.R16ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorR16, ushort, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
int bytesRead = RgbConverter.Convert<ColorR16, ushort, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
@@ -114,10 +113,8 @@ 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.RGBA16ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
int bytesRead = RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
@@ -157,7 +154,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rhalf");
|
||||
RgbConverter.RHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRHalf, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorR16Half, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -166,16 +163,31 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rghalf");
|
||||
RgbConverter.RGHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGHalf, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRG32Half, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB32HalfTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgb24");
|
||||
RgbConverter.Convert<ColorRGB24, byte, ColorRGB32Half, Half>(data, 256, 256, out var halfData);
|
||||
int legacyBytesRead = RgbConverter.R11G11B10FloatToBGRA32(halfData, 256, 256, out var legacyRgbData);
|
||||
int bytesRead = RgbConverter.Convert<ColorRGB32Half, Half, ColorBGRA32, byte>(halfData, 256, 256, out var rgbData);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(halfData.Length));
|
||||
Assert.That(legacyBytesRead, Is.EqualTo(halfData.Length));
|
||||
Assert.That(rgbData, Is.EqualTo(legacyRgbData));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBAHalfTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgbahalf");
|
||||
RgbConverter.RGBAHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBAHalf, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA64Half, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -184,7 +196,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rfloat");
|
||||
RgbConverter.RFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRSingle, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorR32Single, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -193,7 +205,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgfloat");
|
||||
RgbConverter.RGFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGSingle, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRG64Single, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
@@ -202,7 +214,7 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgbafloat");
|
||||
RgbConverter.RGBAFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBASingle, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA128Single, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
public sealed class RgbTests
|
||||
{
|
||||
@@ -15,19 +18,6 @@
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertARGB16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.argb4444");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Rgb.RgbConverter.ARGB16ToBGRA32(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB24Test()
|
||||
{
|
||||
@@ -80,32 +70,6 @@
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertR16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.r16");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Rgb.RgbConverter.R16ToBGRA32(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBA16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgba4444");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Rgb.RgbConverter.RGBA16ToBGRA32(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRG16Test()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net5.0;net6.0;net7.0</TargetFrameworks>
|
||||
<LangVersion>Latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
@@ -11,23 +11,34 @@
|
||||
<RootNamespace>AssetRipper.TextureDecoder</RootNamespace>
|
||||
<Authors>ds5678</Authors>
|
||||
<Company>AssetRipper</Company>
|
||||
<Version>1.2.0.0</Version>
|
||||
<AssemblyVersion>1.2.0.0</AssemblyVersion>
|
||||
<Version>1.3.0.0</Version>
|
||||
<AssemblyVersion>$(Version)</AssemblyVersion>
|
||||
<PackageId>AssetRipper.TextureDecoder</PackageId>
|
||||
<PackageTags>C# Texture</PackageTags>
|
||||
<RepositoryUrl>https://github.com/AssetRipper/TextureDecoder</RepositoryUrl>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageProjectUrl>https://github.com/AssetRipper/TextureDecoder</PackageProjectUrl>
|
||||
<Copyright>Copyright (c) 2022 ds5678</Copyright>
|
||||
<Copyright>Copyright (c) 2022 - 2023 ds5678</Copyright>
|
||||
<Description>Managed library for decoding textures in multiple formats.</Description>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
|
||||
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<DocumentationFile>bin\TextureDecoder.xml</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="PolySharp" Version="1.13.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
|
||||
<PackageReference Include="Half" Version="1.0.0" />
|
||||
<PackageReference Include="System.Memory" Version="4.5.5" />
|
||||
|
||||
@@ -2,6 +2,14 @@ namespace AssetRipper.TextureDecoder.Astc
|
||||
{
|
||||
public static partial class AstcDecoder
|
||||
{
|
||||
private static void ValidateBlockDimension(int value, [CallerArgumentExpression(nameof(value))] string? paramName = null)
|
||||
{
|
||||
if (value < 4 || value > 12)
|
||||
{
|
||||
throw new ArgumentException($"Block dimension must be between 4 and 12, inclusive. Value: {value}", paramName);
|
||||
}
|
||||
}
|
||||
|
||||
public static int DecodeASTC(ReadOnlySpan<byte> input, int width, int height, int blockWidth, int blockHeight, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
@@ -21,6 +29,8 @@ namespace AssetRipper.TextureDecoder.Astc
|
||||
|
||||
private unsafe static int DecodeASTC(byte* input, int width, int height, int blockWidth, int blockHeight, byte* output)
|
||||
{
|
||||
ValidateBlockDimension(blockWidth);
|
||||
ValidateBlockDimension(blockHeight);
|
||||
int bcw = (width + blockWidth - 1) / blockWidth;
|
||||
int bch = (height + blockHeight - 1) / blockHeight;
|
||||
int clen_last = (width + blockWidth - 1) % blockWidth + 1;
|
||||
|
||||
@@ -12,16 +12,13 @@ namespace AssetRipper.TextureDecoder.Atc
|
||||
|
||||
public unsafe static int DecompressAtcRgb4(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
fixed (byte* inputPtr = input)
|
||||
fixed (byte* outputPtr = output)
|
||||
{
|
||||
fixed (byte* outputPtr = output)
|
||||
{
|
||||
return DecompressAtcRgb4(inputPtr, width, height, outputPtr);
|
||||
}
|
||||
return DecompressAtcRgb4(input, width, height, outputPtr);
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe static int DecompressAtcRgb4(byte* input, int width, int height, byte* output)
|
||||
private unsafe static int DecompressAtcRgb4(ReadOnlySpan<byte> input, int width, int height, byte* output)
|
||||
{
|
||||
int bcw = (width + 3) / 4;
|
||||
int bch = (height + 3) / 4;
|
||||
@@ -32,7 +29,7 @@ namespace AssetRipper.TextureDecoder.Atc
|
||||
{
|
||||
for (int s = 0; s < bcw; s++, inputOffset += 8)
|
||||
{
|
||||
DecodeAtcRgb4Block(new ReadOnlySpan<byte>(input + inputOffset, 8), new Span<uint>(buf, 16));
|
||||
DecodeAtcRgb4Block(input.Slice(inputOffset, 8), new Span<uint>(buf, 16));
|
||||
int clen = s < bcw - 1 ? 4 : clen_last;
|
||||
uint* outputPtr = (uint*)(output + (t * 16 * width + s * 16));
|
||||
uint* bufPtr = buf;
|
||||
@@ -59,16 +56,13 @@ namespace AssetRipper.TextureDecoder.Atc
|
||||
|
||||
public unsafe static int DecompressAtcRgba8(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
fixed (byte* inputPtr = input)
|
||||
fixed (byte* outputPtr = output)
|
||||
{
|
||||
fixed (byte* outputPtr = output)
|
||||
{
|
||||
return DecompressAtcRgba8(inputPtr, width, height, outputPtr);
|
||||
}
|
||||
return DecompressAtcRgba8(input, width, height, outputPtr);
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe static int DecompressAtcRgba8(byte* input, int width, int height, byte* output)
|
||||
private unsafe static int DecompressAtcRgba8(ReadOnlySpan<byte> input, int width, int height, byte* output)
|
||||
{
|
||||
int bcw = (width + 3) / 4;
|
||||
int bch = (height + 3) / 4;
|
||||
@@ -79,7 +73,7 @@ namespace AssetRipper.TextureDecoder.Atc
|
||||
{
|
||||
for (int s = 0; s < bcw; s++, inputOffset += 16)
|
||||
{
|
||||
DecodeAtcRgba8Block(new ReadOnlySpan<byte>(input + inputOffset, 16), new Span<uint>(buf, 16));
|
||||
DecodeAtcRgba8Block(input.Slice(inputOffset, 16), new Span<uint>(buf, 16));
|
||||
int clen = s < bcw - 1 ? 4 : clen_last;
|
||||
uint* outputPtr = (uint*)(output + (t * 16 * width + s * 16));
|
||||
uint* bufPtr = buf;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace AssetRipper.TextureDecoder.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Struct)]
|
||||
public sealed class RgbaAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Does the format have a red channel?
|
||||
/// </summary>
|
||||
public bool RedChannel { get; init; }
|
||||
/// <summary>
|
||||
/// Does the format have a green channel?
|
||||
/// </summary>
|
||||
public bool GreenChannel { get; init; }
|
||||
/// <summary>
|
||||
/// Does the format have a blue channel?
|
||||
/// </summary>
|
||||
public bool BlueChannel { get; init; }
|
||||
/// <summary>
|
||||
/// Does the format have an alpha channel?
|
||||
/// </summary>
|
||||
public bool AlphaChannel { get; init; }
|
||||
/// <summary>
|
||||
/// Channels utilize the full range of possible values for their underlying type.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// In the case of floating point numbers, this means that the precision is the same in storage and memory.
|
||||
/// </remarks>
|
||||
public bool FullyUtilizedChannels { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Bc;
|
||||
|
||||
public static class Bc1
|
||||
{
|
||||
internal const int BlockSize = 8;
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return Decompress(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int outputOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRGBA32>();
|
||||
BcHelpers.DecompressBc1(input.Slice(inputOffset, BlockSize), output.Slice(outputOffset), width * 4);
|
||||
inputOffset += BlockSize;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(output, width, height, output);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
internal static int GetCompressedSize(int w, int h) => ((w) >> 2) * ((h) >> 2) * BlockSize;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Bc;
|
||||
|
||||
public static class Bc2
|
||||
{
|
||||
internal const int BlockSize = 16;
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return Decompress(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int outputOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRGBA32>();
|
||||
BcHelpers.DecompressBc2(input.Slice(inputOffset), output.Slice(outputOffset), width * 4);
|
||||
inputOffset += BlockSize;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(output, width, height, output);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
internal static int GetCompressedSize(int w, int h) => ((w) >> 2) * ((h) >> 2) * BlockSize;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Bc;
|
||||
|
||||
public static class Bc3
|
||||
{
|
||||
internal const int BlockSize = 16;
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return Decompress(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int outputOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRGBA32>();
|
||||
BcHelpers.DecompressBc3(input.Slice(inputOffset), output.Slice(outputOffset), width * 4);
|
||||
inputOffset += BlockSize;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(output, width, height, output);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
internal static int GetCompressedSize(int w, int h) => ((w) >> 2) * ((h) >> 2) * BlockSize;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Buffers;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Bc;
|
||||
|
||||
public static class Bc4
|
||||
{
|
||||
internal const int BlockSize = 8;
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return Decompress(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int bufferSize = width * height * Unsafe.SizeOf<ColorR8>();
|
||||
byte[] bufferArray = ArrayPool<byte>.Shared.Rent(bufferSize);
|
||||
Span<byte> buffer = new Span<byte>(bufferArray, 0, bufferSize);
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int bufferOffset = ((i * width) + j) * Unsafe.SizeOf<ColorR8>();
|
||||
BcHelpers.DecompressBc4(input.Slice(inputOffset), buffer.Slice(bufferOffset), width);
|
||||
inputOffset += BlockSize;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorR8, byte, ColorBGRA32, byte>(buffer, width, height, output);
|
||||
ArrayPool<byte>.Shared.Return(bufferArray);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
internal static int GetCompressedSize(int w, int h) => ((w) >> 2) * ((h) >> 2) * BlockSize;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Buffers;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Bc;
|
||||
|
||||
public static class Bc5
|
||||
{
|
||||
internal const int BlockSize = 16;
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return Decompress(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int bufferSize = width * height * Unsafe.SizeOf<ColorRG16>();
|
||||
byte[] bufferArray = ArrayPool<byte>.Shared.Rent(bufferSize);
|
||||
Span<byte> buffer = new Span<byte>(bufferArray, 0, bufferSize);
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int bufferOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRG16>();
|
||||
BcHelpers.DecompressBc5(input.Slice(inputOffset), buffer.Slice(bufferOffset), width * 2);
|
||||
inputOffset += BlockSize;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRG16, byte, ColorBGRA32, byte>(buffer, width, height, output);
|
||||
ArrayPool<byte>.Shared.Return(bufferArray);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
internal static int GetCompressedSize(int w, int h) => ((w) >> 2) * ((h) >> 2) * BlockSize;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Buffers;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Bc;
|
||||
|
||||
public static class Bc6h
|
||||
{
|
||||
internal const int BlockSize = 16;
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, bool isSigned, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return Decompress(input, width, height, isSigned, output);
|
||||
}
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, bool isSigned, Span<byte> output)
|
||||
{
|
||||
int bufferSize = width * height * Unsafe.SizeOf<ColorRGB48Half>();
|
||||
byte[] bufferArray = ArrayPool<byte>.Shared.Rent(bufferSize);
|
||||
Span<byte> buffer = new Span<byte>(bufferArray, 0, bufferSize);
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int outputOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRGB48Half>();
|
||||
BcHelpers.DecompressBc6h(
|
||||
input.Slice(inputOffset, BlockSize),
|
||||
buffer.Slice(outputOffset),
|
||||
width * 3,
|
||||
isSigned);
|
||||
inputOffset += BlockSize;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRGB48Half, Half, ColorBGRA32, byte>(buffer, width, height, output);
|
||||
ArrayPool<byte>.Shared.Return(bufferArray);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
internal static int GetCompressedSize(int w, int h) => ((w) >> 2) * ((h) >> 2) * BlockSize;
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
internal static class Bc6hTables
|
||||
{
|
||||
internal static byte[][] ActualBitsCount =
|
||||
internal static byte[][] ActualBitsCount { get; } = new byte[4][]
|
||||
{
|
||||
new byte[] {10, 7, 11, 11, 11, 9, 8, 8, 8, 6, 10, 11, 12, 16},
|
||||
new byte[] {5, 6, 5, 4, 4, 5, 6, 5, 5, 6, 10, 9, 8, 4},
|
||||
new byte[] {5, 6, 4, 5, 4, 5, 5, 6, 5, 6, 10, 9, 8, 4},
|
||||
new byte[] {5, 6, 4, 4, 5, 5, 5, 5, 6, 6, 10, 9, 8, 4}
|
||||
new byte[14] {10, 7, 11, 11, 11, 9, 8, 8, 8, 6, 10, 11, 12, 16},
|
||||
new byte[14] {5, 6, 5, 4, 4, 5, 6, 5, 5, 6, 10, 9, 8, 4},
|
||||
new byte[14] {5, 6, 4, 5, 4, 5, 5, 6, 5, 6, 10, 9, 8, 4},
|
||||
new byte[14] {5, 6, 4, 4, 5, 5, 5, 5, 6, 6, 10, 9, 8, 4}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -15,235 +15,235 @@ internal static class Bc6hTables
|
||||
/// Each 4x4 block represents a single shape.
|
||||
/// Here also every fix-up index has MSB bit set.
|
||||
/// </summary>
|
||||
internal static byte[][][] PartitionSets =
|
||||
internal static byte[][][] PartitionSets { get; } = new byte[32][][]
|
||||
{
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 1, 1},
|
||||
new byte[] {0, 0, 1, 1},
|
||||
new byte[] {0, 0, 1, 1},
|
||||
new byte[] {0, 0, 1, 129}
|
||||
new byte[4] {128, 0, 1, 1},
|
||||
new byte[4] {0, 0, 1, 1},
|
||||
new byte[4] {0, 0, 1, 1},
|
||||
new byte[4] {0, 0, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 1},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 0, 129}
|
||||
new byte[4] {128, 0, 0, 1},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 0, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 1, 1, 1},
|
||||
new byte[] {0, 1, 1, 1},
|
||||
new byte[] {0, 1, 1, 1},
|
||||
new byte[] {0, 1, 1, 129}
|
||||
new byte[4] {128, 1, 1, 1},
|
||||
new byte[4] {0, 1, 1, 1},
|
||||
new byte[4] {0, 1, 1, 1},
|
||||
new byte[4] {0, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 1},
|
||||
new byte[] {0, 0, 1, 1},
|
||||
new byte[] {0, 0, 1, 1},
|
||||
new byte[] {0, 1, 1, 129}
|
||||
new byte[4] {128, 0, 0, 1},
|
||||
new byte[4] {0, 0, 1, 1},
|
||||
new byte[4] {0, 0, 1, 1},
|
||||
new byte[4] {0, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 1, 129}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 1, 1},
|
||||
new byte[] {0, 1, 1, 1},
|
||||
new byte[] {0, 1, 1, 1},
|
||||
new byte[] {1, 1, 1, 129}
|
||||
new byte[4] {128, 0, 1, 1},
|
||||
new byte[4] {0, 1, 1, 1},
|
||||
new byte[4] {0, 1, 1, 1},
|
||||
new byte[4] {1, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 1},
|
||||
new byte[] {0, 0, 1, 1},
|
||||
new byte[] {0, 1, 1, 1},
|
||||
new byte[] {1, 1, 1, 129}
|
||||
new byte[4] {128, 0, 0, 1},
|
||||
new byte[4] {0, 0, 1, 1},
|
||||
new byte[4] {0, 1, 1, 1},
|
||||
new byte[4] {1, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 1, 1},
|
||||
new byte[] {0, 1, 1, 129}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 1, 1},
|
||||
new byte[4] {0, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 1, 129}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 1, 1},
|
||||
new byte[] {0, 1, 1, 1},
|
||||
new byte[] {1, 1, 1, 1},
|
||||
new byte[] {1, 1, 1, 129}
|
||||
new byte[4] {128, 0, 1, 1},
|
||||
new byte[4] {0, 1, 1, 1},
|
||||
new byte[4] {1, 1, 1, 1},
|
||||
new byte[4] {1, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 1, 1, 1},
|
||||
new byte[] {1, 1, 1, 129}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 1, 1, 1},
|
||||
new byte[4] {1, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 1, 1, 129}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 1},
|
||||
new byte[] {0, 1, 1, 1},
|
||||
new byte[] {1, 1, 1, 1},
|
||||
new byte[] {1, 1, 1, 129}
|
||||
new byte[4] {128, 0, 0, 1},
|
||||
new byte[4] {0, 1, 1, 1},
|
||||
new byte[4] {1, 1, 1, 1},
|
||||
new byte[4] {1, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 0},
|
||||
new byte[] {1, 1, 1, 1},
|
||||
new byte[] {1, 1, 1, 129}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 0},
|
||||
new byte[4] {1, 1, 1, 1},
|
||||
new byte[4] {1, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {1, 1, 1, 1},
|
||||
new byte[] {1, 1, 1, 1},
|
||||
new byte[] {1, 1, 1, 129}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {1, 1, 1, 1},
|
||||
new byte[4] {1, 1, 1, 1},
|
||||
new byte[4] {1, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 0},
|
||||
new byte[] {1, 1, 1, 129}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 0},
|
||||
new byte[4] {1, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {1, 0, 0, 0},
|
||||
new byte[] {1, 1, 1, 0},
|
||||
new byte[] {1, 1, 1, 129}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {1, 0, 0, 0},
|
||||
new byte[4] {1, 1, 1, 0},
|
||||
new byte[4] {1, 1, 1, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 1, 129, 1},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 0}
|
||||
new byte[4] {128, 1, 129, 1},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 0},
|
||||
new byte[] {129, 0, 0, 0},
|
||||
new byte[] {1, 1, 1, 0}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 0},
|
||||
new byte[4] {129, 0, 0, 0},
|
||||
new byte[4] {1, 1, 1, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 1, 129, 1},
|
||||
new byte[] {0, 0, 1, 1},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 0, 0}
|
||||
new byte[4] {128, 1, 129, 1},
|
||||
new byte[4] {0, 0, 1, 1},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 0, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 129, 1},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 0}
|
||||
new byte[4] {128, 0, 129, 1},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {1, 0, 0, 0},
|
||||
new byte[] {129, 1, 0, 0},
|
||||
new byte[] {1, 1, 1, 0}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {1, 0, 0, 0},
|
||||
new byte[4] {129, 1, 0, 0},
|
||||
new byte[4] {1, 1, 1, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {0, 0, 0, 0},
|
||||
new byte[] {129, 0, 0, 0},
|
||||
new byte[] {1, 1, 0, 0}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {0, 0, 0, 0},
|
||||
new byte[4] {129, 0, 0, 0},
|
||||
new byte[4] {1, 1, 0, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 1, 1, 1},
|
||||
new byte[] {0, 0, 1, 1},
|
||||
new byte[] {0, 0, 1, 1},
|
||||
new byte[] {0, 0, 0, 129}
|
||||
new byte[4] {128, 1, 1, 1},
|
||||
new byte[4] {0, 0, 1, 1},
|
||||
new byte[4] {0, 0, 1, 1},
|
||||
new byte[4] {0, 0, 0, 129}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 129, 1},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {0, 0, 0, 0}
|
||||
new byte[4] {128, 0, 129, 1},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {0, 0, 0, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {1, 0, 0, 0},
|
||||
new byte[] {129, 0, 0, 0},
|
||||
new byte[] {1, 1, 0, 0}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {1, 0, 0, 0},
|
||||
new byte[4] {129, 0, 0, 0},
|
||||
new byte[4] {1, 1, 0, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 1, 129, 0},
|
||||
new byte[] {0, 1, 1, 0},
|
||||
new byte[] {0, 1, 1, 0},
|
||||
new byte[] {0, 1, 1, 0}
|
||||
new byte[4] {128, 1, 129, 0},
|
||||
new byte[4] {0, 1, 1, 0},
|
||||
new byte[4] {0, 1, 1, 0},
|
||||
new byte[4] {0, 1, 1, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 129, 1},
|
||||
new byte[] {0, 1, 1, 0},
|
||||
new byte[] {0, 1, 1, 0},
|
||||
new byte[] {1, 1, 0, 0}
|
||||
new byte[4] {128, 0, 129, 1},
|
||||
new byte[4] {0, 1, 1, 0},
|
||||
new byte[4] {0, 1, 1, 0},
|
||||
new byte[4] {1, 1, 0, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 1},
|
||||
new byte[] {0, 1, 1, 1},
|
||||
new byte[] {129, 1, 1, 0},
|
||||
new byte[] {1, 0, 0, 0}
|
||||
new byte[4] {128, 0, 0, 1},
|
||||
new byte[4] {0, 1, 1, 1},
|
||||
new byte[4] {129, 1, 1, 0},
|
||||
new byte[4] {1, 0, 0, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 0, 0},
|
||||
new byte[] {1, 1, 1, 1},
|
||||
new byte[] {129, 1, 1, 1},
|
||||
new byte[] {0, 0, 0, 0}
|
||||
new byte[4] {128, 0, 0, 0},
|
||||
new byte[4] {1, 1, 1, 1},
|
||||
new byte[4] {129, 1, 1, 1},
|
||||
new byte[4] {0, 0, 0, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 1, 129, 1},
|
||||
new byte[] {0, 0, 0, 1},
|
||||
new byte[] {1, 0, 0, 0},
|
||||
new byte[] {1, 1, 1, 0}
|
||||
new byte[4] {128, 1, 129, 1},
|
||||
new byte[4] {0, 0, 0, 1},
|
||||
new byte[4] {1, 0, 0, 0},
|
||||
new byte[4] {1, 1, 1, 0}
|
||||
},
|
||||
new byte[][]
|
||||
new byte[4][]
|
||||
{
|
||||
new byte[] {128, 0, 129, 1},
|
||||
new byte[] {1, 0, 0, 1},
|
||||
new byte[] {1, 0, 0, 1},
|
||||
new byte[] {1, 1, 0, 0}
|
||||
new byte[4] {128, 0, 129, 1},
|
||||
new byte[4] {1, 0, 0, 1},
|
||||
new byte[4] {1, 0, 0, 1},
|
||||
new byte[4] {1, 1, 0, 0}
|
||||
}
|
||||
};
|
||||
|
||||
internal static int[] AWeight3 = { 0, 9, 18, 27, 37, 46, 55, 64 };
|
||||
internal static int[] AWeight3 { get; } = new int[8] { 0, 9, 18, 27, 37, 46, 55, 64 };
|
||||
|
||||
internal static int[] AWeight4 = { 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 };
|
||||
internal static int[] AWeight4 { get; } = new int[16] { 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 };
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Bc;
|
||||
|
||||
public static class Bc7
|
||||
{
|
||||
internal const int BlockSize = 16;
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return Decompress(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int Decompress(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int outputOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRGBA32>();
|
||||
BcHelpers.DecompressBc7(
|
||||
input.Slice(inputOffset, BlockSize),
|
||||
output.Slice(outputOffset),
|
||||
width * 4);
|
||||
inputOffset += BlockSize;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(output, width, height, output);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
internal static int GetCompressedSize(int w, int h) => ((w) >> 2) * ((h) >> 2) * BlockSize;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,191 +0,0 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Bc
|
||||
{
|
||||
public static class BcDecoder
|
||||
{
|
||||
public static int DecompressBC1(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return DecompressBC1(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int DecompressBC1(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int outputOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRGBA32>();
|
||||
BcHelpers.DecompressBc1(input.Slice(inputOffset, DefineConstants.BCDEC_BC1_BLOCK_SIZE), output.Slice(outputOffset), width * 4);
|
||||
inputOffset += DefineConstants.BCDEC_BC1_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(output, width, height, output);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
public static int DecompressBC2(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return DecompressBC2(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int DecompressBC2(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int outputOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRGBA32>();
|
||||
BcHelpers.DecompressBc2(input.Slice(inputOffset), output.Slice(outputOffset), width * 4);
|
||||
inputOffset += DefineConstants.BCDEC_BC2_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(output, width, height, output);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
public static int DecompressBC3(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return DecompressBC3(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int DecompressBC3(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int outputOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRGBA32>();
|
||||
BcHelpers.DecompressBc3(input.Slice(inputOffset), output.Slice(outputOffset), width * 4);
|
||||
inputOffset += DefineConstants.BCDEC_BC3_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(output, width, height, output);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
public static int DecompressBC4(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return DecompressBC4(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int DecompressBC4(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
Span<byte> buffer = new byte[width * height * Unsafe.SizeOf<ColorR8>()];
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int bufferOffset = ((i * width) + j) * Unsafe.SizeOf<ColorR8>();
|
||||
BcHelpers.DecompressBc4(input.Slice(inputOffset), buffer.Slice(bufferOffset), width);
|
||||
inputOffset += DefineConstants.BCDEC_BC4_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorR8, byte, ColorBGRA32, byte>(buffer, width, height, output);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
public static int DecompressBC5(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return DecompressBC5(input, width, height, output);
|
||||
}
|
||||
|
||||
public static int DecompressBC5(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
Span<byte> buffer = new byte[width * height * Unsafe.SizeOf<ColorRG16>()];
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int bufferOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRG16>();
|
||||
BcHelpers.DecompressBc5(input.Slice(inputOffset), buffer.Slice(bufferOffset), width * 2);
|
||||
inputOffset += DefineConstants.BCDEC_BC5_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRG16, byte, ColorBGRA32, byte>(buffer, width, height, output);
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
public static int DecompressBC6H(ReadOnlySpan<byte> input, int width, int height, bool isSigned, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return DecompressBC6H(input, width, height, isSigned, output);
|
||||
}
|
||||
|
||||
public unsafe static int DecompressBC6H(ReadOnlySpan<byte> input, int width, int height, bool isSigned, Span<byte> output)
|
||||
{
|
||||
int bytesRead;
|
||||
byte[] buffer = new byte[width * height * Unsafe.SizeOf<ColorRGBSingle>()];
|
||||
fixed (byte* inputPtr = input)
|
||||
{
|
||||
fixed (byte* bufferPtr = buffer)
|
||||
{
|
||||
bytesRead = DecompressBC6H(inputPtr, width, height, isSigned, bufferPtr);
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRGBSingle, float, ColorBGRA32, byte>(buffer, width, height, output);
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
private unsafe static int DecompressBC6H(byte* input, int width, int height, bool isSigned, byte* output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int outputOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRGBSingle>();
|
||||
BcHelpers.DecompressBc6h_Float(input + inputOffset, output + outputOffset, width * 3, isSigned ? 1 : 0);
|
||||
inputOffset += DefineConstants.BCDEC_BC6H_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
return inputOffset;
|
||||
}
|
||||
|
||||
public static int DecompressBC7(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * Unsafe.SizeOf<ColorBGRA32>()];
|
||||
return DecompressBC7(input, width, height, output);
|
||||
}
|
||||
|
||||
public unsafe static int DecompressBC7(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int bytesRead;
|
||||
fixed (byte* inputPtr = input)
|
||||
{
|
||||
fixed (byte* outputPtr = output)
|
||||
{
|
||||
bytesRead = DecompressBC7(inputPtr, width, height, outputPtr);
|
||||
}
|
||||
}
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(output, width, height, output);
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
private unsafe static int DecompressBC7(byte* input, int width, int height, byte* output)
|
||||
{
|
||||
int inputOffset = 0;
|
||||
for (int i = 0; i < height; i += 4)
|
||||
{
|
||||
for (int j = 0; j < width; j += 4)
|
||||
{
|
||||
int outputOffset = ((i * width) + j) * Unsafe.SizeOf<ColorRGBA32>();
|
||||
BcHelpers.DecompressBc7(input + inputOffset, output + outputOffset, width * 4);
|
||||
inputOffset += DefineConstants.BCDEC_BC7_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
return inputOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -8,11 +8,11 @@ internal struct BitStream
|
||||
public int ReadBits(int numBits)
|
||||
{
|
||||
uint mask = (uint)((1 << numBits) - 1);
|
||||
/* Read the low N bits */
|
||||
// Read the low N bits
|
||||
uint bits = (uint)(this.low & mask);
|
||||
|
||||
this.low >>= numBits;
|
||||
/* Put the low N bits of "high" into the high 64-N bits of "low". */
|
||||
// Put the low N bits of "high" into the high 64-N bits of "low".
|
||||
this.low |= (this.high & mask) << ((sizeof(ulong) * 8) - numBits);
|
||||
this.high >>= numBits;
|
||||
|
||||
@@ -32,7 +32,7 @@ internal struct BitStream
|
||||
public int ReadBitsReversed(int numBits)
|
||||
{
|
||||
int bits = this.ReadBits(numBits);
|
||||
/* Reverse the bits. */
|
||||
// Reverse the bits.
|
||||
int result = 0;
|
||||
while (numBits-- != 0)
|
||||
{
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.Bc;
|
||||
|
||||
internal static class DefineConstants
|
||||
{
|
||||
public const int BCDEC_BC1_BLOCK_SIZE = 8;
|
||||
public const int BCDEC_BC2_BLOCK_SIZE = 16;
|
||||
public const int BCDEC_BC3_BLOCK_SIZE = 16;
|
||||
public const int BCDEC_BC4_BLOCK_SIZE = 8;
|
||||
public const int BCDEC_BC5_BLOCK_SIZE = 16;
|
||||
public const int BCDEC_BC6H_BLOCK_SIZE = 16;
|
||||
public const int BCDEC_BC7_BLOCK_SIZE = 16;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Bc;
|
||||
|
||||
/// <summary>
|
||||
/// Union between uint and float
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal struct FP32
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public uint u;
|
||||
[FieldOffset(0)]
|
||||
public float f;
|
||||
}
|
||||
@@ -409,12 +409,14 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
/// <summary>
|
||||
/// Parses an 8-byte Etc1 block from <paramref name="input"/>.
|
||||
/// </summary>
|
||||
private unsafe static void DecodeEtc1Block(ReadOnlySpan<byte> input, Span<uint> output)
|
||||
private static void DecodeEtc1Block(ReadOnlySpan<byte> input, Span<uint> output)
|
||||
{
|
||||
byte i3 = input[3];
|
||||
Span<int> code = stackalloc int[2];
|
||||
code[0] = (i3 >> 5) * 4;
|
||||
code[1] = (i3 >> 2 & 7) * 4;
|
||||
ReadOnlySpan<int> code = stackalloc int[2]
|
||||
{
|
||||
(i3 >> 5) * 4,
|
||||
(i3 >> 2 & 7) * 4
|
||||
};
|
||||
Span<byte> c = stackalloc byte[6];
|
||||
int ti = (i3 & 1) * 16;
|
||||
if ((i3 & 2) != 0)
|
||||
@@ -462,7 +464,7 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe static void DecodeEtc2Block(ReadOnlySpan<byte> input, Span<uint> output)
|
||||
private static void DecodeEtc2Block(ReadOnlySpan<byte> input, Span<uint> output)
|
||||
{
|
||||
int j = input[6] << 8 | input[7];
|
||||
int k = input[4] << 8 | input[5];
|
||||
@@ -567,9 +569,9 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
{
|
||||
for (int x = 0; x < 4; x++, i++)
|
||||
{
|
||||
int ri = Clamp255((x * (c[1 * 3 + 0] - c[0 * 3 + 0]) + y * (c[2 * 3 + 0] - c[0 * 3 + 0]) + 4 * c[0 * 3 + 0] + 2) >> 2);
|
||||
int gi = Clamp255((x * (c[1 * 3 + 1] - c[0 * 3 + 1]) + y * (c[2 * 3 + 1] - c[0 * 3 + 1]) + 4 * c[0 * 3 + 1] + 2) >> 2);
|
||||
int bi = Clamp255((x * (c[1 * 3 + 2] - c[0 * 3 + 2]) + y * (c[2 * 3 + 2] - c[0 * 3 + 2]) + 4 * c[0 * 3 + 2] + 2) >> 2);
|
||||
byte ri = Clamp255((x * (c[1 * 3 + 0] - c[0 * 3 + 0]) + y * (c[2 * 3 + 0] - c[0 * 3 + 0]) + 4 * c[0 * 3 + 0] + 2) >> 2);
|
||||
byte gi = Clamp255((x * (c[1 * 3 + 1] - c[0 * 3 + 1]) + y * (c[2 * 3 + 1] - c[0 * 3 + 1]) + 4 * c[0 * 3 + 1] + 2) >> 2);
|
||||
byte bi = Clamp255((x * (c[1 * 3 + 2] - c[0 * 3 + 2]) + y * (c[2 * 3 + 2] - c[0 * 3 + 2]) + 4 * c[0 * 3 + 2] + 2) >> 2);
|
||||
output[i] = Color(ri, gi, bi, 255);
|
||||
}
|
||||
}
|
||||
@@ -610,9 +612,11 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
else
|
||||
{
|
||||
// individual
|
||||
Span<int> code = stackalloc int[2];
|
||||
code[0] = (input[3] >> 5) * 4;
|
||||
code[1] = (input[3] >> 2 & 7) * 4;
|
||||
ReadOnlySpan<int> code = stackalloc int[2]
|
||||
{
|
||||
(input[3] >> 5) * 4,
|
||||
(input[3] >> 2 & 7) * 4
|
||||
};
|
||||
int ti = (input[3] & 1) * 16;
|
||||
unchecked
|
||||
{
|
||||
@@ -637,7 +641,7 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private unsafe static void DecodeEtc2a1Block(ReadOnlySpan<byte> input, Span<uint> output)
|
||||
private static void DecodeEtc2a1Block(ReadOnlySpan<byte> input, Span<uint> output)
|
||||
{
|
||||
if ((input[3] & 2) != 0)
|
||||
{
|
||||
@@ -650,7 +654,7 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe static void DecodeEtc2PunchThrowBlock(ReadOnlySpan<byte> input, Span<uint> output)
|
||||
private static void DecodeEtc2PunchThrowBlock(ReadOnlySpan<byte> input, Span<uint> output)
|
||||
{
|
||||
int j = input[6] << 8 | input[7];
|
||||
int k = input[4] << 8 | input[5];
|
||||
@@ -671,7 +675,7 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
}
|
||||
int ti = input[3] >> 1 & 6 | input[3] & 1;
|
||||
byte d = Etc2DistanceTable[ti];
|
||||
uint* color_set = stackalloc uint[]
|
||||
ReadOnlySpan<uint> color_set = stackalloc uint[4]
|
||||
{
|
||||
ApplicateColorRaw(c, 0),
|
||||
ApplicateColor(c, 1, d),
|
||||
@@ -713,7 +717,7 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
++di;
|
||||
}
|
||||
byte d = Etc2DistanceTable[di];
|
||||
uint* color_set = stackalloc uint[]
|
||||
ReadOnlySpan<uint> color_set = stackalloc uint[4]
|
||||
{
|
||||
ApplicateColor(c, 0, d),
|
||||
ApplicateColor(c, 0, -d),
|
||||
@@ -754,9 +758,9 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
{
|
||||
for (int x = 0; x < 4; x++, i++)
|
||||
{
|
||||
int ri = Clamp255((x * (c[1 * 3 + 0] - c[0 * 3 + 0]) + y * (c[2 * 3 + 0] - c[0 * 3 + 0]) + 4 * c[0 * 3 + 0] + 2) >> 2);
|
||||
int gi = Clamp255((x * (c[1 * 3 + 1] - c[0 * 3 + 1]) + y * (c[2 * 3 + 1] - c[0 * 3 + 1]) + 4 * c[0 * 3 + 1] + 2) >> 2);
|
||||
int bi = Clamp255((x * (c[1 * 3 + 2] - c[0 * 3 + 2]) + y * (c[2 * 3 + 2] - c[0 * 3 + 2]) + 4 * c[0 * 3 + 2] + 2) >> 2);
|
||||
byte ri = Clamp255((x * (c[1 * 3 + 0] - c[0 * 3 + 0]) + y * (c[2 * 3 + 0] - c[0 * 3 + 0]) + 4 * c[0 * 3 + 0] + 2) >> 2);
|
||||
byte gi = Clamp255((x * (c[1 * 3 + 1] - c[0 * 3 + 1]) + y * (c[2 * 3 + 1] - c[0 * 3 + 1]) + 4 * c[0 * 3 + 1] + 2) >> 2);
|
||||
byte bi = Clamp255((x * (c[1 * 3 + 2] - c[0 * 3 + 2]) + y * (c[2 * 3 + 2] - c[0 * 3 + 2]) + 4 * c[0 * 3 + 2] + 2) >> 2);
|
||||
output[i] = Color(ri, gi, bi, 255);
|
||||
}
|
||||
}
|
||||
@@ -764,9 +768,11 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
else
|
||||
{
|
||||
// differential (Etc1Block + mask + specific mod table)
|
||||
int* code = stackalloc int[2];
|
||||
code[0] = (input[3] >> 5) * 4;
|
||||
code[1] = (input[3] >> 2 & 7) * 4;
|
||||
ReadOnlySpan<int> code = stackalloc int[2]
|
||||
{
|
||||
(input[3] >> 5) * 4,
|
||||
(input[3] >> 2 & 7) * 4
|
||||
};
|
||||
int ti = (input[3] & 1) * 16;
|
||||
unchecked
|
||||
{
|
||||
@@ -796,7 +802,7 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe static void DecodeEtc2a8Block(ReadOnlySpan<byte> input, Span<uint> output)
|
||||
private static void DecodeEtc2a8Block(ReadOnlySpan<byte> input, Span<uint> output)
|
||||
{
|
||||
int @base = input[0];
|
||||
int data1 = input[1];
|
||||
@@ -816,7 +822,7 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe static void DecodeEacUnsignedBlock(ReadOnlySpan<byte> input, Span<uint> output, int channel)
|
||||
private static void DecodeEacUnsignedBlock(ReadOnlySpan<byte> input, Span<uint> output, int channel)
|
||||
{
|
||||
int @base = input[0];
|
||||
int data1 = input[1];
|
||||
@@ -833,7 +839,7 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe static void DecodeEacSignedBlock(ReadOnlySpan<byte> input, Span<uint> output, int channel)
|
||||
private static void DecodeEacSignedBlock(ReadOnlySpan<byte> input, Span<uint> output, int channel)
|
||||
{
|
||||
int @base = 127 + unchecked((sbyte)input[0]);
|
||||
int data1 = input[1];
|
||||
@@ -851,7 +857,7 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private unsafe static void DecodeEac11Block(Span<byte> output, int @base)
|
||||
private static void DecodeEac11Block(Span<byte> output, int @base)
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
@@ -860,15 +866,13 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private unsafe static void DecodeEac11Block(Span<byte> output, int @base, int ti, int mul, ulong l)
|
||||
private static void DecodeEac11Block(Span<byte> output, int @base, int ti, int mul, ulong l)
|
||||
{
|
||||
fixed (sbyte* table = &Etc2AlphaModTable[ti * 8])
|
||||
ReadOnlySpan<sbyte> table = Etc2AlphaModTable.AsSpan(ti * 8, 8);
|
||||
for (int i = 0; i < 16; i++, l >>= 3)
|
||||
{
|
||||
for (int i = 0; i < 16; i++, l >>= 3)
|
||||
{
|
||||
int val = @base + mul * table[l & 7];
|
||||
output[WriteOrderTableRev[i] * 4] = (byte)(Clamp255(val));
|
||||
}
|
||||
int val = @base + mul * table[unchecked((int)(l & 0b111))];
|
||||
output[WriteOrderTableRev[i] * 4] = Clamp255(val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -879,31 +883,31 @@ namespace AssetRipper.TextureDecoder.Etc
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static int Clamp255(int n)
|
||||
private static byte Clamp255(int n)
|
||||
{
|
||||
return n < 0 ? 0 : n > 255 ? 255 : n;
|
||||
return n < 0 ? (byte)0 : n > 255 ? (byte)255 : unchecked((byte)n);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private unsafe static uint ApplicateColor(ReadOnlySpan<byte> c, int o, int m)
|
||||
private static uint ApplicateColor(ReadOnlySpan<byte> c, int o, int m)
|
||||
{
|
||||
return Color(Clamp255(c[o * 3 + 0] + m), Clamp255(c[o * 3 + 1] + m), Clamp255(c[o * 3 + 2] + m), 255);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private unsafe static uint ApplicateColor(ReadOnlySpan<int> c, int o, int m)
|
||||
private static uint ApplicateColor(ReadOnlySpan<int> c, int o, int m)
|
||||
{
|
||||
return Color(Clamp255(c[o * 3 + 0] + m), Clamp255(c[o * 3 + 1] + m), Clamp255(c[o * 3 + 2] + m), 255);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private unsafe static uint ApplicateColorRaw(ReadOnlySpan<byte> c, int o)
|
||||
private static uint ApplicateColorRaw(ReadOnlySpan<byte> c, int o)
|
||||
{
|
||||
return Color(c[o * 3 + 0], c[o * 3 + 1], c[o * 3 + 2], 255);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private unsafe static ulong Get6SwapedBytes(ReadOnlySpan<byte> data)
|
||||
private static ulong Get6SwapedBytes(ReadOnlySpan<byte> data)
|
||||
{
|
||||
return data[7] | (uint)data[6] << 8 | (uint)data[5] << 16 | (uint)data[4] << 24 | (ulong)data[3] << 32 | (ulong)data[2] << 40;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,20 @@
|
||||
{
|
||||
return Unsafe.As<TFrom, TTo>(ref value);
|
||||
}
|
||||
else if (typeof(TFrom) == typeof(sbyte))
|
||||
{
|
||||
byte converted = ChangeSign(Unsafe.As<TFrom, sbyte>(ref value));
|
||||
return ConvertUInt8<TTo>(converted);
|
||||
}
|
||||
else if(typeof(TFrom) == typeof(byte))
|
||||
{
|
||||
return ConvertUInt8<TTo>(Unsafe.As<TFrom, byte>(ref value));
|
||||
}
|
||||
else if (typeof(TFrom) == typeof(short))
|
||||
{
|
||||
ushort converted = ChangeSign(Unsafe.As<TFrom, short>(ref value));
|
||||
return ConvertUInt16<TTo>(converted);
|
||||
}
|
||||
else if (typeof(TFrom) == typeof(ushort))
|
||||
{
|
||||
return ConvertUInt16<TTo>(Unsafe.As<TFrom, ushort>(ref value));
|
||||
@@ -33,20 +43,30 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
return default; //exceptions prevent inlining
|
||||
return ThrowOrReturnDefault<TTo>();
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static TTo ConvertUInt8<TTo>(byte value) where TTo : unmanaged
|
||||
{
|
||||
if (typeof(TTo) == typeof(byte))
|
||||
if (typeof(TTo) == typeof(sbyte))
|
||||
{
|
||||
sbyte converted = ChangeSign(value);
|
||||
return Unsafe.As<sbyte, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(byte))
|
||||
{
|
||||
return Unsafe.As<byte, TTo>(ref value);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(short))
|
||||
{
|
||||
short converted = ChangeSign(ConvertUInt8ToUInt16(value));
|
||||
return Unsafe.As<short, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(ushort))
|
||||
{
|
||||
ushort converted = unchecked((ushort)((uint)value << 8));
|
||||
ushort converted = ConvertUInt8ToUInt16(value);
|
||||
return Unsafe.As<ushort, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(Half))
|
||||
@@ -66,18 +86,34 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
return default; //exceptions prevent inlining
|
||||
return ThrowOrReturnDefault<TTo>();
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
static ushort ConvertUInt8ToUInt16(byte value)
|
||||
{
|
||||
return unchecked((ushort)(((uint)value << 8) | value));//See https://github.com/AssetRipper/TextureDecoder/issues/19
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static TTo ConvertUInt16<TTo>(ushort value) where TTo : unmanaged
|
||||
{
|
||||
if (typeof(TTo) == typeof(byte))
|
||||
if (typeof(TTo) == typeof(sbyte))
|
||||
{
|
||||
byte converted = unchecked((byte)((uint)value >> 8));
|
||||
sbyte converted = ChangeSign(ConvertUInt16ToUInt8(value));
|
||||
return Unsafe.As<sbyte, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(byte))
|
||||
{
|
||||
byte converted = ConvertUInt16ToUInt8(value);
|
||||
return Unsafe.As<byte, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(short))
|
||||
{
|
||||
short converted = ChangeSign(value);
|
||||
return Unsafe.As<short, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(ushort))
|
||||
{
|
||||
return Unsafe.As<ushort, TTo>(ref value);
|
||||
@@ -99,18 +135,35 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
return default; //exceptions prevent inlining
|
||||
return ThrowOrReturnDefault<TTo>();
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
static byte ConvertUInt16ToUInt8(ushort value)
|
||||
{
|
||||
uint result = (value * 255u + 32895u) >> 16;//See https://github.com/AssetRipper/TextureDecoder/issues/19
|
||||
return unchecked((byte)result);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static TTo ConvertHalf<TTo>(Half value) where TTo : unmanaged
|
||||
{
|
||||
if (typeof(TTo) == typeof(byte))
|
||||
if (typeof(TTo) == typeof(sbyte))
|
||||
{
|
||||
sbyte converted = ChangeSign(ClampUInt8((float)value * byte.MaxValue));
|
||||
return Unsafe.As<sbyte, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(byte))
|
||||
{
|
||||
byte converted = ClampUInt8((float)value * byte.MaxValue);
|
||||
return Unsafe.As<byte, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(short))
|
||||
{
|
||||
short converted = ChangeSign(ClampUInt16((float)value * ushort.MaxValue));
|
||||
return Unsafe.As<short, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(ushort))
|
||||
{
|
||||
ushort converted = ClampUInt16((float)value * ushort.MaxValue);
|
||||
@@ -132,18 +185,28 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
return default; //exceptions prevent inlining
|
||||
return ThrowOrReturnDefault<TTo>();
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static TTo ConvertSingle<TTo>(float value) where TTo : unmanaged
|
||||
{
|
||||
if (typeof(TTo) == typeof(byte))
|
||||
if (typeof(TTo) == typeof(sbyte))
|
||||
{
|
||||
sbyte converted = ChangeSign(ClampUInt8(value * byte.MaxValue));
|
||||
return Unsafe.As<sbyte, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(byte))
|
||||
{
|
||||
byte converted = ClampUInt8(value * byte.MaxValue);
|
||||
return Unsafe.As<byte, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(short))
|
||||
{
|
||||
short converted = ChangeSign(ClampUInt16(value * ushort.MaxValue));
|
||||
return Unsafe.As<short, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(ushort))
|
||||
{
|
||||
ushort converted = ClampUInt16(value * ushort.MaxValue);
|
||||
@@ -165,18 +228,28 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
return default; //exceptions prevent inlining
|
||||
return ThrowOrReturnDefault<TTo>();
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static TTo ConvertDouble<TTo>(double value) where TTo : unmanaged
|
||||
{
|
||||
if (typeof(TTo) == typeof(byte))
|
||||
if (typeof(TTo) == typeof(sbyte))
|
||||
{
|
||||
sbyte converted = ChangeSign(ClampUInt8(value * byte.MaxValue));
|
||||
return Unsafe.As<sbyte, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(byte))
|
||||
{
|
||||
byte converted = ClampUInt8(value * byte.MaxValue);
|
||||
return Unsafe.As<byte, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(short))
|
||||
{
|
||||
short converted = ChangeSign(ClampUInt16(value * ushort.MaxValue));
|
||||
return Unsafe.As<short, TTo>(ref converted);
|
||||
}
|
||||
else if (typeof(TTo) == typeof(ushort))
|
||||
{
|
||||
ushort converted = ClampUInt16(value * ushort.MaxValue);
|
||||
@@ -198,10 +271,20 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
return default; //exceptions prevent inlining
|
||||
return ThrowOrReturnDefault<TTo>();
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static T ThrowOrReturnDefault<T>() where T : unmanaged
|
||||
{
|
||||
#if DEBUG
|
||||
throw new InvalidCastException();
|
||||
#else
|
||||
return default; //exceptions prevent inlining
|
||||
#endif
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static byte ClampUInt8(float x)
|
||||
{
|
||||
@@ -225,5 +308,45 @@
|
||||
{
|
||||
return ushort.MaxValue < x ? ushort.MaxValue : (x > ushort.MinValue ? (ushort)x : ushort.MinValue);
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static byte ChangeSign(sbyte x)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
const uint SignBit = 0x80;
|
||||
return (byte)((uint)x ^ SignBit);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static sbyte ChangeSign(byte x)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
const uint SignBit = 0x80;
|
||||
return (sbyte)(x ^ SignBit);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static ushort ChangeSign(short x)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
const uint SignBit = 0x8000;
|
||||
return (ushort)((uint)x ^ SignBit);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
private static short ChangeSign(ushort x)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
const uint SignBit = 0x8000;
|
||||
return (short)(x ^ SignBit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public struct ColorA8 : IColor<byte>
|
||||
{
|
||||
public byte R
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
public byte G
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
public byte B
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
public byte A { get; set; }
|
||||
|
||||
public 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = false, GreenChannel = false, BlueChannel = false, AlphaChannel = true, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorA8 : IColor<byte>
|
||||
{
|
||||
public byte R
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public byte G
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public byte B
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public byte A { get; set; }
|
||||
|
||||
public void GetChannels(out byte r, out byte g, out byte b, out byte a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(byte r, byte g, byte b, byte a)
|
||||
{
|
||||
A = a;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,32 @@
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public struct ColorARGB16 : IColor<byte>
|
||||
public partial struct ColorARGB16 : IColor<byte>
|
||||
{
|
||||
private byte gb;
|
||||
private byte ar;
|
||||
private UInt4Pair gb;
|
||||
private UInt4Pair ar;
|
||||
|
||||
public byte B
|
||||
{
|
||||
get => unchecked((byte)((uint)gb << 4));
|
||||
set => gb = unchecked((byte)(((uint)value >> 4) | (gb & 0xF0u)));
|
||||
get => gb.LowValue;
|
||||
set => gb.LowValue = value;
|
||||
}
|
||||
|
||||
public byte G
|
||||
{
|
||||
get => (byte)(gb & 0xF0);
|
||||
set => gb = (byte)((value & 0xF0u) | (gb & 0x0Fu));
|
||||
get => gb.HighValue;
|
||||
set => gb.HighValue = value;
|
||||
}
|
||||
|
||||
public byte R
|
||||
{
|
||||
get => unchecked((byte)(ar << 4));
|
||||
set => ar = unchecked((byte)(((uint)value >> 4) | (ar & 0xF0u)));
|
||||
get => ar.LowValue;
|
||||
set => ar.LowValue = value;
|
||||
}
|
||||
|
||||
public byte A
|
||||
{
|
||||
get => (byte)(ar & 0xF0);
|
||||
set => ar = (byte)((value & 0xF0u) | (ar & 0x0Fu));
|
||||
get => ar.HighValue;
|
||||
set => ar.HighValue = value;
|
||||
}
|
||||
|
||||
public void GetChannels(out byte r, out byte g, out byte b, out byte a)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = true, BlueChannel = true, AlphaChannel = true, FullyUtilizedChannels = false)]
|
||||
public partial struct ColorARGB16 : IColor<byte>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public struct ColorARGB32 : IColor<byte>
|
||||
public partial struct ColorARGB32 : IColor<byte>
|
||||
{
|
||||
public byte A { get; set; }
|
||||
public byte R { get; set; }
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = true, BlueChannel = true, AlphaChannel = true, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorARGB32 : IColor<byte>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public struct ColorBGRA32 : IColor<byte>
|
||||
public partial struct ColorBGRA32 : IColor<byte>
|
||||
{
|
||||
public byte B { get; set; }
|
||||
public byte G { get; set; }
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = true, BlueChannel = true, AlphaChannel = true, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorBGRA32 : IColor<byte>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public struct ColorR16 : IColor<ushort>
|
||||
{
|
||||
public ushort R { get; set; }
|
||||
public ushort G
|
||||
{
|
||||
get => ushort.MinValue;
|
||||
set { }
|
||||
}
|
||||
public ushort B
|
||||
{
|
||||
get => ushort.MinValue;
|
||||
set { }
|
||||
}
|
||||
public ushort A
|
||||
{
|
||||
get => ushort.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out ushort r, out ushort g, out ushort b, out ushort a)
|
||||
{
|
||||
DefaultColorMethods.GetChannels(this, out r, out g, out b, out a);
|
||||
}
|
||||
|
||||
public void SetChannels(ushort r, ushort g, ushort b, ushort a)
|
||||
{
|
||||
DefaultColorMethods.SetChannels(ref this, r, g, b, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = false, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorR16 : IColor<ushort>
|
||||
{
|
||||
public ushort R { get; set; }
|
||||
|
||||
public ushort G
|
||||
{
|
||||
get => ushort.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public ushort B
|
||||
{
|
||||
get => ushort.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public ushort A
|
||||
{
|
||||
get => ushort.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out ushort r, out ushort g, out ushort b, out ushort a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(ushort r, ushort g, ushort b, ushort a)
|
||||
{
|
||||
R = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = false, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorR16Half : IColor<Half>
|
||||
{
|
||||
public Half R { get; set; }
|
||||
|
||||
public Half G
|
||||
{
|
||||
get => default;
|
||||
set { }
|
||||
}
|
||||
|
||||
public Half B
|
||||
{
|
||||
get => default;
|
||||
set { }
|
||||
}
|
||||
|
||||
public Half A
|
||||
{
|
||||
get => HalfConstants.One;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out Half r, out Half g, out Half b, out Half a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(Half r, Half g, Half b, Half a)
|
||||
{
|
||||
R = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = false, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorR16Signed : IColor<short>
|
||||
{
|
||||
public short R { get; set; }
|
||||
|
||||
public short G
|
||||
{
|
||||
get => short.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public short B
|
||||
{
|
||||
get => short.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public short A
|
||||
{
|
||||
get => short.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out short r, out short g, out short b, out short a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(short r, short g, short b, short a)
|
||||
{
|
||||
R = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = false, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorR32Single : IColor<float>
|
||||
{
|
||||
public float R { get; set; }
|
||||
|
||||
public float G
|
||||
{
|
||||
get => 0f;
|
||||
set { }
|
||||
}
|
||||
|
||||
public float B
|
||||
{
|
||||
get => 0f;
|
||||
set { }
|
||||
}
|
||||
|
||||
public float A
|
||||
{
|
||||
get => 1f;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out float r, out float g, out float b, out float a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(float r, float g, float b, float a)
|
||||
{
|
||||
R = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = false, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorR64Double : IColor<double>
|
||||
{
|
||||
public double R { get; set; }
|
||||
|
||||
public double G
|
||||
{
|
||||
get => 0d;
|
||||
set { }
|
||||
}
|
||||
|
||||
public double B
|
||||
{
|
||||
get => 0d;
|
||||
set { }
|
||||
}
|
||||
|
||||
public double A
|
||||
{
|
||||
get => 1d;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out double r, out double g, out double b, out double a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(double r, double g, double b, double a)
|
||||
{
|
||||
R = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public struct ColorR8 : IColor<byte>
|
||||
{
|
||||
public byte R { get; set; }
|
||||
public byte G
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
public byte B
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
public byte A
|
||||
{
|
||||
get => byte.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = false, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorR8 : IColor<byte>
|
||||
{
|
||||
public byte R { get; set; }
|
||||
|
||||
public byte G
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public byte B
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public byte A
|
||||
{
|
||||
get => byte.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out byte r, out byte g, out byte b, out byte a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(byte r, byte g, byte b, byte a)
|
||||
{
|
||||
R = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = false, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorR8Signed : IColor<sbyte>
|
||||
{
|
||||
public sbyte R { get; set; }
|
||||
|
||||
public sbyte G
|
||||
{
|
||||
get => sbyte.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public sbyte B
|
||||
{
|
||||
get => sbyte.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public sbyte A
|
||||
{
|
||||
get => sbyte.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out sbyte r, out sbyte g, out sbyte b, out sbyte a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(sbyte r, sbyte g, sbyte b, sbyte a)
|
||||
{
|
||||
R = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = true, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorRG128Double : IColor<double>
|
||||
{
|
||||
public double R { get; set; }
|
||||
|
||||
public double G { get; set; }
|
||||
|
||||
public double B
|
||||
{
|
||||
get => 0d;
|
||||
set { }
|
||||
}
|
||||
|
||||
public double A
|
||||
{
|
||||
get => 1d;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out double r, out double g, out double b, out double a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(double r, double g, double b, double a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public struct ColorRG16 : IColor<byte>
|
||||
{
|
||||
public byte R { get; set; }
|
||||
public byte G { get; set; }
|
||||
public byte B
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
public byte A
|
||||
{
|
||||
get => byte.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = true, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorRG16 : IColor<byte>
|
||||
{
|
||||
public byte R { get; set; }
|
||||
|
||||
public byte G { get; set; }
|
||||
|
||||
public byte B
|
||||
{
|
||||
get => byte.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public byte A
|
||||
{
|
||||
get => byte.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out byte r, out byte g, out byte b, out byte a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(byte r, byte g, byte b, byte a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = true, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorRG16Signed : IColor<sbyte>
|
||||
{
|
||||
public sbyte R { get; set; }
|
||||
|
||||
public sbyte G { get; set; }
|
||||
|
||||
public sbyte B
|
||||
{
|
||||
get => sbyte.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public sbyte A
|
||||
{
|
||||
get => sbyte.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out sbyte r, out sbyte g, out sbyte b, out sbyte a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(sbyte r, sbyte g, sbyte b, sbyte a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
public struct ColorRG32 : IColor<ushort>
|
||||
{
|
||||
public ushort R { get; set; }
|
||||
public ushort G { get; set; }
|
||||
public ushort B
|
||||
{
|
||||
get => ushort.MinValue;
|
||||
set { }
|
||||
}
|
||||
public ushort A
|
||||
{
|
||||
get => ushort.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out ushort r, out ushort g, out ushort b, out ushort a)
|
||||
{
|
||||
DefaultColorMethods.GetChannels(this, out r, out g, out b, out a);
|
||||
}
|
||||
|
||||
public void SetChannels(ushort r, ushort g, ushort b, ushort a)
|
||||
{
|
||||
DefaultColorMethods.SetChannels(ref this, r, g, b, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = true, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorRG32 : IColor<ushort>
|
||||
{
|
||||
public ushort R { get; set; }
|
||||
|
||||
public ushort G { get; set; }
|
||||
|
||||
public ushort B
|
||||
{
|
||||
get => ushort.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public ushort A
|
||||
{
|
||||
get => ushort.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out ushort r, out ushort g, out ushort b, out ushort a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(ushort r, ushort g, ushort b, ushort a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = true, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorRG32Half : IColor<Half>
|
||||
{
|
||||
public Half R { get; set; }
|
||||
|
||||
public Half G { get; set; }
|
||||
|
||||
public Half B
|
||||
{
|
||||
get => default;
|
||||
set { }
|
||||
}
|
||||
|
||||
public Half A
|
||||
{
|
||||
get => HalfConstants.One;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out Half r, out Half g, out Half b, out Half a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(Half r, Half g, Half b, Half a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = true, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorRG32Signed : IColor<short>
|
||||
{
|
||||
public short R { get; set; }
|
||||
|
||||
public short G { get; set; }
|
||||
|
||||
public short B
|
||||
{
|
||||
get => short.MinValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public short A
|
||||
{
|
||||
get => short.MaxValue;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out short r, out short g, out short b, out short a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(short r, short g, short b, short a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Rgb.Formats
|
||||
{
|
||||
[RgbaAttribute(RedChannel = true, GreenChannel = true, BlueChannel = false, AlphaChannel = false, FullyUtilizedChannels = true)]
|
||||
public partial struct ColorRG64Single : IColor<float>
|
||||
{
|
||||
public float R { get; set; }
|
||||
|
||||
public float G { get; set; }
|
||||
|
||||
public float B
|
||||
{
|
||||
get => 0f;
|
||||
set { }
|
||||
}
|
||||
|
||||
public float A
|
||||
{
|
||||
get => 1f;
|
||||
set { }
|
||||
}
|
||||
|
||||
public void GetChannels(out float r, out float g, out float b, out float a)
|
||||
{
|
||||
r = R;
|
||||
g = G;
|
||||
b = B;
|
||||
a = A;
|
||||
}
|
||||
|
||||
public void SetChannels(float r, float g, float b, float a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 141 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user