mirror of
https://github.com/AssetRipper/AssetRipper.TextureDecoder.git
synced 2026-11-12 18:07:28 -10:00
Compare commits
151
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e41eeb5766 | ||
|
|
a7a12fdd72 | ||
|
|
801edea4cf | ||
|
|
3cb859c6ac | ||
|
|
0738ba4b50 | ||
|
|
09067cecbb | ||
|
|
ec6754a5d2 | ||
|
|
bc4d0f5378 | ||
|
|
8f0f94695b | ||
|
|
aacbfbd222 | ||
|
|
93fe6948b6 | ||
|
|
0e6f3080be | ||
|
|
f8294eff8b | ||
|
|
0b4d1dfc83 | ||
|
|
f5c1aca0e1 | ||
|
|
d4d335d94b | ||
|
|
70775daca9 | ||
|
|
3a94ea1a0f | ||
|
|
db875125d2 | ||
|
|
cdd73752df | ||
|
|
99556c46dd | ||
|
|
c919852137 | ||
|
|
9bca952f2d | ||
|
|
dbfe5b2979 | ||
|
|
168098c29e | ||
|
|
8b493e5650 | ||
|
|
9e60f004df | ||
|
|
324f8eb8f4 | ||
|
|
b39200e3ff | ||
|
|
ed8ffde7d0 | ||
|
|
e70c6d961c | ||
|
|
93ad0eeccf | ||
|
|
b5b6b5aca8 | ||
|
|
2c2f9486f9 | ||
|
|
cd60c44ba5 | ||
|
|
09f605e45d | ||
|
|
40ef1f6989 | ||
|
|
eeffa5897d | ||
|
|
d45e129e46 | ||
|
|
d57e3461ff | ||
|
|
1d2d19c9ef | ||
|
|
f3ba84589d | ||
|
|
7cee390b2e | ||
|
|
024ac9eb8c | ||
|
|
d47fe4dcfb | ||
|
|
7d028ce3f5 | ||
|
|
beb819daa4 | ||
|
|
c9d338f159 | ||
|
|
19b2469595 | ||
|
|
c5a2382733 | ||
|
|
9ce8311e1b | ||
|
|
e39b439ccd | ||
|
|
f2da43bcbb | ||
|
|
128eb58864 | ||
|
|
9f7a61172a | ||
|
|
93c177232f | ||
|
|
8b62957cdb | ||
|
|
95ecf5b1ac | ||
|
|
f8d17ad290 | ||
|
|
f2772dcb83 | ||
|
|
1e363e355e | ||
|
|
8e82e702a7 | ||
|
|
1957784de4 | ||
|
|
1bf5f70ead | ||
|
|
2bb946b26f | ||
|
|
eed528cc68 | ||
|
|
c6d3236770 | ||
|
|
34d8310764 | ||
|
|
e7b9db0dd6 | ||
|
|
1e7ef0c44c | ||
|
|
0f2a6fdec1 | ||
|
|
058a14953f | ||
|
|
94f1a9ab8e | ||
|
|
5953a2baf7 | ||
|
|
4b398e6c94 | ||
|
|
a25a42dbd4 | ||
|
|
e9674d1c39 | ||
|
|
05eaeb81dc | ||
|
|
76a8b2f837 | ||
|
|
c113649b6e | ||
|
|
07002c77ee | ||
|
|
bed45ee60e | ||
|
|
d8918771a9 | ||
|
|
5dba4cdb19 | ||
|
|
b1803e8a35 | ||
|
|
5ec29c6a82 | ||
|
|
c6a1240499 | ||
|
|
12c6750a88 | ||
|
|
5dacd489d0 | ||
|
|
509a567aa5 | ||
|
|
1f1dd55e85 | ||
|
|
5e28554f00 | ||
|
|
d4cd1d5560 | ||
|
|
9ae8296532 | ||
|
|
637a53fc6f | ||
|
|
53f177cae3 | ||
|
|
c57303ff6b | ||
|
|
bd834212ad | ||
|
|
f0bdada27c | ||
|
|
4a386d57d7 | ||
|
|
d96d8e6c35 | ||
|
|
c16bec4431 | ||
|
|
548d5e8aec | ||
|
|
9e21272b2b | ||
|
|
df1ab3c1e4 | ||
|
|
7c30eb44ee | ||
|
|
e32f934043 | ||
|
|
79295aa258 | ||
|
|
b721294e62 | ||
|
|
f3f7b69954 | ||
|
|
6980a32759 | ||
|
|
81e2a38829 | ||
|
|
d496a13d63 | ||
|
|
850f7f335a | ||
|
|
78a8f18375 | ||
|
|
696a677bc3 | ||
|
|
1ef781f072 | ||
|
|
2a41577d28 | ||
|
|
b3371b34d3 | ||
|
|
05c961fcac | ||
|
|
061968eeb8 | ||
|
|
9a02c7149b | ||
|
|
705dc88bbb | ||
|
|
3187e92d6b | ||
|
|
b4863dcae7 | ||
|
|
d416ad0318 | ||
|
|
8220d27370 | ||
|
|
43d7db671e | ||
|
|
6fb2c430af | ||
|
|
14f22a1b28 | ||
|
|
52d6613263 | ||
|
|
301212b278 | ||
|
|
07812e1f48 | ||
|
|
16cdf61406 | ||
|
|
e5da67340b | ||
|
|
750dae931e | ||
|
|
f05609904a | ||
|
|
f90871bd03 | ||
|
|
c578ab204b | ||
|
|
699e437511 | ||
|
|
8b7644d2bf | ||
|
|
aea54da07a | ||
|
|
18a5b27333 | ||
|
|
ddcb97be28 | ||
|
|
959f6584b2 | ||
|
|
8f4390a315 | ||
|
|
ccd0276d99 | ||
|
|
4064c799a7 | ||
|
|
093a810e30 | ||
|
|
20c835e821 | ||
|
|
243caa5bf8 |
No files matched your search
+251
@@ -0,0 +1,251 @@
|
||||
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
|
||||
# Remove the line below if you want to inherit .editorconfig settings from higher directories
|
||||
root = true
|
||||
|
||||
# C# files
|
||||
[*.cs]
|
||||
|
||||
#### Core EditorConfig Options ####
|
||||
|
||||
# Indentation and spacing
|
||||
indent_size = 4
|
||||
indent_style = tab
|
||||
tab_width = 4
|
||||
|
||||
# New line preferences
|
||||
end_of_line = crlf
|
||||
insert_final_newline =true
|
||||
|
||||
#### .NET Coding Conventions ####
|
||||
|
||||
# Organize usings
|
||||
dotnet_separate_import_directive_groups = false
|
||||
dotnet_sort_system_directives_first = false
|
||||
|
||||
# this. and Me. preferences
|
||||
dotnet_style_qualification_for_event = false:silent
|
||||
dotnet_style_qualification_for_field = false:silent
|
||||
dotnet_style_qualification_for_method = false:silent
|
||||
dotnet_style_qualification_for_property = false:silent
|
||||
|
||||
# Language keywords vs BCL types preferences
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||
|
||||
# Parentheses preferences
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
|
||||
|
||||
# Modifier preferences
|
||||
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
|
||||
|
||||
# Expression-level preferences
|
||||
dotnet_style_coalesce_expression = true:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_explicit_tuple_names = true:suggestion
|
||||
dotnet_style_null_propagation = true:suggestion
|
||||
dotnet_style_object_initializer = false:suggestion
|
||||
dotnet_style_prefer_auto_properties = true:suggestion
|
||||
dotnet_style_prefer_compound_assignment = true:suggestion
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = false:silent
|
||||
dotnet_style_prefer_conditional_expression_over_return = false:silent
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
|
||||
dotnet_style_prefer_inferred_tuple_names = true:suggestion
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
|
||||
|
||||
# Field preferences
|
||||
dotnet_style_readonly_field = true:suggestion
|
||||
|
||||
# Parameter preferences
|
||||
dotnet_code_quality_unused_parameters = all:suggestion
|
||||
|
||||
#### C# Coding Conventions ####
|
||||
|
||||
# var preferences
|
||||
csharp_style_var_elsewhere = false:warning
|
||||
csharp_style_var_for_built_in_types = false:warning
|
||||
csharp_style_var_when_type_is_apparent = false:suggestion
|
||||
|
||||
# Expression-bodied members
|
||||
csharp_style_expression_bodied_accessors = true:silent
|
||||
csharp_style_expression_bodied_constructors = false:silent
|
||||
csharp_style_expression_bodied_indexers = true:silent
|
||||
csharp_style_expression_bodied_lambdas = true:silent
|
||||
csharp_style_expression_bodied_local_functions = false:silent
|
||||
csharp_style_expression_bodied_methods = false:silent
|
||||
csharp_style_expression_bodied_operators = false:silent
|
||||
csharp_style_expression_bodied_properties = true:silent
|
||||
|
||||
# Pattern matching preferences
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
|
||||
csharp_style_prefer_switch_expression = true:suggestion
|
||||
|
||||
# Null-checking preferences
|
||||
csharp_style_conditional_delegate_call = true:suggestion
|
||||
|
||||
# Modifier preferences
|
||||
csharp_prefer_static_local_function = true:suggestion
|
||||
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
|
||||
|
||||
# Code-block preferences
|
||||
csharp_prefer_braces = true:suggestion
|
||||
csharp_prefer_simple_using_statement = true:suggestion
|
||||
|
||||
# Expression-level preferences
|
||||
csharp_prefer_simple_default_expression = true:suggestion
|
||||
csharp_style_deconstructed_variable_declaration = true:suggestion
|
||||
csharp_style_inlined_variable_declaration = true:suggestion
|
||||
csharp_style_pattern_local_over_anonymous_function = true:suggestion
|
||||
csharp_style_prefer_index_operator = true:suggestion
|
||||
csharp_style_prefer_range_operator = true:suggestion
|
||||
csharp_style_throw_expression = true:suggestion
|
||||
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
|
||||
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
|
||||
|
||||
# 'using' directive preferences
|
||||
csharp_using_directive_placement = outside_namespace:silent
|
||||
|
||||
#### C# Formatting Rules ####
|
||||
|
||||
# New line preferences
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
|
||||
# Indentation preferences
|
||||
csharp_indent_block_contents = true
|
||||
csharp_indent_braces = false
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_case_contents_when_block = true
|
||||
csharp_indent_labels = one_less_than_current
|
||||
csharp_indent_switch_labels = true
|
||||
|
||||
# Space preferences
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_after_comma = true
|
||||
csharp_space_after_dot = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_after_semicolon_in_for_statement = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_around_declaration_statements = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_before_comma = false
|
||||
csharp_space_before_dot = false
|
||||
csharp_space_before_open_square_brackets = false
|
||||
csharp_space_before_semicolon_in_for_statement = false
|
||||
csharp_space_between_empty_square_brackets = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_between_square_brackets = false
|
||||
|
||||
# Wrapping preferences
|
||||
csharp_preserve_single_line_blocks = true
|
||||
csharp_preserve_single_line_statements = true
|
||||
|
||||
#### Naming styles ####
|
||||
|
||||
# Naming rules
|
||||
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
|
||||
|
||||
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
|
||||
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
|
||||
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
|
||||
|
||||
# Symbol specifications
|
||||
|
||||
dotnet_naming_symbols.interface.applicable_kinds = interface
|
||||
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.interface.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
|
||||
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.types.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
|
||||
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.non_field_members.required_modifiers =
|
||||
|
||||
# Naming styles
|
||||
|
||||
dotnet_naming_style.pascal_case.required_prefix =
|
||||
dotnet_naming_style.pascal_case.required_suffix =
|
||||
dotnet_naming_style.pascal_case.word_separator =
|
||||
dotnet_naming_style.pascal_case.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.begins_with_i.required_prefix = I
|
||||
dotnet_naming_style.begins_with_i.required_suffix =
|
||||
dotnet_naming_style.begins_with_i.word_separator =
|
||||
dotnet_naming_style.begins_with_i.capitalization = pascal_case
|
||||
csharp_style_namespace_declarations = block_scoped:silent
|
||||
csharp_style_prefer_method_group_conversion = true:silent
|
||||
csharp_style_prefer_null_check_over_type_check = true:suggestion
|
||||
csharp_style_prefer_local_over_anonymous_function = true:suggestion
|
||||
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
|
||||
csharp_style_prefer_tuple_swap = true:suggestion
|
||||
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
|
||||
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
|
||||
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
|
||||
csharp_style_prefer_parameter_null_checking = true:suggestion
|
||||
csharp_style_prefer_pattern_matching = true:silent
|
||||
csharp_style_prefer_not_pattern = true:suggestion
|
||||
csharp_style_prefer_extended_property_pattern = true:suggestion
|
||||
csharp_style_prefer_top_level_statements = false:silent
|
||||
dotnet_diagnostic.CA1309.severity = error
|
||||
dotnet_diagnostic.CA1311.severity = suggestion
|
||||
dotnet_diagnostic.SYSLIB1054.severity = warning
|
||||
|
||||
[*.{cs,vb}]
|
||||
dotnet_style_coalesce_expression = true:suggestion
|
||||
dotnet_style_null_propagation = true:suggestion
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
|
||||
dotnet_style_prefer_auto_properties = true:suggestion
|
||||
dotnet_style_object_initializer = false:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
|
||||
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
||||
tab_width = 4
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = false:silent
|
||||
dotnet_style_prefer_conditional_expression_over_return = false:silent
|
||||
dotnet_style_explicit_tuple_names = true:suggestion
|
||||
dotnet_style_prefer_inferred_tuple_names = true:suggestion
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
|
||||
dotnet_style_prefer_compound_assignment = true:suggestion
|
||||
dotnet_style_prefer_simplified_interpolation = true:suggestion
|
||||
dotnet_style_namespace_match_folder = true:suggestion
|
||||
dotnet_style_readonly_field = true:suggestion
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
|
||||
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
|
||||
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
|
||||
dotnet_code_quality_unused_parameters = all:suggestion
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
|
||||
dotnet_style_qualification_for_field = false:silent
|
||||
dotnet_style_qualification_for_property = false:silent
|
||||
dotnet_style_qualification_for_method = false:silent
|
||||
dotnet_style_qualification_for_event = false:silent
|
||||
@@ -12,11 +12,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v6
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v3.2.0
|
||||
uses: actions/setup-dotnet@v5.1.0
|
||||
with:
|
||||
dotnet-version: 7.0.x
|
||||
dotnet-version: 9.0.x
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
- name: Build
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Benchmarks;
|
||||
|
||||
public class Argb32Decoding
|
||||
{
|
||||
private const int Width = 256;//ignoring smaller mips
|
||||
private const int Height = 256;//ignoring smaller mips
|
||||
private readonly byte[] inputData;
|
||||
private readonly byte[] outputData;
|
||||
|
||||
public Argb32Decoding()
|
||||
{
|
||||
inputData = File.ReadAllBytes(PathConstants.PathToTestFiles + "Rgb/" + "test.argb32");
|
||||
outputData = new byte[Width * Height * sizeof(uint)];
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public int OriginalMethod() => RgbConverter.ARGB32ToBGRA32(inputData, Width, Height, outputData);
|
||||
|
||||
[Benchmark]
|
||||
public int GenericMethod() => RgbConverter.Convert<ColorARGB32, byte, ColorBGRA32, byte>(inputData, Width, Height, outputData);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AssetRipper.TextureDecoder\AssetRipper.TextureDecoder.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.Benchmarks;
|
||||
|
||||
internal static class PathConstants
|
||||
{
|
||||
internal const string PathToRepositoryRoot = "../../../../../../../../";
|
||||
internal const string PathToTestFiles = PathToRepositoryRoot + "TestFiles/";
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using BenchmarkDotNet.Running;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Benchmarks;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
BenchmarkRunner.Run(typeof(Program).Assembly);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Benchmarks;
|
||||
|
||||
public class Rgb9e5Decoding
|
||||
{
|
||||
private const int Width = 256;//ignoring smaller mips
|
||||
private const int Height = 256;//ignoring smaller mips
|
||||
private readonly byte[] inputData;
|
||||
private readonly byte[] outputData;
|
||||
|
||||
public Rgb9e5Decoding()
|
||||
{
|
||||
inputData = File.ReadAllBytes(PathConstants.PathToTestFiles + "Rgb/" + "test.rgb9e5float");
|
||||
outputData = new byte[Width * Height * sizeof(uint)];
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public int OriginalMethod() => RgbConverter.RGB9e5FloatToBGRA32(inputData, Width, Height, outputData);
|
||||
|
||||
[Benchmark]
|
||||
public int GenericMethod() => RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA32, byte>(inputData, Width, Height, outputData);
|
||||
}
|
||||
+9
-4
@@ -1,10 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AssetRipper.Text.SourceGeneration" Version="1.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AssetRipper.TextureDecoder.SourceGeneration.Common\AssetRipper.TextureDecoder.SourceGeneration.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,295 @@
|
||||
using AssetRipper.Text.SourceGeneration;
|
||||
using AssetRipper.TextureDecoder.SourceGeneration.Common;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.ColorGenerator;
|
||||
internal static class NumericConversionGenerator
|
||||
{
|
||||
private const string OutputNamespace = "AssetRipper.TextureDecoder.Rgb";
|
||||
private const string OutputDirectory = "../../../../AssetRipper.TextureDecoder/Rgb/";
|
||||
private const string ClassName = "NumericConversion";
|
||||
private const string ChangeSign = "ChangeSign";
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
Console.WriteLine(ClassName);
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create(OutputDirectory, ClassName);
|
||||
Write(writer);
|
||||
}
|
||||
|
||||
private static void Write(IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLine();
|
||||
writer.WriteFileScopedNamespace(OutputNamespace);
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"static partial class {ClassName}");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
WritePrimaryConvertMethod(writer);
|
||||
foreach (CSharpPrimitives.Data from in CSharpPrimitives.List)
|
||||
{
|
||||
WriteConvertMethod(writer, from);
|
||||
}
|
||||
WriteGetValueMethod(writer, "GetMinimumValue");
|
||||
WriteGetValueMethod(writer, "GetMaximumValue");
|
||||
WriteChangeSignMethods(writer);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteChangeSignMethods(IndentedTextWriter writer)
|
||||
{
|
||||
foreach ((CSharpPrimitives.Data unsignedType, CSharpPrimitives.Data signedType) in GetIntegerTypes())
|
||||
{
|
||||
if (!unsignedType.HasPointerSize(out _, out _))
|
||||
{
|
||||
WriteMethod(writer, unsignedType, signedType, unsignedType);
|
||||
WriteMethod(writer, signedType, unsignedType, unsignedType);
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteMethod(IndentedTextWriter writer, CSharpPrimitives.Data parameterType, CSharpPrimitives.Data returnType, CSharpPrimitives.Data unsignedType)
|
||||
{
|
||||
writer.WriteLine("[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]");
|
||||
writer.WriteLine($"private static {returnType.LangName} {ChangeSign}({parameterType.LangName} value)");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
string methodName = parameterType == unsignedType ? "ToSignedNumber" : "ToUnsignedNumber";
|
||||
writer.WriteLine($"return {methodName}<{parameterType.LangName}, {returnType.LangName}>(value);");
|
||||
}
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
|
||||
static IEnumerable<(CSharpPrimitives.Data, CSharpPrimitives.Data)> GetIntegerTypes()
|
||||
{
|
||||
foreach (CSharpPrimitives.Data data in CSharpPrimitives.List)
|
||||
{
|
||||
if (data.IsSignedInteger(out CSharpPrimitives.Data? unsignedData))
|
||||
{
|
||||
yield return (unsignedData, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void WritePrimaryConvertMethod(IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]");
|
||||
writer.WriteLine($"public static TTo Convert<TFrom, TTo>(TFrom value) where TFrom : unmanaged where TTo : unmanaged");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine("if (typeof(TFrom) == typeof(TTo))");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine("return Unsafe.BitCast<TFrom, TTo>(value);");
|
||||
}
|
||||
foreach (CSharpPrimitives.Data from in CSharpPrimitives.List)
|
||||
{
|
||||
writer.WriteLine($"else if (typeof(TFrom) == typeof({from.LangName}))");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine($"return {ConvertMethodName(from.Type)}<TTo>(Unsafe.BitCast<TFrom, {from.LangName}>(value));");
|
||||
}
|
||||
}
|
||||
writer.WriteLine("else");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine("return ThrowOrReturnDefault<TTo>();");
|
||||
}
|
||||
}
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
|
||||
private static void WriteConvertMethod(IndentedTextWriter writer, CSharpPrimitives.Data from)
|
||||
{
|
||||
string methodName = ConvertMethodName(from.Type);
|
||||
writer.WriteLine("[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]");
|
||||
writer.WriteLine($"private static TTo {methodName}<TTo>({from.LangName} value) where TTo : unmanaged");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
if (from.HasPointerSize(out CSharpPrimitives.Data? bit32From, out CSharpPrimitives.Data? bit64From))
|
||||
{
|
||||
using (new If(writer, "IntPtr.Size == sizeof(int)"))
|
||||
{
|
||||
writer.WriteLine($"return {ConvertMethodName(bit32From.Type)}<TTo>(({bit32From.LangName})value);");
|
||||
}
|
||||
using (new Else(writer))
|
||||
{
|
||||
writer.WriteLine($"return {ConvertMethodName(bit64From.Type)}<TTo>(({bit64From.LangName})value);");
|
||||
}
|
||||
}
|
||||
else if (from.IsSignedInteger(out CSharpPrimitives.Data? unsignedFrom))
|
||||
{
|
||||
writer.WriteLine($"return {ConvertMethodName(unsignedFrom.Type)}<TTo>({ChangeSign}(value));");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (CSharpPrimitives.Data to in CSharpPrimitives.List)
|
||||
{
|
||||
string ifOrElseIf = to == CSharpPrimitives.FirstData ? "if" : "else if";
|
||||
writer.WriteLine($"{ifOrElseIf} (typeof(TTo) == typeof({to.LangName}))");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
if (from == to)
|
||||
{
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(value);");
|
||||
}
|
||||
else if (to.HasPointerSize(out CSharpPrimitives.Data? bit32To, out CSharpPrimitives.Data? bit64To))
|
||||
{
|
||||
using (new If(writer, "IntPtr.Size == sizeof(int)"))
|
||||
{
|
||||
writer.WriteLine($"{to.LangName} converted = ({to.LangName}){methodName}<{bit32To.LangName}>(value);");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(converted);");
|
||||
}
|
||||
using (new Else(writer))
|
||||
{
|
||||
writer.WriteLine($"{to.LangName} converted = ({to.LangName}){methodName}<{bit64To.LangName}>(value);");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(converted);");
|
||||
}
|
||||
}
|
||||
else if (to.IsSignedInteger(out CSharpPrimitives.Data? unsignedTo))
|
||||
{
|
||||
writer.WriteLine($"{to.LangName} converted = {ChangeSign}({methodName}<{unsignedTo.LangName}>(value));");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(converted);");
|
||||
}
|
||||
else if (from.IsFloatingPoint)
|
||||
{
|
||||
if (to.IsFloatingPoint)
|
||||
{
|
||||
writer.WriteLine($"{to.LangName} converted = ({to.LangName})value;");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(converted);");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(to.IsUnsignedInteger);
|
||||
CSharpPrimitives.Data conversionType = CSharpPrimitives.GetDataForIntegerFloatingPointConversion(to, from);
|
||||
if (conversionType != from)
|
||||
{
|
||||
writer.WriteComment($"We use {conversionType.LangName} because it has enough precision to convert from {from.LangName} to {to.LangName}.");
|
||||
writer.WriteLine($"return {ConvertMethodName(conversionType.Type)}<TTo>(({conversionType.LangName})value);");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteComment("x must be clamped because of rounding errors.");
|
||||
string minValue = to.MinValue;
|
||||
string maxValue = to.MaxValue;
|
||||
writer.WriteLine($"{from.LangName} x = value * ({from.LangName}){maxValue};");
|
||||
writer.WriteLine($"{to.LangName} converted = ({from.LangName}){maxValue} < x ? {maxValue} : (x > ({from.LangName}){minValue} ? ({to.LangName})x : {minValue});");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(converted);");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(from.IsUnsignedInteger);
|
||||
if (to.IsFloatingPoint)
|
||||
{
|
||||
CSharpPrimitives.Data conversionType = CSharpPrimitives.GetDataForIntegerFloatingPointConversion(from, to);
|
||||
if (conversionType != to)
|
||||
{
|
||||
writer.WriteComment($"There isn't enough precision to convert from {from.LangName} to {to.LangName}, so we convert to {conversionType.LangName} first.");
|
||||
writer.WriteLine($"{conversionType.LangName} x = {methodName}<{conversionType.LangName}>(value);");
|
||||
writer.WriteLine($"{to.LangName} converted = ({to.LangName})x;");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(converted);");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine($"{to.LangName} converted = ({to.LangName})value / ({to.LangName}){from.MaxValue};");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(converted);");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(to.IsUnsignedInteger);
|
||||
writer.WriteComment("See https://github.com/AssetRipper/TextureDecoder/issues/19");
|
||||
if (from.Size < to.Size)
|
||||
{
|
||||
int divided = to.Size / from.Size;
|
||||
string conversionType = to.Size < sizeof(uint) ? "uint" : to.LangName;
|
||||
writer.WriteLine("unchecked");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.Write($"{to.LangName} converted = ({to.LangName})(");
|
||||
for (int i = divided - 1; i > 0; i--)
|
||||
{
|
||||
writer.Write($"(({conversionType})value << {i * from.Size * 8}) | ");
|
||||
}
|
||||
writer.WriteLine("value);");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(converted);");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(from.Size > to.Size);
|
||||
if (from.Type == typeof(ushort) && to.Type == typeof(byte))
|
||||
{
|
||||
writer.WriteComment("This is a special case where we already know an optimal algorithm.");
|
||||
writer.WriteLine("uint x = (value * 255u + 32895u) >> 16;");
|
||||
writer.WriteLine("byte converted = unchecked((byte)x);");
|
||||
writer.WriteLine("return Unsafe.BitCast<byte, TTo>(converted);");
|
||||
}
|
||||
else if (from.Size < sizeof(double) && to.Size < sizeof(double))
|
||||
{
|
||||
writer.WriteLine($"double interpolated = (double)value / (double){from.MaxValue};");
|
||||
writer.WriteLine($"double exact = interpolated * (double){to.MaxValue};");
|
||||
writer.WriteLine($"{to.LangName} converted = ({to.LangName})double.Round(exact, MidpointRounding.AwayFromZero);");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(converted);");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteComment($"There are more accurate ways to map {from.TypeName} onto {to.TypeName}, but this is the simplest.");
|
||||
string conversionType = from.Size < sizeof(uint) ? "uint" : from.LangName;
|
||||
writer.WriteLine("unchecked");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
int offset = (from.Size / to.Size - 1) * to.Size * 8;
|
||||
writer.WriteLine($"{to.LangName} converted = ({to.LangName})(({conversionType})value >> {offset});");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{to.LangName}, TTo>(converted);");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.WriteLine("else");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine("return ThrowOrReturnDefault<TTo>();");
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
|
||||
private static void WriteGetValueMethod(IndentedTextWriter writer, string methodName)
|
||||
{
|
||||
writer.WriteLine("[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]");
|
||||
writer.WriteLine($"public static T {methodName}<T>() where T : unmanaged");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
foreach (CSharpPrimitives.Data from in CSharpPrimitives.List)
|
||||
{
|
||||
string ifOrElseIf = from == CSharpPrimitives.FirstData ? "if" : "else if";
|
||||
writer.WriteLine($"{ifOrElseIf} (typeof(T) == typeof({from.LangName}))");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine($"{from.LangName} value = {methodName}Safe<{from.LangName}>();");
|
||||
writer.WriteLine($"return Unsafe.BitCast<{from.LangName}, T>(value);");
|
||||
}
|
||||
}
|
||||
writer.WriteLine("else");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine("return ThrowOrReturnDefault<T>();");
|
||||
}
|
||||
}
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
|
||||
private static string ConvertMethodName(Type from)
|
||||
{
|
||||
return $"Convert{from.Name}";
|
||||
}
|
||||
}
|
||||
@@ -1,233 +1,531 @@
|
||||
using System.CodeDom.Compiler;
|
||||
using AssetRipper.Text.SourceGeneration;
|
||||
using AssetRipper.TextureDecoder.SourceGeneration.Common;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.ColorGenerator;
|
||||
|
||||
internal static class Program
|
||||
internal static partial 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 const string RgbNamespace = "AssetRipper.TextureDecoder.Rgb";
|
||||
private const string RgbFolder = "../../../../AssetRipper.TextureDecoder/Rgb/";
|
||||
private const string FormatsNamespace = "AssetRipper.TextureDecoder.Rgb.Formats";
|
||||
private const string FormatsFolder = "../../../../AssetRipper.TextureDecoder/Rgb/Formats/";
|
||||
|
||||
private static readonly Dictionary<Type, string> MinimumValues = new()
|
||||
private readonly record struct CustomColorDetails(string Name, Type Type, bool HasRed, bool HasGreen, bool HasBlue, bool HasAlpha, bool FullyUtilized)
|
||||
{
|
||||
{ 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" },
|
||||
};
|
||||
public static implicit operator CustomColorDetails((string, Type, bool, bool, bool, bool, bool) details)
|
||||
{
|
||||
return new CustomColorDetails(details.Item1, details.Item2, details.Item3, details.Item4, details.Item5, details.Item6, details.Item7);
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
private static readonly CustomColorDetails[] CustomColors =
|
||||
[
|
||||
( "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 ),
|
||||
};
|
||||
];
|
||||
|
||||
private static readonly string[] GenericColors =
|
||||
[
|
||||
"ColorR",
|
||||
"ColorRG",
|
||||
"ColorRGB",
|
||||
"ColorRGBA",
|
||||
"ColorA",
|
||||
"ColorARGB",
|
||||
"ColorBGRA",
|
||||
"ColorBGR",
|
||||
];
|
||||
|
||||
static void Main()
|
||||
{
|
||||
foreach (var color in Colors)
|
||||
foreach (CustomColorDetails customColor in CustomColors)
|
||||
{
|
||||
WriteColor(color);
|
||||
WriteCustomColor(customColor);
|
||||
}
|
||||
foreach (var otherColor in OtherColors)
|
||||
foreach (string genericColor in GenericColors)
|
||||
{
|
||||
WriteOtherColor(otherColor);
|
||||
WriteGenericColor(genericColor);
|
||||
}
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
WriteSuperGenericColor(i);
|
||||
}
|
||||
NumericConversionGenerator.Run();
|
||||
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)
|
||||
private static void WriteCustomColor(CustomColorDetails 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);
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create(FormatsFolder, name);
|
||||
WriteCustomColor(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)
|
||||
private static void WriteGenericColor(string name)
|
||||
{
|
||||
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('}');
|
||||
Console.WriteLine(name);
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create(FormatsFolder, name);
|
||||
WriteGenericColor(writer, name);
|
||||
}
|
||||
|
||||
private static void WriteColor(IndentedTextWriter writer, string name, Type type, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha)
|
||||
private static void WriteSuperGenericColor(int channelCount)
|
||||
{
|
||||
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++;
|
||||
string name = $"Color`{channelCount}";
|
||||
Console.WriteLine(name);
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create(RgbFolder, name);
|
||||
WriteSuperGenericColor(writer, channelCount);
|
||||
}
|
||||
|
||||
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++;
|
||||
private static void WriteCustomColor(IndentedTextWriter writer, string name, Type type, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha, bool fullyUtilized)
|
||||
{
|
||||
string typeName = CSharpPrimitives.Dictionary[type].LangName;
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLine();
|
||||
using (new Namespace(writer, FormatsNamespace))
|
||||
{
|
||||
writer.WriteLine($"public partial struct {name} : IColor<{typeName}>");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
WriteNonGenericStaticProperties(writer, hasRed, hasGreen, hasBlue, hasAlpha, fullyUtilized, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteToString(writer, hasRed, hasGreen, hasBlue, hasAlpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
private static void WriteToString(IndentedTextWriter writer, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha)
|
||||
{
|
||||
writer.WriteLine("public override string ToString()");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
sb.Append("return $\"{{ ");
|
||||
bool first = true;
|
||||
if (hasRed)
|
||||
{
|
||||
sb.Append("R: {R}");
|
||||
first = false;
|
||||
}
|
||||
if (hasGreen)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.Append("G: {G}");
|
||||
first = false;
|
||||
}
|
||||
if (hasBlue)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.Append("B: {B}");
|
||||
first = false;
|
||||
}
|
||||
if (hasAlpha)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.Append("A: {A}");
|
||||
}
|
||||
sb.Append(" }}\";");
|
||||
writer.WriteLine(sb.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
WriteGetChannels(writer, typeName);
|
||||
writer.WriteLine();
|
||||
WriteSetChannels(writer, type, hasRed, hasGreen, hasBlue, hasAlpha);
|
||||
private static void WriteNonGenericStaticProperties(IndentedTextWriter writer, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha, bool fullyUtilized, string typeName)
|
||||
{
|
||||
WriteNonGenericStaticProperties(writer, hasRed.ToLowerString(), hasGreen.ToLowerString(), hasBlue.ToLowerString(), hasAlpha.ToLowerString(), fullyUtilized.ToLowerString(), typeName);
|
||||
}
|
||||
|
||||
writer.Indent--;
|
||||
writer.WriteLine('}');
|
||||
private static void WriteNonGenericStaticProperties(IndentedTextWriter writer, string hasRed, string hasGreen, string hasBlue, string hasAlpha, string fullyUtilized, string typeName)
|
||||
{
|
||||
writer.WriteLine($"static bool IColor.HasRedChannel => {hasRed};");
|
||||
writer.WriteLine($"static bool IColor.HasGreenChannel => {hasGreen};");
|
||||
writer.WriteLine($"static bool IColor.HasBlueChannel => {hasBlue};");
|
||||
writer.WriteLine($"static bool IColor.HasAlphaChannel => {hasAlpha};");
|
||||
writer.WriteLine($"static bool IColor.ChannelsAreFullyUtilized => {fullyUtilized};");
|
||||
writer.WriteLine($"static Type IColor.ChannelType => typeof({typeName});");
|
||||
}
|
||||
|
||||
writer.Indent--;
|
||||
writer.WriteLine('}');
|
||||
private static void WriteBlackWhiteStaticProperties(IndentedTextWriter writer, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha, string colorTypeName, string channelTypeName)
|
||||
{
|
||||
string minValue = $"NumericConversion.GetMinimumValueSafe<{channelTypeName}>()";
|
||||
string maxValue = $"NumericConversion.GetMaximumValueSafe<{channelTypeName}>()";
|
||||
|
||||
//Black
|
||||
{
|
||||
writer.Write($"public static {colorTypeName}<{channelTypeName}> Black => new(");
|
||||
int rgbCount = CountRGB(hasRed, hasGreen, hasBlue);
|
||||
for (int i = 0; i < rgbCount; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
writer.Write(", ");
|
||||
}
|
||||
writer.Write(minValue);
|
||||
}
|
||||
if (hasAlpha)
|
||||
{
|
||||
if (rgbCount != 0)
|
||||
{
|
||||
writer.Write(", ");
|
||||
}
|
||||
writer.Write(maxValue);
|
||||
}
|
||||
writer.WriteLine(");");
|
||||
}
|
||||
|
||||
//White
|
||||
if (hasRed || hasGreen || hasBlue)
|
||||
{
|
||||
writer.Write($"public static {colorTypeName}<{channelTypeName}> White => new(");
|
||||
int rgbaCount = CountRGBA(hasRed, hasGreen, hasBlue, hasAlpha);
|
||||
for (int i = 0; i < rgbaCount; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
writer.Write(", ");
|
||||
}
|
||||
writer.Write(maxValue);
|
||||
}
|
||||
writer.WriteLine(");");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine($"static {colorTypeName}<{channelTypeName}> IColor<{colorTypeName}<{channelTypeName}>, {channelTypeName}>.White => throw new NotSupportedException();");
|
||||
}
|
||||
|
||||
static int CountRGB(bool hasRed, bool hasGreen, bool hasBlue)
|
||||
{
|
||||
return (hasRed ? 1 : 0) + (hasGreen ? 1 : 0) + (hasBlue ? 1 : 0);
|
||||
}
|
||||
|
||||
static int CountRGBA(bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha)
|
||||
{
|
||||
return CountRGB(hasRed, hasGreen, hasBlue) + (hasAlpha ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteGenericColor(IndentedTextWriter writer, string name)
|
||||
{
|
||||
const string typeName = "T";
|
||||
const string minValue = "NumericConversion.GetMinimumValueSafe<T>()";
|
||||
const string maxValue = "NumericConversion.GetMaximumValueSafe<T>()";
|
||||
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
writer.WriteFileScopedNamespace(FormatsNamespace);
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
writer.WriteLine($"public partial struct {name}<T> : IColor<{name}<T>, T> where T : unmanaged, INumberBase<T>, IMinMaxValue<T>");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
Debug.Assert(name.StartsWith("Color", StringComparison.Ordinal));
|
||||
ReadOnlySpan<char> channels = name.AsSpan()[5..];
|
||||
foreach (char channel in channels)
|
||||
{
|
||||
WriteProperty(writer, true, typeName, channel, minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
|
||||
bool hasRed = channels.Contains('R');
|
||||
bool hasGreen = channels.Contains('G');
|
||||
bool hasBlue = channels.Contains('B');
|
||||
bool hasAlpha = channels.Contains('A');
|
||||
|
||||
if (!hasRed)
|
||||
{
|
||||
WriteProperty(writer, hasRed, typeName, 'R', minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
if (!hasGreen)
|
||||
{
|
||||
WriteProperty(writer, hasGreen, typeName, 'G', minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
if (!hasBlue)
|
||||
{
|
||||
WriteProperty(writer, hasBlue, typeName, 'B', minValue);
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
if (!hasAlpha)
|
||||
{
|
||||
WriteProperty(writer, hasAlpha, typeName, 'A', maxValue);
|
||||
writer.WriteLineNoTabs();
|
||||
}
|
||||
|
||||
WriteConstructor(writer, name, hasRed, hasGreen, hasBlue, hasAlpha, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteGetChannels(writer, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteSetChannels(writer, typeName, hasRed, hasGreen, hasBlue, hasAlpha);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteNonGenericStaticProperties(writer, hasRed, hasGreen, hasBlue, hasAlpha, true, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteBlackWhiteStaticProperties(writer, hasRed, hasGreen, hasBlue, hasAlpha, name, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteToString(writer, hasRed, hasGreen, hasBlue, hasAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteSuperGenericColor(IndentedTextWriter writer, int channelCount)
|
||||
{
|
||||
const string typeName = "TChannelValue";
|
||||
const string minValue = $"NumericConversion.GetMinimumValueSafe<{typeName}>()";
|
||||
const string maxValue = $"NumericConversion.GetMaximumValueSafe<{typeName}>()";
|
||||
|
||||
string[] channelTypeParameters = channelCount switch
|
||||
{
|
||||
1 => ["TChannel"],
|
||||
2 => ["TChannel1", "TChannel2"],
|
||||
3 => ["TChannel1", "TChannel2", "TChannel3"],
|
||||
4 => ["TChannel1", "TChannel2", "TChannel3", "TChannel4"],
|
||||
_ => throw new(),
|
||||
};
|
||||
|
||||
string[] fieldNames = channelCount switch
|
||||
{
|
||||
1 => ["value"],
|
||||
2 => ["value1", "value2"],
|
||||
3 => ["value1", "value2", "value3"],
|
||||
4 => ["value1", "value2", "value3", "value4"],
|
||||
_ => throw new(),
|
||||
};
|
||||
|
||||
|
||||
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
writer.WriteUsing("AssetRipper.TextureDecoder.Rgb.Channels");
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
writer.WriteFileScopedNamespace("AssetRipper.TextureDecoder.Rgb");
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
string structName;
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
sb.Append("Color<");
|
||||
sb.Append(typeName);
|
||||
for (int i = 0; i < channelTypeParameters.Length; i++)
|
||||
{
|
||||
sb.Append(", ");
|
||||
sb.Append(channelTypeParameters[i]);
|
||||
}
|
||||
sb.Append('>');
|
||||
structName = sb.ToString();
|
||||
}
|
||||
|
||||
writer.WriteLine($"public partial struct {structName} : IColor<{structName}, {typeName}>");
|
||||
using (new Indented(writer))
|
||||
{
|
||||
writer.WriteLine($"where {typeName} : unmanaged, INumberBase<{typeName}>, IMinMaxValue<{typeName}>");
|
||||
foreach (string channel in channelTypeParameters)
|
||||
{
|
||||
writer.WriteLine($"where {channel} : IChannel");
|
||||
}
|
||||
}
|
||||
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
foreach (string fieldName in fieldNames)
|
||||
{
|
||||
writer.WriteLine($"private {typeName} {fieldName};");
|
||||
}
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
WriteProperty(writer, 'R', "Red", channelTypeParameters, fieldNames, minValue, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteProperty(writer, 'G', "Green", channelTypeParameters, fieldNames, minValue, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteProperty(writer, 'B', "Blue", channelTypeParameters, fieldNames, minValue, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteProperty(writer, 'A', "Alpha", channelTypeParameters, fieldNames, maxValue, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
writer.Write("public Color(");
|
||||
for (int i = 0; i < fieldNames.Length; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
writer.Write(", ");
|
||||
}
|
||||
|
||||
writer.Write(typeName);
|
||||
writer.Write(' ');
|
||||
writer.Write(fieldNames[i]);
|
||||
}
|
||||
writer.WriteLine(')');
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
foreach (string fieldName in fieldNames)
|
||||
{
|
||||
writer.WriteLine($"this.{fieldName} = {fieldName};");
|
||||
}
|
||||
}
|
||||
writer.WriteLineNoTabs();
|
||||
WriteGetChannels(writer, typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteSetChannels(writer, typeName, true, true, true, true);
|
||||
writer.WriteLineNoTabs();
|
||||
WriteNonGenericStaticProperties(
|
||||
writer,
|
||||
string.Join(" || ", channelTypeParameters.Select(c => $"{c}.IsRed")),
|
||||
string.Join(" || ", channelTypeParameters.Select(c => $"{c}.IsGreen")),
|
||||
string.Join(" || ", channelTypeParameters.Select(c => $"{c}.IsBlue")),
|
||||
string.Join(" || ", channelTypeParameters.Select(c => $"{c}.IsAlpha")),
|
||||
string.Join(" && ", channelTypeParameters.Select(c => $"{c}.FullyUtilized")),
|
||||
typeName);
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
writer.WriteLine($"public static {structName} Black");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine($"get => new({string.Join(", ", channelTypeParameters.Select(c => $"{c}.GetBlack<{typeName}>()"))});");
|
||||
}
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
writer.WriteLine($"public static {structName} White");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine($"get => new({string.Join(", ", channelTypeParameters.Select(c => $"{c}.GetWhite<{typeName}>()"))});");
|
||||
}
|
||||
writer.WriteLineNoTabs();
|
||||
|
||||
WriteToString(writer, true, true, true, true);
|
||||
}
|
||||
|
||||
static void WriteProperty(IndentedTextWriter writer, char property, string channel, string[] channels, string[] fields, string defaultValue, string typeName)
|
||||
{
|
||||
writer.WriteLine($"public {typeName} {property}");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine("readonly get");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
If.Write(
|
||||
writer,
|
||||
Enumerable.Range(0, channels.Length).Select(i => new ValueTuple<string, Action<IndentedTextWriter>?>($"{channels[i]}.Is{channel}", (writer) =>
|
||||
{
|
||||
writer.WriteLine($"return {channels[i]}.Get{channel}({fields[i]});");
|
||||
})),
|
||||
(writer) =>
|
||||
{
|
||||
writer.WriteLine($"return {defaultValue};");
|
||||
});
|
||||
}
|
||||
writer.WriteLine("set");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
for (int i = 0; i < channels.Length; i++)
|
||||
{
|
||||
writer.WriteLine($"Channel.SetIf{channel}<{channels[i]}, {typeName}>(ref {fields[i]}, value);");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteConstructor(IndentedTextWriter writer, string declaringTypeName, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha, string channelTypeName)
|
||||
{
|
||||
writer.Write($"public {declaringTypeName}(");
|
||||
if (hasRed)
|
||||
{
|
||||
writer.Write($"{channelTypeName} r");
|
||||
if (hasGreen || hasBlue || hasAlpha)
|
||||
{
|
||||
writer.Write(", ");
|
||||
}
|
||||
}
|
||||
if (hasGreen)
|
||||
{
|
||||
writer.Write($"{channelTypeName} g");
|
||||
if (hasBlue || hasAlpha)
|
||||
{
|
||||
writer.Write(", ");
|
||||
}
|
||||
}
|
||||
if (hasBlue)
|
||||
{
|
||||
writer.Write($"{channelTypeName} b");
|
||||
if (hasAlpha)
|
||||
{
|
||||
writer.Write(", ");
|
||||
}
|
||||
}
|
||||
if (hasAlpha)
|
||||
{
|
||||
writer.Write($"{channelTypeName} a");
|
||||
}
|
||||
writer.WriteLine(")");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
if (hasRed)
|
||||
{
|
||||
writer.WriteLine("R = r;");
|
||||
}
|
||||
if (hasGreen)
|
||||
{
|
||||
writer.WriteLine("G = g;");
|
||||
}
|
||||
if (hasBlue)
|
||||
{
|
||||
writer.WriteLine("B = b;");
|
||||
}
|
||||
if (hasAlpha)
|
||||
{
|
||||
writer.WriteLine("A = a;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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('}');
|
||||
writer.WriteLine($"public readonly void GetChannels(out {typeName} r, out {typeName} g, out {typeName} b, out {typeName} a)");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine("r = R;");
|
||||
writer.WriteLine("g = G;");
|
||||
writer.WriteLine("b = B;");
|
||||
writer.WriteLine("a = A;");
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteSetChannels(IndentedTextWriter writer, Type type, bool hasRed, bool hasGreen, bool hasBlue, bool hasAlpha)
|
||||
private static void WriteSetChannels(IndentedTextWriter writer, string typeName, 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)
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine("R = r;");
|
||||
if (hasRed)
|
||||
{
|
||||
writer.WriteLine("R = r;");
|
||||
}
|
||||
if (hasGreen)
|
||||
{
|
||||
writer.WriteLine("G = g;");
|
||||
}
|
||||
if (hasBlue)
|
||||
{
|
||||
writer.WriteLine("B = b;");
|
||||
}
|
||||
if (hasAlpha)
|
||||
{
|
||||
writer.WriteLine("A = a;");
|
||||
}
|
||||
}
|
||||
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)
|
||||
@@ -238,13 +536,12 @@ internal static class Program
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine($"public {typeName} {channel} ");
|
||||
writer.WriteLine('{');
|
||||
writer.Indent++;
|
||||
writer.WriteLine($"get => {defaultValue};");
|
||||
writer.WriteLine("set { }");
|
||||
writer.Indent--;
|
||||
writer.WriteLine('}');
|
||||
writer.WriteLine($"public readonly {typeName} {channel} ");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine($"get => {defaultValue};");
|
||||
writer.WriteLine("set { }");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<PublishAot>true</PublishAot>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using AssetRipper.TextureDecoder.Exr;
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Channels;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using StbImageWriteSharp;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -6,10 +8,11 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.ConsoleApp;
|
||||
|
||||
public struct DirectBitmap<TColor, TColorArg>
|
||||
public readonly struct DirectBitmap<TColor, TColorArg>
|
||||
where TColorArg : unmanaged
|
||||
where TColor : unmanaged, IColor<TColorArg>
|
||||
{
|
||||
private static readonly ImageWriter imageWriter = new();
|
||||
public DirectBitmap(int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
@@ -45,96 +48,91 @@ public struct DirectBitmap<TColor, TColorArg>
|
||||
|
||||
public void SaveAsBmp(string path)
|
||||
{
|
||||
GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components);
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
ImageWriter writer = new();
|
||||
if (typeof(TColor) == typeof(ColorRGBA32))
|
||||
lock (imageWriter)
|
||||
{
|
||||
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);
|
||||
imageWriter.WriteBmp(data, Width, Height, components, stream);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAsExr(string path)
|
||||
{
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
ExrWriter.Write<TColor, TColorArg>(stream, Width, Height, Pixels);
|
||||
}
|
||||
|
||||
public void SaveAsHdr(string path)
|
||||
{
|
||||
GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components);
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
ImageWriter writer = new();
|
||||
if (typeof(TColor) == typeof(ColorRGBA32))
|
||||
lock (imageWriter)
|
||||
{
|
||||
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);
|
||||
imageWriter.WriteHdr(data, Width, Height, components, stream);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAsJpg(string path)
|
||||
{
|
||||
GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components);
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
ImageWriter writer = new();
|
||||
if (typeof(TColor) == typeof(ColorRGBA32))
|
||||
lock (imageWriter)
|
||||
{
|
||||
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);
|
||||
imageWriter.WriteJpg(data, Width, Height, components, stream, default);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAsPng(string path)
|
||||
{
|
||||
GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components);
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
ImageWriter writer = new();
|
||||
if (typeof(TColor) == typeof(ColorRGBA32))
|
||||
lock (imageWriter)
|
||||
{
|
||||
writer.WritePng(Data, Width, Height, ColorComponents.RedGreenBlueAlpha, stream);
|
||||
}
|
||||
else if (typeof(TColor) == typeof(ColorRGB24))
|
||||
{
|
||||
writer.WritePng(Data, Width, Height, ColorComponents.RedGreenBlue, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
RgbConverter.Convert<TColor, TColorArg, ColorRGBA32, byte>(Bits, Width, Height, out byte[] output);
|
||||
writer.WritePng(output, Width, Height, ColorComponents.RedGreenBlueAlpha, stream);
|
||||
imageWriter.WritePng(data, Width, Height, components, stream);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAsTga(string path)
|
||||
{
|
||||
GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components);
|
||||
using Stream stream = File.OpenWrite(path);
|
||||
ImageWriter writer = new();
|
||||
if (typeof(TColor) == typeof(ColorRGBA32))
|
||||
lock (imageWriter)
|
||||
{
|
||||
writer.WriteTga(Data, Width, Height, ColorComponents.RedGreenBlueAlpha, stream);
|
||||
imageWriter.WriteTga(data, Width, Height, components, stream);
|
||||
}
|
||||
else if (typeof(TColor) == typeof(ColorRGB24))
|
||||
}
|
||||
|
||||
private void GetDataAndComponentsForSaving(out byte[] data, out ColorComponents components)
|
||||
{
|
||||
if (typeof(TColor) == typeof(Color<byte, R, G, B, A>) || typeof(TColor) == typeof(ColorRGBA<byte>))
|
||||
{
|
||||
writer.WriteTga(Data, Width, Height, ColorComponents.RedGreenBlue, stream);
|
||||
data = Data;
|
||||
components = ColorComponents.RedGreenBlueAlpha;
|
||||
}
|
||||
else if (typeof(TColor) == typeof(Color<byte, R, G, B>) || typeof(TColor) == typeof(ColorRGB<byte>))
|
||||
{
|
||||
data = Data;
|
||||
components = ColorComponents.RedGreenBlue;
|
||||
}
|
||||
else if (typeof(TColor) == typeof(Color<byte, Gray, A>))
|
||||
{
|
||||
data = Data;
|
||||
components = ColorComponents.GreyAlpha;
|
||||
}
|
||||
else if (typeof(TColor) == typeof(Color<byte, Gray>))
|
||||
{
|
||||
data = Data;
|
||||
components = ColorComponents.Grey;
|
||||
}
|
||||
else if (TColor.HasAlphaChannel)
|
||||
{
|
||||
RgbConverter.Convert<TColor, TColorArg, Color<byte, R, G, B, A>, byte>(Bits, Width, Height, out data);
|
||||
components = ColorComponents.RedGreenBlueAlpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
RgbConverter.Convert<TColor, TColorArg, ColorRGBA32, byte>(Bits, Width, Height, out byte[] output);
|
||||
writer.WriteTga(output, Width, Height, ColorComponents.RedGreenBlueAlpha, stream);
|
||||
RgbConverter.Convert<TColor, TColorArg, Color<byte, R, G, B>, byte>(Bits, Width, Height, out data);
|
||||
components = ColorComponents.RedGreenBlue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ using AssetRipper.TextureDecoder.Bc;
|
||||
using AssetRipper.TextureDecoder.Dxt;
|
||||
using AssetRipper.TextureDecoder.Etc;
|
||||
using AssetRipper.TextureDecoder.Pvrtc;
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using AssetRipper.TextureDecoder.Yuy2;
|
||||
|
||||
@@ -28,7 +27,7 @@ internal static partial class Program
|
||||
string args6 = args.GetArgument(6);
|
||||
byte[] data = File.ReadAllBytes(path);
|
||||
|
||||
DirectBitmap<ColorBGRA32, byte> bitmap = new DirectBitmap<ColorBGRA32, byte>(width, height);
|
||||
DirectBitmap<ColorBGRA<byte>, byte> bitmap = new DirectBitmap<ColorBGRA<byte>, byte>(width, height);
|
||||
switch (inputType)
|
||||
{
|
||||
case "astc":
|
||||
@@ -53,29 +52,40 @@ internal static partial class Program
|
||||
DecodeRgb(data, width, height, args5, bitmap.Bits);
|
||||
break;
|
||||
case "yuy2":
|
||||
Yuy2Decoder.DecompressYUY2(data, width, height, bitmap.Bits);
|
||||
Yuy2Decoder.DecompressYUY2<ColorBGRA<byte>, byte>(data, width, height, bitmap.Bits);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(inputType);
|
||||
}
|
||||
|
||||
string dirPath = Path.GetDirectoryName(path) ?? Environment.CurrentDirectory;
|
||||
string name = Path.GetFileName(path);
|
||||
|
||||
switch (outputType)
|
||||
{
|
||||
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);
|
||||
}
|
||||
File.WriteAllBytes(path + ".bgra", bitmap.Bits);
|
||||
break;
|
||||
case "bmp":
|
||||
bitmap.FlipY();
|
||||
bitmap.SaveAsBmp(path + ".bmp");
|
||||
break;
|
||||
case "exr":
|
||||
bitmap.FlipY();
|
||||
bitmap.SaveAsExr(path + ".exr");
|
||||
break;
|
||||
case "hdr":
|
||||
bitmap.FlipY();
|
||||
bitmap.SaveAsHdr(path + ".hdr");
|
||||
break;
|
||||
case "jpg":
|
||||
bitmap.FlipY();
|
||||
bitmap.SaveAsJpg(path + ".jpg");
|
||||
break;
|
||||
case "png":
|
||||
bitmap.FlipY();
|
||||
bitmap.SaveAsPng(path + ".png");
|
||||
break;
|
||||
case "tga":
|
||||
bitmap.FlipY();
|
||||
bitmap.SaveAsTga(path + ".tga");
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(outputType);
|
||||
@@ -95,7 +105,7 @@ internal static partial class Program
|
||||
Console.WriteLine("Arg at index 6 : blockYSize");
|
||||
int blockXSize = int.Parse(blockXSizeString);
|
||||
int blockYSize = int.Parse(blockYSizeString);
|
||||
AstcDecoder.DecodeASTC(input, width, height, blockXSize, blockYSize, output);
|
||||
AstcDecoder.DecodeASTC<ColorBGRA<byte>, byte>(input, width, height, blockXSize, blockYSize, output);
|
||||
}
|
||||
|
||||
private static void DecodeAtc(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)
|
||||
@@ -107,10 +117,10 @@ internal static partial class Program
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
AtcDecoder.DecompressAtcRgb4(input, width, height, output);
|
||||
AtcDecoder.DecompressAtcRgb4<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 1:
|
||||
AtcDecoder.DecompressAtcRgba8(input, width, height, output);
|
||||
AtcDecoder.DecompressAtcRgba8<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -133,25 +143,25 @@ internal static partial class Program
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
Bc1.Decompress(input, width, height, output);
|
||||
Bc1.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
Bc2.Decompress(input, width, height, output);
|
||||
Bc2.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 3:
|
||||
Bc3.Decompress(input, width, height, output);
|
||||
Bc3.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 4:
|
||||
Bc4.Decompress(input, width, height, output);
|
||||
Bc4.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 5:
|
||||
Bc5.Decompress(input, width, height, output);
|
||||
Bc5.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 6:
|
||||
Bc6h.Decompress(input, width, height, bool.Parse(isSignedString), output);
|
||||
Bc6h.Decompress<ColorBGRA<byte>, byte>(input, width, height, bool.Parse(isSignedString), output);
|
||||
break;
|
||||
case 7:
|
||||
Bc7.Decompress(input, width, height, output);
|
||||
Bc7.Decompress<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -169,13 +179,13 @@ internal static partial class Program
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
DxtDecoder.DecompressDXT1(input, width, height, output);
|
||||
DxtDecoder.DecompressDXT1<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 1:
|
||||
DxtDecoder.DecompressDXT3(input, width, height, output);
|
||||
DxtDecoder.DecompressDXT3<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
DxtDecoder.DecompressDXT5(input, width, height, output);
|
||||
DxtDecoder.DecompressDXT5<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -198,28 +208,28 @@ internal static partial class Program
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
EtcDecoder.DecompressETC(input, width, height, output);
|
||||
EtcDecoder.DecompressETC<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 1:
|
||||
EtcDecoder.DecompressETC2(input, width, height, output);
|
||||
EtcDecoder.DecompressETC2<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
EtcDecoder.DecompressETC2A1(input, width, height, output);
|
||||
EtcDecoder.DecompressETC2A1<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 3:
|
||||
EtcDecoder.DecompressETC2A8(input, width, height, output);
|
||||
EtcDecoder.DecompressETC2A8<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 4:
|
||||
EtcDecoder.DecompressEACRUnsigned(input, width, height, output);
|
||||
EtcDecoder.DecompressEACRUnsigned<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 5:
|
||||
EtcDecoder.DecompressEACRSigned(input, width, height, output);
|
||||
EtcDecoder.DecompressEACRSigned<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 6:
|
||||
EtcDecoder.DecompressEACRGUnsigned(input, width, height, output);
|
||||
EtcDecoder.DecompressEACRGUnsigned<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 7:
|
||||
EtcDecoder.DecompressEACRGSigned(input, width, height, output);
|
||||
EtcDecoder.DecompressEACRGSigned<ColorBGRA<byte>, byte>(input, width, height, output);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -231,13 +241,6 @@ internal static partial class Program
|
||||
{
|
||||
Console.WriteLine("Arg at index 5 : 2bitMode");
|
||||
bool do2bit = bool.Parse(do2bitModeString);
|
||||
PvrtcDecoder.DecompressPVRTC(input, width, height, do2bit, output);
|
||||
PvrtcDecoder.DecompressPVRTC<ColorBGRA<byte>, byte>(input, width, height, do2bit, output);
|
||||
}
|
||||
|
||||
public static void WriteAllBytes(string path, ReadOnlySpan<byte> bytes)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Channels;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.ConsoleApp;
|
||||
static partial class Program
|
||||
@@ -9,152 +11,500 @@ 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");
|
||||
Console.WriteLine(" 0 - R_SByte");
|
||||
Console.WriteLine(" 1 - RG_SByte");
|
||||
Console.WriteLine(" 2 - RGB_SByte");
|
||||
Console.WriteLine(" 3 - RGBA_SByte");
|
||||
Console.WriteLine(" 4 - A_SByte");
|
||||
Console.WriteLine(" 5 - ARGB_SByte");
|
||||
Console.WriteLine(" 6 - BGRA_SByte");
|
||||
Console.WriteLine(" 7 - R_Byte");
|
||||
Console.WriteLine(" 8 - RG_Byte");
|
||||
Console.WriteLine(" 9 - RGB_Byte");
|
||||
Console.WriteLine(" 10 - RGBA_Byte");
|
||||
Console.WriteLine(" 11 - A_Byte");
|
||||
Console.WriteLine(" 12 - ARGB_Byte");
|
||||
Console.WriteLine(" 13 - BGRA_Byte");
|
||||
Console.WriteLine(" 14 - R_Int16");
|
||||
Console.WriteLine(" 15 - RG_Int16");
|
||||
Console.WriteLine(" 16 - RGB_Int16");
|
||||
Console.WriteLine(" 17 - RGBA_Int16");
|
||||
Console.WriteLine(" 18 - A_Int16");
|
||||
Console.WriteLine(" 19 - ARGB_Int16");
|
||||
Console.WriteLine(" 20 - BGRA_Int16");
|
||||
Console.WriteLine(" 21 - R_UInt16");
|
||||
Console.WriteLine(" 22 - RG_UInt16");
|
||||
Console.WriteLine(" 23 - RGB_UInt16");
|
||||
Console.WriteLine(" 24 - RGBA_UInt16");
|
||||
Console.WriteLine(" 25 - A_UInt16");
|
||||
Console.WriteLine(" 26 - ARGB_UInt16");
|
||||
Console.WriteLine(" 27 - BGRA_UInt16");
|
||||
Console.WriteLine(" 28 - R_Int32");
|
||||
Console.WriteLine(" 29 - RG_Int32");
|
||||
Console.WriteLine(" 30 - RGB_Int32");
|
||||
Console.WriteLine(" 31 - RGBA_Int32");
|
||||
Console.WriteLine(" 32 - A_Int32");
|
||||
Console.WriteLine(" 33 - ARGB_Int32");
|
||||
Console.WriteLine(" 34 - BGRA_Int32");
|
||||
Console.WriteLine(" 35 - R_UInt32");
|
||||
Console.WriteLine(" 36 - RG_UInt32");
|
||||
Console.WriteLine(" 37 - RGB_UInt32");
|
||||
Console.WriteLine(" 38 - RGBA_UInt32");
|
||||
Console.WriteLine(" 39 - A_UInt32");
|
||||
Console.WriteLine(" 40 - ARGB_UInt32");
|
||||
Console.WriteLine(" 41 - BGRA_UInt32");
|
||||
Console.WriteLine(" 42 - R_IntPtr");
|
||||
Console.WriteLine(" 43 - RG_IntPtr");
|
||||
Console.WriteLine(" 44 - RGB_IntPtr");
|
||||
Console.WriteLine(" 45 - RGBA_IntPtr");
|
||||
Console.WriteLine(" 46 - A_IntPtr");
|
||||
Console.WriteLine(" 47 - ARGB_IntPtr");
|
||||
Console.WriteLine(" 48 - BGRA_IntPtr");
|
||||
Console.WriteLine(" 49 - R_UIntPtr");
|
||||
Console.WriteLine(" 50 - RG_UIntPtr");
|
||||
Console.WriteLine(" 51 - RGB_UIntPtr");
|
||||
Console.WriteLine(" 52 - RGBA_UIntPtr");
|
||||
Console.WriteLine(" 53 - A_UIntPtr");
|
||||
Console.WriteLine(" 54 - ARGB_UIntPtr");
|
||||
Console.WriteLine(" 55 - BGRA_UIntPtr");
|
||||
Console.WriteLine(" 56 - R_Int64");
|
||||
Console.WriteLine(" 57 - RG_Int64");
|
||||
Console.WriteLine(" 58 - RGB_Int64");
|
||||
Console.WriteLine(" 59 - RGBA_Int64");
|
||||
Console.WriteLine(" 60 - A_Int64");
|
||||
Console.WriteLine(" 61 - ARGB_Int64");
|
||||
Console.WriteLine(" 62 - BGRA_Int64");
|
||||
Console.WriteLine(" 63 - R_UInt64");
|
||||
Console.WriteLine(" 64 - RG_UInt64");
|
||||
Console.WriteLine(" 65 - RGB_UInt64");
|
||||
Console.WriteLine(" 66 - RGBA_UInt64");
|
||||
Console.WriteLine(" 67 - A_UInt64");
|
||||
Console.WriteLine(" 68 - ARGB_UInt64");
|
||||
Console.WriteLine(" 69 - BGRA_UInt64");
|
||||
Console.WriteLine(" 70 - R_Int128");
|
||||
Console.WriteLine(" 71 - RG_Int128");
|
||||
Console.WriteLine(" 72 - RGB_Int128");
|
||||
Console.WriteLine(" 73 - RGBA_Int128");
|
||||
Console.WriteLine(" 74 - A_Int128");
|
||||
Console.WriteLine(" 75 - ARGB_Int128");
|
||||
Console.WriteLine(" 76 - BGRA_Int128");
|
||||
Console.WriteLine(" 77 - R_UInt128");
|
||||
Console.WriteLine(" 78 - RG_UInt128");
|
||||
Console.WriteLine(" 79 - RGB_UInt128");
|
||||
Console.WriteLine(" 80 - RGBA_UInt128");
|
||||
Console.WriteLine(" 81 - A_UInt128");
|
||||
Console.WriteLine(" 82 - ARGB_UInt128");
|
||||
Console.WriteLine(" 83 - BGRA_UInt128");
|
||||
Console.WriteLine(" 84 - R_Half");
|
||||
Console.WriteLine(" 85 - RG_Half");
|
||||
Console.WriteLine(" 86 - RGB_Half");
|
||||
Console.WriteLine(" 87 - RGBA_Half");
|
||||
Console.WriteLine(" 88 - A_Half");
|
||||
Console.WriteLine(" 89 - ARGB_Half");
|
||||
Console.WriteLine(" 90 - BGRA_Half");
|
||||
Console.WriteLine(" 91 - R_Single");
|
||||
Console.WriteLine(" 92 - RG_Single");
|
||||
Console.WriteLine(" 93 - RGB_Single");
|
||||
Console.WriteLine(" 94 - RGBA_Single");
|
||||
Console.WriteLine(" 95 - A_Single");
|
||||
Console.WriteLine(" 96 - ARGB_Single");
|
||||
Console.WriteLine(" 97 - BGRA_Single");
|
||||
Console.WriteLine(" 98 - R_NFloat");
|
||||
Console.WriteLine(" 99 - RG_NFloat");
|
||||
Console.WriteLine(" 100 - RGB_NFloat");
|
||||
Console.WriteLine(" 101 - RGBA_NFloat");
|
||||
Console.WriteLine(" 102 - A_NFloat");
|
||||
Console.WriteLine(" 103 - ARGB_NFloat");
|
||||
Console.WriteLine(" 104 - BGRA_NFloat");
|
||||
Console.WriteLine(" 105 - R_Double");
|
||||
Console.WriteLine(" 106 - RG_Double");
|
||||
Console.WriteLine(" 107 - RGB_Double");
|
||||
Console.WriteLine(" 108 - RGBA_Double");
|
||||
Console.WriteLine(" 109 - A_Double");
|
||||
Console.WriteLine(" 110 - ARGB_Double");
|
||||
Console.WriteLine(" 111 - BGRA_Double");
|
||||
Console.WriteLine(" 112 - R_Decimal");
|
||||
Console.WriteLine(" 113 - RG_Decimal");
|
||||
Console.WriteLine(" 114 - RGB_Decimal");
|
||||
Console.WriteLine(" 115 - RGBA_Decimal");
|
||||
Console.WriteLine(" 116 - A_Decimal");
|
||||
Console.WriteLine(" 117 - ARGB_Decimal");
|
||||
Console.WriteLine(" 118 - BGRA_Decimal");
|
||||
Console.WriteLine(" 119 - ARGB16");
|
||||
Console.WriteLine(" 120 - RGB16");
|
||||
Console.WriteLine(" 121 - RGB9e5");
|
||||
Console.WriteLine(" 122 - RGBA16");
|
||||
int mode = int.Parse(modeString);
|
||||
switch(mode)
|
||||
{
|
||||
case 0:
|
||||
RgbConverter.Convert<ColorA8, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 1:
|
||||
RgbConverter.Convert<ColorARGB16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 2:
|
||||
RgbConverter.Convert<ColorARGB32, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 3:
|
||||
RgbConverter.Convert<ColorBGRA32, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 4:
|
||||
RgbConverter.Convert<ColorR16, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 5:
|
||||
RgbConverter.Convert<ColorR16Half, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 6:
|
||||
RgbConverter.Convert<ColorR16Signed, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<sbyte>, sbyte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 7:
|
||||
RgbConverter.Convert<ColorR32Single, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 8:
|
||||
RgbConverter.Convert<ColorR64Double, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 9:
|
||||
RgbConverter.Convert<ColorR8, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 10:
|
||||
RgbConverter.Convert<ColorR8Signed, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 11:
|
||||
RgbConverter.Convert<ColorRG16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 12:
|
||||
RgbConverter.Convert<ColorRG32Half, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 13:
|
||||
RgbConverter.Convert<ColorRG16Signed, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<byte>, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 14:
|
||||
RgbConverter.Convert<ColorRG32, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 15:
|
||||
RgbConverter.Convert<ColorRG32Signed, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 16:
|
||||
RgbConverter.Convert<ColorRG64Single, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 17:
|
||||
RgbConverter.Convert<ColorRG128Double, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 18:
|
||||
RgbConverter.Convert<ColorRGB16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 19:
|
||||
RgbConverter.Convert<ColorRGB24, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 20:
|
||||
RgbConverter.Convert<ColorRGB24Signed, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<short>, short, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 21:
|
||||
RgbConverter.Convert<ColorRGB32Half, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 22:
|
||||
RgbConverter.Convert<ColorRGB48, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 23:
|
||||
RgbConverter.Convert<ColorRGB48Half, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 24:
|
||||
RgbConverter.Convert<ColorRGB48Signed, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 25:
|
||||
RgbConverter.Convert<ColorRGB96Single, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 26:
|
||||
RgbConverter.Convert<ColorRGB192Double, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 27:
|
||||
RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<ushort>, ushort, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 28:
|
||||
RgbConverter.Convert<ColorRGBA128Single, float, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 29:
|
||||
RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRG<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 30:
|
||||
RgbConverter.Convert<ColorRGBA256Double, double, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGB<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 31:
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorRGBA<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 32:
|
||||
RgbConverter.Convert<ColorRGBA32Signed, sbyte, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorA<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 33:
|
||||
RgbConverter.Convert<ColorRGBA64, ushort, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorARGB<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 34:
|
||||
RgbConverter.Convert<ColorRGBA64Half, Half, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorBGRA<int>, int, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 35:
|
||||
RgbConverter.Convert<ColorRGBA64Signed, short, ColorBGRA32, byte>(input, width, height, output);
|
||||
RgbConverter.Convert<ColorR<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 36:
|
||||
RgbConverter.Convert<ColorRG<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 37:
|
||||
RgbConverter.Convert<ColorRGB<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 38:
|
||||
RgbConverter.Convert<ColorRGBA<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 39:
|
||||
RgbConverter.Convert<ColorA<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 40:
|
||||
RgbConverter.Convert<ColorARGB<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 41:
|
||||
RgbConverter.Convert<ColorBGRA<uint>, uint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 42:
|
||||
RgbConverter.Convert<ColorR<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 43:
|
||||
RgbConverter.Convert<ColorRG<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 44:
|
||||
RgbConverter.Convert<ColorRGB<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 45:
|
||||
RgbConverter.Convert<ColorRGBA<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 46:
|
||||
RgbConverter.Convert<ColorA<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 47:
|
||||
RgbConverter.Convert<ColorARGB<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 48:
|
||||
RgbConverter.Convert<ColorBGRA<nint>, nint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 49:
|
||||
RgbConverter.Convert<ColorR<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 50:
|
||||
RgbConverter.Convert<ColorRG<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 51:
|
||||
RgbConverter.Convert<ColorRGB<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 52:
|
||||
RgbConverter.Convert<ColorRGBA<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 53:
|
||||
RgbConverter.Convert<ColorA<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 54:
|
||||
RgbConverter.Convert<ColorARGB<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 55:
|
||||
RgbConverter.Convert<ColorBGRA<nuint>, nuint, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 56:
|
||||
RgbConverter.Convert<ColorR<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 57:
|
||||
RgbConverter.Convert<ColorRG<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 58:
|
||||
RgbConverter.Convert<ColorRGB<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 59:
|
||||
RgbConverter.Convert<ColorRGBA<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 60:
|
||||
RgbConverter.Convert<ColorA<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 61:
|
||||
RgbConverter.Convert<ColorARGB<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 62:
|
||||
RgbConverter.Convert<ColorBGRA<long>, long, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 63:
|
||||
RgbConverter.Convert<ColorR<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 64:
|
||||
RgbConverter.Convert<ColorRG<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 65:
|
||||
RgbConverter.Convert<ColorRGB<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 66:
|
||||
RgbConverter.Convert<ColorRGBA<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 67:
|
||||
RgbConverter.Convert<ColorA<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 68:
|
||||
RgbConverter.Convert<ColorARGB<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 69:
|
||||
RgbConverter.Convert<ColorBGRA<ulong>, ulong, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 70:
|
||||
RgbConverter.Convert<ColorR<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 71:
|
||||
RgbConverter.Convert<ColorRG<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 72:
|
||||
RgbConverter.Convert<ColorRGB<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 73:
|
||||
RgbConverter.Convert<ColorRGBA<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 74:
|
||||
RgbConverter.Convert<ColorA<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 75:
|
||||
RgbConverter.Convert<ColorARGB<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 76:
|
||||
RgbConverter.Convert<ColorBGRA<Int128>, Int128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 77:
|
||||
RgbConverter.Convert<ColorR<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 78:
|
||||
RgbConverter.Convert<ColorRG<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 79:
|
||||
RgbConverter.Convert<ColorRGB<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 80:
|
||||
RgbConverter.Convert<ColorRGBA<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 81:
|
||||
RgbConverter.Convert<ColorA<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 82:
|
||||
RgbConverter.Convert<ColorARGB<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 83:
|
||||
RgbConverter.Convert<ColorBGRA<UInt128>, UInt128, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 84:
|
||||
RgbConverter.Convert<ColorR<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 85:
|
||||
RgbConverter.Convert<ColorRG<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 86:
|
||||
RgbConverter.Convert<ColorRGB<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 87:
|
||||
RgbConverter.Convert<ColorRGBA<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 88:
|
||||
RgbConverter.Convert<ColorA<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 89:
|
||||
RgbConverter.Convert<ColorARGB<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 90:
|
||||
RgbConverter.Convert<ColorBGRA<Half>, Half, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 91:
|
||||
RgbConverter.Convert<ColorR<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 92:
|
||||
RgbConverter.Convert<ColorRG<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 93:
|
||||
RgbConverter.Convert<ColorRGB<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 94:
|
||||
RgbConverter.Convert<ColorRGBA<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 95:
|
||||
RgbConverter.Convert<ColorA<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 96:
|
||||
RgbConverter.Convert<ColorARGB<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 97:
|
||||
RgbConverter.Convert<ColorBGRA<float>, float, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 98:
|
||||
RgbConverter.Convert<ColorR<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 99:
|
||||
RgbConverter.Convert<ColorRG<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 100:
|
||||
RgbConverter.Convert<ColorRGB<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 101:
|
||||
RgbConverter.Convert<ColorRGBA<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 102:
|
||||
RgbConverter.Convert<ColorA<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 103:
|
||||
RgbConverter.Convert<ColorARGB<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 104:
|
||||
RgbConverter.Convert<ColorBGRA<NFloat>, NFloat, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 105:
|
||||
RgbConverter.Convert<ColorR<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 106:
|
||||
RgbConverter.Convert<ColorRG<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 107:
|
||||
RgbConverter.Convert<ColorRGB<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 108:
|
||||
RgbConverter.Convert<ColorRGBA<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 109:
|
||||
RgbConverter.Convert<ColorA<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 110:
|
||||
RgbConverter.Convert<ColorARGB<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 111:
|
||||
RgbConverter.Convert<ColorBGRA<double>, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 112:
|
||||
RgbConverter.Convert<ColorR<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 113:
|
||||
RgbConverter.Convert<ColorRG<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 114:
|
||||
RgbConverter.Convert<ColorRGB<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 115:
|
||||
RgbConverter.Convert<ColorRGBA<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 116:
|
||||
RgbConverter.Convert<ColorA<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 117:
|
||||
RgbConverter.Convert<ColorARGB<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 118:
|
||||
RgbConverter.Convert<ColorBGRA<decimal>, decimal, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 119:
|
||||
RgbConverter.Convert<ColorARGB16, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 120:
|
||||
RgbConverter.Convert<ColorRGB16, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 121:
|
||||
RgbConverter.Convert<ColorRGB9e5, double, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
case 122:
|
||||
RgbConverter.Convert<ColorRGBA16, byte, Color<byte, B, G, R, A>, byte>(input, width, height, output);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(mode.ToString());
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace AssetRipper.TextureDecoder.Paths;
|
||||
|
||||
public static class ProjectFolders
|
||||
{
|
||||
public const string ThisProject = "../../../";
|
||||
public const string RepositoryRoot = ThisProject + "../";
|
||||
public const string TestProject = RepositoryRoot + "AssetRipper.TextureDecoder.Tests/";
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace AssetRipper.TextureDecoder.Paths;
|
||||
|
||||
public static class TestFileFolders
|
||||
{
|
||||
public const string TestFiles = ProjectFolders.RepositoryRoot + "TestFiles/";
|
||||
public const string AstcTestFiles = TestFiles + "Astc/";
|
||||
public const string AtcTestFiles = TestFiles + "Atc/";
|
||||
public const string BcTestFiles = TestFiles + "Bc/";
|
||||
public const string DxtTestFiles = TestFiles + "Dxt/";
|
||||
public const string EtcTestFiles = TestFiles + "Etc/";
|
||||
public const string PvrtcTestFiles = TestFiles + "Pvrtc/";
|
||||
public const string RgbTestFiles = TestFiles + "Rgb/";
|
||||
public const string Yuy2TestFiles = TestFiles + "Yuy2/";
|
||||
public const string AndroidTestFiles = TestFiles + "Android/";
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,281 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.SourceGeneration.Common;
|
||||
|
||||
public static class CSharpPrimitives
|
||||
{
|
||||
public static IReadOnlyDictionary<Type, Data> Dictionary { get; } = new Dictionary<Type, Data>()
|
||||
{
|
||||
{ typeof(sbyte), new Data<sbyte>() },
|
||||
{ typeof(byte), new Data<byte>() },
|
||||
{ typeof(short), new Data<short>() },
|
||||
{ typeof(ushort), new Data<ushort>() },
|
||||
{ typeof(int), new Data<int>() },
|
||||
{ typeof(uint), new Data<uint>() },
|
||||
{ typeof(nint), new Data<nint>() },
|
||||
{ typeof(nuint), new Data<nuint>() },
|
||||
{ typeof(long), new Data<long>() },
|
||||
{ typeof(ulong), new Data<ulong>() },
|
||||
{ typeof(Int128), new Data<Int128>() },
|
||||
{ typeof(UInt128), new Data<UInt128>() },
|
||||
{ typeof(Half), new Data<Half>() },
|
||||
{ typeof(float), new Data<float>() },
|
||||
{ typeof(NFloat), new Data<NFloat>() },
|
||||
{ typeof(double), new Data<double>() },
|
||||
{ typeof(decimal), new Data<decimal>() },
|
||||
};
|
||||
|
||||
public static IReadOnlyList<Data> List { get; } = Dictionary.Values.ToList();
|
||||
|
||||
public static IReadOnlyList<Type> Types { get; } = Dictionary.Keys.ToList();
|
||||
|
||||
public static Type FirstType => Types[0];
|
||||
|
||||
public static Data FirstData => List[0];
|
||||
|
||||
public static bool HasPointerSize(Type type, [NotNullWhen(true)] out Type? bit32Type, [NotNullWhen(true)] out Type? bit64Type)
|
||||
{
|
||||
if (type == typeof(nint))
|
||||
{
|
||||
bit32Type = typeof(int);
|
||||
bit64Type = typeof(long);
|
||||
return true;
|
||||
}
|
||||
else if (type == typeof(nuint))
|
||||
{
|
||||
bit32Type = typeof(uint);
|
||||
bit64Type = typeof(ulong);
|
||||
return true;
|
||||
}
|
||||
else if (type == typeof(NFloat))
|
||||
{
|
||||
bit32Type = typeof(float);
|
||||
bit64Type = typeof(double);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bit32Type = null;
|
||||
bit64Type = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsFloatingPoint(Type type)
|
||||
{
|
||||
return type == typeof(Half) || type == typeof(float) || type == typeof(NFloat) || type == typeof(double) || type == typeof(decimal);
|
||||
}
|
||||
|
||||
public static bool IsInteger(Type type)
|
||||
{
|
||||
return IsUnsignedInteger(type) || IsSignedInteger(type);
|
||||
}
|
||||
|
||||
public static bool IsUnsignedInteger(Type type)
|
||||
{
|
||||
return type == typeof(byte) || type == typeof(ushort) || type == typeof(uint) || type == typeof(nuint) || type == typeof(ulong) || type == typeof(UInt128);
|
||||
}
|
||||
|
||||
public static bool IsSignedInteger(Type type) => IsSignedInteger(type, out _);
|
||||
|
||||
public static bool IsSignedInteger(Type type, [NotNullWhen(true)] out Type? unsignedType)
|
||||
{
|
||||
if (type == typeof(sbyte))
|
||||
{
|
||||
unsignedType = typeof(byte);
|
||||
}
|
||||
else if (type == typeof(short))
|
||||
{
|
||||
unsignedType = typeof(ushort);
|
||||
}
|
||||
else if (type == typeof(int))
|
||||
{
|
||||
unsignedType = typeof(uint);
|
||||
}
|
||||
else if (type == typeof(nint))
|
||||
{
|
||||
unsignedType = typeof(nuint);
|
||||
}
|
||||
else if (type == typeof(long))
|
||||
{
|
||||
unsignedType = typeof(ulong);
|
||||
}
|
||||
else if (type == typeof(Int128))
|
||||
{
|
||||
unsignedType = typeof(UInt128);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsignedType = null;
|
||||
}
|
||||
return unsignedType is not null;
|
||||
}
|
||||
|
||||
public static bool CanBeConstant(Type type)
|
||||
{
|
||||
return type == typeof(byte)
|
||||
|| type == typeof(sbyte)
|
||||
|| type == typeof(ushort)
|
||||
|| type == typeof(short)
|
||||
|| type == typeof(uint)
|
||||
|| type == typeof(int)
|
||||
|| type == typeof(ulong)
|
||||
|| type == typeof(long)
|
||||
|| type == typeof(float)
|
||||
|| type == typeof(double)
|
||||
|| type == typeof(bool)
|
||||
|| type == typeof(char)
|
||||
|| type == typeof(string);
|
||||
}
|
||||
|
||||
public static string GetLangName(Type type)
|
||||
{
|
||||
if (type == typeof(sbyte))
|
||||
{
|
||||
return "sbyte";
|
||||
}
|
||||
else if (type == typeof(byte))
|
||||
{
|
||||
return "byte";
|
||||
}
|
||||
else if (type == typeof(short))
|
||||
{
|
||||
return "short";
|
||||
}
|
||||
else if (type == typeof(ushort))
|
||||
{
|
||||
return "ushort";
|
||||
}
|
||||
else if (type == typeof(int))
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
else if (type == typeof(uint))
|
||||
{
|
||||
return "uint";
|
||||
}
|
||||
else if (type == typeof(nint))
|
||||
{
|
||||
return "nint";
|
||||
}
|
||||
else if (type == typeof(nuint))
|
||||
{
|
||||
return "nuint";
|
||||
}
|
||||
else if (type == typeof(long))
|
||||
{
|
||||
return "long";
|
||||
}
|
||||
else if (type == typeof(ulong))
|
||||
{
|
||||
return "ulong";
|
||||
}
|
||||
else if (type == typeof(float))
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
else if (type == typeof(double))
|
||||
{
|
||||
return "double";
|
||||
}
|
||||
else if (type == typeof(decimal))
|
||||
{
|
||||
return "decimal";
|
||||
}
|
||||
else if (type == typeof(char))
|
||||
{
|
||||
return "char";
|
||||
}
|
||||
else if (type == typeof(bool))
|
||||
{
|
||||
return "bool";
|
||||
}
|
||||
else if (type == typeof(string))
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
else
|
||||
{
|
||||
return type.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public static Data GetDataForIntegerFloatingPointConversion(Data integerType, Data floatingPointType)
|
||||
{
|
||||
if (!IsInteger(integerType.Type))
|
||||
{
|
||||
throw new ArgumentException("The provided integer type is not an integer type.", nameof(integerType));
|
||||
}
|
||||
if (!IsFloatingPoint(floatingPointType.Type))
|
||||
{
|
||||
throw new ArgumentException("The provided floating point type is not a floating point type.", nameof(floatingPointType));
|
||||
}
|
||||
|
||||
Data result = integerType.Size < sizeof(uint) ? Dictionary[typeof(float)] : Dictionary[typeof(double)];
|
||||
return floatingPointType.Size >= result.Size ? floatingPointType : result;
|
||||
}
|
||||
|
||||
public abstract class Data
|
||||
{
|
||||
public abstract Type Type { get; }
|
||||
public string TypeName => Type.Name;
|
||||
public string LangName => GetLangName(Type);
|
||||
public bool CanBeConstant => CanBeConstant(Type);
|
||||
public bool HasPointerSize([NotNullWhen(true)] out Data? bit32Data, [NotNullWhen(true)] out Data? bit64Data)
|
||||
{
|
||||
if (CSharpPrimitives.HasPointerSize(Type, out Type? bit32Type, out Type? bit64Type))
|
||||
{
|
||||
bit32Data = Dictionary[bit32Type];
|
||||
bit64Data = Dictionary[bit64Type];
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bit32Data = null;
|
||||
bit64Data = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsFloatingPoint => IsFloatingPoint(Type);
|
||||
public bool IsUnsignedInteger => IsUnsignedInteger(Type);
|
||||
public bool IsSignedInteger([NotNullWhen(true)] out Data? unsignedData)
|
||||
{
|
||||
if (CSharpPrimitives.IsSignedInteger(Type, out Type? unsignedType))
|
||||
{
|
||||
unsignedData = Dictionary[unsignedType];
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsignedData = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public abstract int Size { get; }
|
||||
public override string ToString() => TypeName;
|
||||
public string MinValue => IsFloatingPoint ? $"{LangName}.Zero" : $"{LangName}.MinValue";
|
||||
public string MaxValue => IsFloatingPoint ? $"{LangName}.One" : $"{LangName}.MaxValue";
|
||||
}
|
||||
|
||||
private sealed class Data<T> : Data
|
||||
{
|
||||
public override Type Type => typeof(T);
|
||||
|
||||
public override int Size
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CSharpPrimitives.HasPointerSize(Type, out _, out _))
|
||||
{
|
||||
return 6;//arbitrary value between 4 and 8
|
||||
}
|
||||
else
|
||||
{
|
||||
return Unsafe.SizeOf<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -2,13 +2,16 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AssetRipper.TextureDecoder.Paths\AssetRipper.TextureDecoder.Paths.csproj" />
|
||||
<ProjectReference Include="..\AssetRipper.TextureDecoder.SourceGeneration.Common\AssetRipper.TextureDecoder.SourceGeneration.Common.csproj" />
|
||||
<ProjectReference Include="..\AssetRipper.TextureDecoder\AssetRipper.TextureDecoder.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AssetRipper.Text.SourceGeneration" Version="1.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,20 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
{
|
||||
internal struct ColorRandomValues
|
||||
{
|
||||
public string DefaultR;
|
||||
public string DefaultG;
|
||||
public string DefaultB;
|
||||
public string DefaultA;
|
||||
public string SetValue;
|
||||
|
||||
public ColorRandomValues(string defaultR, string defaultG, string defaultB, string defaultA, string setValue)
|
||||
{
|
||||
DefaultR = defaultR;
|
||||
DefaultG = defaultG;
|
||||
DefaultB = defaultB;
|
||||
DefaultA = defaultA;
|
||||
SetValue = setValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +1,39 @@
|
||||
using AssetRipper.TextureDecoder.Attributes;
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using System.Reflection;
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.SourceGeneration.Common;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
{
|
||||
internal readonly struct GenerationData
|
||||
{
|
||||
public Type ColorType { get; }
|
||||
public Type ChannelType { get; }
|
||||
public int ColorSize { get; }
|
||||
public Type ColorType { get; private init; }
|
||||
public Type ChannelType { get; private init; }
|
||||
public int ColorSize { get; private init; }
|
||||
|
||||
public bool RedChannel { get; }
|
||||
public bool GreenChannel { get; }
|
||||
public bool BlueChannel { get; }
|
||||
public bool AlphaChannel { get; }
|
||||
public bool FullyUtilizedChannels { get; }
|
||||
public bool RedChannel { get; private init; }
|
||||
public bool GreenChannel { get; private init; }
|
||||
public bool BlueChannel { get; private init; }
|
||||
public bool AlphaChannel { get; private init; }
|
||||
public bool FullyUtilizedChannels { get; private init; }
|
||||
|
||||
public bool IsFloatingPoint
|
||||
public bool IsFloatingPoint => CSharpPrimitives.IsFloatingPoint(ChannelType);
|
||||
|
||||
public int BitSizePerChannel => CSharpPrimitives.Dictionary[ChannelType].Size * 8;
|
||||
|
||||
public string ChannelTypeName => CSharpPrimitives.Dictionary[ChannelType].LangName;
|
||||
|
||||
public static GenerationData Create<T>(int colorSize) where T : IColor
|
||||
{
|
||||
get
|
||||
return new GenerationData()
|
||||
{
|
||||
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 = 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;
|
||||
ColorType = typeof(T),
|
||||
ChannelType = T.ChannelType,
|
||||
ColorSize = colorSize,
|
||||
RedChannel = T.HasRedChannel,
|
||||
GreenChannel = T.HasGreenChannel,
|
||||
BlueChannel = T.HasBlueChannel,
|
||||
AlphaChannel = T.HasAlphaChannel,
|
||||
FullyUtilizedChannels = T.ChannelsAreFullyUtilized,
|
||||
};
|
||||
}
|
||||
|
||||
public bool Contains(GenerationData other)
|
||||
@@ -89,12 +43,7 @@ namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsFloatingPoint && other.IsFloatingPoint)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsFloatingPoint && !other.IsFloatingPoint)
|
||||
if (IsFloatingPoint != other.IsFloatingPoint)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -122,4 +71,4 @@ namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
return BitSizePerChannel >= other.BitSizePerChannel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
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,6 +1,10 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.Text.SourceGeneration;
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Channels;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using AssetRipper.TextureDecoder.SourceGeneration.Common;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
{
|
||||
@@ -8,111 +12,86 @@ namespace AssetRipper.TextureDecoder.TestGenerator
|
||||
{
|
||||
internal static readonly List<GenerationData> dataList = new()
|
||||
{
|
||||
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),
|
||||
GenerationData.Create<ColorARGB16>(2),
|
||||
GenerationData.Create<ColorRGB16>(2),
|
||||
GenerationData.Create<ColorRGB9e5>(4),
|
||||
GenerationData.Create<ColorRGBA16>(2),
|
||||
};
|
||||
|
||||
static void Main()
|
||||
{
|
||||
TestClassGenerator.GenerateTestClasses();
|
||||
GenerateRgbConsoleMethod();
|
||||
TextureDataClassGenerator.Generate();
|
||||
Console.WriteLine("Done!");
|
||||
}
|
||||
|
||||
private static void GenerateRgbConsoleMethod()
|
||||
{
|
||||
StringWriter streamWriter = new();
|
||||
IndentedTextWriter textWriter = new IndentedTextWriter(streamWriter, "\t");
|
||||
streamWriter.NewLine = "\n";
|
||||
textWriter.NewLine = "\n";
|
||||
|
||||
textWriter.WriteSourceGenerationDisclaimer();
|
||||
textWriter.WriteLine($"using {typeof(RgbConverter).Namespace};");
|
||||
textWriter.WriteLine($"using {typeof(ColorBGRA32).Namespace};");
|
||||
textWriter.WriteLine();
|
||||
|
||||
textWriter.WriteLine("namespace AssetRipper.TextureDecoder.ConsoleApp;");
|
||||
textWriter.WriteLine("static partial class Program");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent++;
|
||||
|
||||
textWriter.WriteLine("private static void DecodeRgb(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent++;
|
||||
|
||||
textWriter.WriteLine("Console.WriteLine(\"Arg at index 5 : mode\");");
|
||||
for (int i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
textWriter.WriteLine($"Console.WriteLine(\" {i} - {dataList[i].ColorType.Name.Substring(5)}\");");
|
||||
}
|
||||
textWriter.WriteLine("int mode = int.Parse(modeString);");
|
||||
textWriter.WriteLine("switch(mode)");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent++;
|
||||
|
||||
for (int i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
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--;
|
||||
}
|
||||
{
|
||||
textWriter.WriteLine("default:");
|
||||
textWriter.Indent++;
|
||||
textWriter.WriteLine("throw new NotSupportedException(mode.ToString());");
|
||||
textWriter.Indent--;
|
||||
}
|
||||
|
||||
textWriter.Indent--;
|
||||
textWriter.WriteLine("}");
|
||||
|
||||
textWriter.Indent--;
|
||||
textWriter.WriteLine("}");
|
||||
|
||||
textWriter.Indent--;
|
||||
textWriter.WriteLine("}");
|
||||
|
||||
textWriter.Flush();
|
||||
streamWriter.Flush();
|
||||
File.WriteAllText("../../../../AssetRipper.TextureDecoder.ConsoleApp/Program.g.cs", streamWriter.ToString());
|
||||
Console.WriteLine("Program");
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create("../../../../AssetRipper.TextureDecoder.ConsoleApp", "Program");
|
||||
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"using {typeof(RgbConverter).Namespace};");
|
||||
writer.WriteLine($"using {typeof(B).Namespace};");
|
||||
writer.WriteLine($"using {typeof(ColorRGBA16).Namespace};");
|
||||
writer.WriteLine($"using {typeof(NFloat).Namespace};");
|
||||
writer.WriteLine();
|
||||
|
||||
writer.WriteFileScopedNamespace("AssetRipper.TextureDecoder.ConsoleApp");
|
||||
writer.WriteLine("static partial class Program");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine("private static void DecodeRgb(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
List<(string, string, string)> list = GetColorNames().ToList();
|
||||
writer.WriteLine("Console.WriteLine(\"Arg at index 5 : mode\");");
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
writer.WriteLine($"Console.WriteLine(\" {i} - {list[i].Item1.Substring(5)}\");");
|
||||
}
|
||||
writer.WriteLine("int mode = int.Parse(modeString);");
|
||||
writer.WriteLine("switch(mode)");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
for (int i = 0 ; i < list.Count; i++)
|
||||
{
|
||||
(string prettyName, string colorName, string channelName) = list[i];
|
||||
writer.WriteLine($"case {i}:");
|
||||
using (new Indented(writer))
|
||||
{
|
||||
writer.WriteLine($"RgbConverter.Convert<{colorName}, {channelName}, Color<byte, B, G, R, A>, byte>(input, width, height, output);");
|
||||
writer.WriteLine("break;");
|
||||
}
|
||||
}
|
||||
{
|
||||
writer.WriteLine("default:");
|
||||
using (new Indented(writer))
|
||||
{
|
||||
writer.WriteLine("throw new NotSupportedException(mode.ToString());");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<(string, string, string)> GetColorNames()
|
||||
{
|
||||
foreach (CSharpPrimitives.Data primitiveData in CSharpPrimitives.List)
|
||||
{
|
||||
foreach (string genericColorName in TestClassGenerator.GetGenericColorNames())
|
||||
{
|
||||
string prettyName = $"{genericColorName}_{primitiveData.TypeName}";
|
||||
yield return (prettyName, $"{genericColorName}<{primitiveData.LangName}>", primitiveData.LangName);
|
||||
}
|
||||
}
|
||||
foreach (GenerationData data in dataList)
|
||||
{
|
||||
yield return (data.ColorType.Name, data.ColorType.Name, data.ChannelTypeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.Text.SourceGeneration;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using AssetRipper.TextureDecoder.SourceGeneration.Common;
|
||||
using AssetRipper.TextureDecoder.TestGenerator;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
@@ -6,54 +8,97 @@ internal static class TestClassGenerator
|
||||
{
|
||||
private const string OutputNamespace = "AssetRipper.TextureDecoder.Tests.Formats";
|
||||
private const string OutputFolder = "../../../../AssetRipper.TextureDecoder.Tests/Formats/";
|
||||
private const string GenericOutputNamespace = OutputNamespace + ".Generic";
|
||||
private const string GenericOutputFolder = OutputFolder + "Generic/";
|
||||
|
||||
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") },
|
||||
};
|
||||
private static readonly char[] channels = ['R', 'G', 'B', 'A'];
|
||||
|
||||
internal static void GenerateTestClasses()
|
||||
{
|
||||
Directory.CreateDirectory(OutputFolder);
|
||||
|
||||
MakeGenericColorTests();
|
||||
MakeLosslessColorTests();
|
||||
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.WriteGeneratedCodeWarning();
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteNamespaceUsings(data.ColorType.Namespace);
|
||||
textWriter.WriteFileScopedNamespace();
|
||||
textWriter.WriteClassDefinitionOpen(data);
|
||||
textWriter.Indent++;
|
||||
textWriter.WriteCorrectSizeTest(data);
|
||||
textWriter.WriteLine();
|
||||
textWriter.WritePropertySymmetryTests(data);
|
||||
textWriter.WriteIndependenceTests(data);
|
||||
textWriter.WriteLineNoTabs();
|
||||
if (data.ColorType != typeof(ColorRGB9e5))//Rounding errors cause these to fail
|
||||
{
|
||||
textWriter.WritePropertySymmetryTests(data);
|
||||
textWriter.WriteIndependenceTests(data);
|
||||
}
|
||||
textWriter.WriteGetMethodMatchesProperties();
|
||||
textWriter.WriteLine();
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteMethodSymmetryTest();
|
||||
textWriter.WriteLine();
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteMakeRandomColor(data);
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteMakeRandomValue(data);
|
||||
|
||||
foreach (GenerationData otherData in Program.dataList)
|
||||
{
|
||||
if (otherData.Contains(data))
|
||||
{
|
||||
textWriter.WriteLine();
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data, otherData);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (CSharpPrimitives.Data channelData in CSharpPrimitives.List)
|
||||
{
|
||||
Type channelType = channelData.Type;
|
||||
string channelTypeName = channelData.LangName;
|
||||
|
||||
if (CSharpPrimitives.IsFloatingPoint(channelType) != CSharpPrimitives.IsFloatingPoint(data.ChannelType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (channelType == typeof(decimal) || data.ChannelType == typeof(decimal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (channelData.Size < CSharpPrimitives.Dictionary[data.ChannelType].Size)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorRGBA<>)}<{channelTypeName}>", channelTypeName);
|
||||
|
||||
if (!data.AlphaChannel)
|
||||
{
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorRGB<>)}<{channelTypeName}>", channelTypeName);
|
||||
if (!data.BlueChannel)
|
||||
{
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorRG<>)}<{channelTypeName}>", channelTypeName);
|
||||
if (!data.GreenChannel)
|
||||
{
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorR<>)}<{channelTypeName}>", channelTypeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!data.RedChannel && !data.GreenChannel && !data.BlueChannel)
|
||||
{
|
||||
textWriter.WriteLineNoTabs();
|
||||
textWriter.WriteLosslessConversionTest(data.ColorType.Name, data.ChannelTypeName, $"{nameof(ColorA<>)}<{channelTypeName}>", channelTypeName);
|
||||
}
|
||||
}
|
||||
|
||||
textWriter.Indent--;
|
||||
textWriter.WriteClassDefinitionClose();
|
||||
|
||||
@@ -66,6 +111,78 @@ internal static class TestClassGenerator
|
||||
}
|
||||
}
|
||||
|
||||
private static void MakeGenericColorTests()
|
||||
{
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create(GenericOutputFolder, "GenericColorTests");
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLine();
|
||||
writer.WriteUsing(typeof(ColorR<>).Namespace!);
|
||||
writer.WriteLine();
|
||||
writer.WriteFileScopedNamespace(GenericOutputNamespace);
|
||||
|
||||
foreach (string channeName in CSharpPrimitives.List.Select(d => d.LangName))
|
||||
{
|
||||
foreach (string colorName in GetGenericColorNames())
|
||||
{
|
||||
writer.WriteLine($"[TestFixture(TypeArgs = new Type[] {{ typeof({colorName}<{channeName}>), typeof({channeName}) }})]");
|
||||
}
|
||||
}
|
||||
writer.WriteLine("partial class GenericColorTests<TColor, TChannelValue>");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
internal static IEnumerable<string> GetGenericColorNames()
|
||||
{
|
||||
yield return nameof(ColorR<>);
|
||||
yield return nameof(ColorRG<>);
|
||||
yield return nameof(ColorRGB<>);
|
||||
yield return nameof(ColorRGBA<>);
|
||||
yield return nameof(ColorA<>);
|
||||
yield return nameof(ColorARGB<>);
|
||||
yield return nameof(ColorBGRA<>);
|
||||
}
|
||||
|
||||
private static void MakeLosslessColorTests()
|
||||
{
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create(GenericOutputFolder, "LosslessColorTests");
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLine();
|
||||
writer.WriteUsing(typeof(ColorR<>).Namespace!);
|
||||
writer.WriteLine();
|
||||
writer.WriteFileScopedNamespace(GenericOutputNamespace);
|
||||
|
||||
foreach (CSharpPrimitives.Data t1 in CSharpPrimitives.List)
|
||||
{
|
||||
foreach (CSharpPrimitives.Data t2 in CSharpPrimitives.List)
|
||||
{
|
||||
if (t1.IsFloatingPoint != t2.IsFloatingPoint)
|
||||
{
|
||||
// one is floating point, the other is not
|
||||
continue;
|
||||
}
|
||||
|
||||
if (t1.Type == typeof(decimal) || t2.Type == typeof(decimal))
|
||||
{
|
||||
// decimal has rounding errors when converting to/from double and float
|
||||
continue;
|
||||
}
|
||||
|
||||
if (t1.Size > t2.Size)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
writer.WriteLine($"[TestFixture(TypeArgs = new Type[] {{ typeof({t1.LangName}), typeof({t2.LangName}) }})]");
|
||||
}
|
||||
}
|
||||
writer.WriteLine("partial class LosslessColorTests<T1, T2>");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteClassDefinitionClose(this IndentedTextWriter textWriter)
|
||||
{
|
||||
textWriter.WriteLine("}");
|
||||
@@ -103,7 +220,7 @@ internal static class TestClassGenerator
|
||||
|
||||
textWriter.WriteLine("var color = MakeRandomColor();");
|
||||
textWriter.WriteLine("color.GetChannels(out var r, out var g, out var b, out var a);");
|
||||
textWriter.WriteLine("Assert.Multiple(() =>");
|
||||
textWriter.WriteLine("using (Assert.EnterMultipleScope())");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
@@ -113,7 +230,7 @@ internal static class TestClassGenerator
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
textWriter.WriteLine("};");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
@@ -131,9 +248,9 @@ internal static class TestClassGenerator
|
||||
{
|
||||
textWriter.WriteLine($"var {char.ToLowerInvariant(otherChannel)} = color.{otherChannel};");
|
||||
}
|
||||
textWriter.WriteLine($"color.{channel} = {randomValueDictionary[data.ChannelType].SetValue};");
|
||||
textWriter.WriteLine($"color.{channel} = MakeRandomValue();");
|
||||
|
||||
textWriter.WriteLine("Assert.Multiple(() =>");
|
||||
textWriter.WriteLine("using (Assert.EnterMultipleScope())");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
@@ -143,7 +260,7 @@ internal static class TestClassGenerator
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
textWriter.WriteLine("};");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
@@ -160,44 +277,27 @@ internal static class TestClassGenerator
|
||||
|
||||
private static void WriteLosslessConversionTest(this IndentedTextWriter textWriter, GenerationData currentData, GenerationData containingData)
|
||||
{
|
||||
string currentName = currentData.ColorType.Name;
|
||||
string containingName = containingData.ColorType.Name;
|
||||
textWriter.WriteLosslessConversionTest(currentData.ColorType.Name, currentData.ChannelTypeName, containingData.ColorType.Name, containingData.ChannelTypeName);
|
||||
}
|
||||
|
||||
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 WriteLosslessConversionTest(this IndentedTextWriter writer, string t1Color, string t1Channel, string t2Color, string t2Channel)
|
||||
{
|
||||
writer.WriteLine("[Test]");
|
||||
writer.WriteLine($"public void ConversionIsLosslessTo{t2Color.Replace("<","_").Replace(">", "")}()");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine($"LosslessConversion.Assert<{t1Color}, {t1Channel}, {t2Color}, {t2Channel}>();");
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteMakeRandomColor(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
textWriter.WriteLine($"public static {data.ColorType.Name} MakeRandomColor()");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
textWriter.WriteLine($"public static {data.ColorType.Name} MakeRandomColor() => ColorRandom<{data.ColorType.Name}, {data.ChannelTypeName}>.MakeRandomColor();");
|
||||
}
|
||||
|
||||
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 WriteMakeRandomValue(this IndentedTextWriter textWriter, GenerationData data)
|
||||
{
|
||||
textWriter.WriteLine($"public static {data.ChannelTypeName} MakeRandomValue() => ColorRandom<{data.ColorType.Name}, {data.ChannelTypeName}>.MakeRandomValue();");
|
||||
}
|
||||
|
||||
private static void WriteMethodSymmetryTest(this IndentedTextWriter textWriter)
|
||||
@@ -210,7 +310,7 @@ internal static class TestClassGenerator
|
||||
textWriter.WriteLine("var color = MakeRandomColor();");
|
||||
textWriter.WriteLine("color.GetChannels(out var r, out var g, out var b, out var a);");
|
||||
textWriter.WriteLine("color.SetChannels(r, g, b, a);");
|
||||
textWriter.WriteLine("Assert.Multiple(() =>");
|
||||
textWriter.WriteLine("using (Assert.EnterMultipleScope())");
|
||||
textWriter.WriteLine("{");
|
||||
textWriter.Indent += 1;
|
||||
|
||||
@@ -220,16 +320,15 @@ internal static class TestClassGenerator
|
||||
}
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("});");
|
||||
textWriter.WriteLine("};");
|
||||
|
||||
textWriter.Indent -= 1;
|
||||
textWriter.WriteLine("}");
|
||||
}
|
||||
|
||||
private static void WriteNamespaceUsings(this IndentedTextWriter textWriter, GenerationData data)
|
||||
private static void WriteNamespaceUsings(this IndentedTextWriter textWriter, string? colorNamespace)
|
||||
{
|
||||
textWriter.WriteLine($"using {typeof(ColorExtensions).Namespace};");
|
||||
textWriter.WriteLine($"using {data.ColorType.Namespace};");
|
||||
textWriter.WriteLine($"using {colorNamespace};");
|
||||
textWriter.WriteLine($"using {typeof(System.Runtime.CompilerServices.Unsafe).Namespace};");
|
||||
textWriter.WriteLine();//An empty line after the usings
|
||||
}
|
||||
@@ -257,4 +356,4 @@ internal static class TestClassGenerator
|
||||
textWriter.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using AssetRipper.Text.SourceGeneration;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.TestGenerator;
|
||||
|
||||
internal static class TextureDataClassGenerator
|
||||
{
|
||||
private const string TestFilesFolder = $"{nameof(TestFileFolders)}.{nameof(TestFileFolders.AndroidTestFiles)}";
|
||||
private const string TextureType = "TextureType";
|
||||
private const string TextureFormat = "TextureFormat";
|
||||
private const string ITexture = "ITexture";
|
||||
private const string Namespace = "AssetRipper.TextureDecoder.Tests";
|
||||
|
||||
public static void Generate()
|
||||
{
|
||||
IReadOnlyList<TextureMetadata> metadataList = LoadMetadata(TestFileFolders.AndroidTestFiles);
|
||||
GenerateTextureType(metadataList);
|
||||
GenerateTextureFormat(metadataList);
|
||||
GenerateITexture();
|
||||
GenerateAndroidTextures(metadataList);
|
||||
}
|
||||
|
||||
private static void GenerateTextureType(IReadOnlyList<TextureMetadata> metadataList)
|
||||
{
|
||||
GenerateEnum(TextureType, metadataList.Select(m => m.Type).Distinct().Order());
|
||||
}
|
||||
|
||||
private static void GenerateTextureFormat(IReadOnlyList<TextureMetadata> metadataList)
|
||||
{
|
||||
GenerateEnum(TextureFormat, metadataList.Select(m => m.Format).Distinct().Order());
|
||||
}
|
||||
|
||||
private static void GenerateEnum(string name, IEnumerable<string?> values)
|
||||
{
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create(ProjectFolders.TestProject, name);
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLine();
|
||||
writer.WriteFileScopedNamespace(Namespace);
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"public enum {name}");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
foreach (string? value in values)
|
||||
{
|
||||
writer.WriteLine($"{value},");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateITexture()
|
||||
{
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create(ProjectFolders.TestProject, ITexture);
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLine();
|
||||
writer.WriteFileScopedNamespace(Namespace);
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"public partial interface {ITexture}");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine($"static abstract {TextureType} {nameof(TextureMetadata.Type)} {{ get; }}");
|
||||
writer.WriteLine($"static abstract {TextureFormat} {nameof(TextureMetadata.Format)} {{ get; }}");
|
||||
writer.WriteLine($"static abstract int {nameof(TextureMetadata.FileSize)} {{ get; }}");
|
||||
writer.WriteLine($"static abstract int {nameof(TextureMetadata.ImageSize)} {{ get; }}");
|
||||
writer.WriteLine($"static abstract int {nameof(TextureMetadata.ImageCount)} {{ get; }}");
|
||||
writer.WriteLine($"static abstract bool {nameof(TextureMetadata.Mips)} {{ get; }}");
|
||||
writer.WriteLine($"static abstract int {nameof(TextureMetadata.Width)} {{ get; }}");
|
||||
writer.WriteLine($"static abstract int {nameof(TextureMetadata.Height)} {{ get; }}");
|
||||
writer.WriteLine("static abstract string Path { get; }");
|
||||
writer.WriteLine("static abstract byte[] Data { get; }");
|
||||
}
|
||||
}
|
||||
|
||||
private static IReadOnlyList<TextureMetadata> LoadMetadata(string directory)
|
||||
{
|
||||
string[] jsonFiles = Directory.GetFiles(directory, "*.json");
|
||||
List<TextureMetadata> metadataList = new(jsonFiles.Length);
|
||||
foreach (string jsonFile in jsonFiles)
|
||||
{
|
||||
metadataList.Add(TextureMetadata.FromFile(jsonFile));
|
||||
}
|
||||
return metadataList;
|
||||
}
|
||||
|
||||
private static void GenerateAndroidTextures(IReadOnlyList<TextureMetadata> metadataList)
|
||||
{
|
||||
const string AndroidTextures = "AndroidTextures";
|
||||
using IndentedTextWriter writer = IndentedTextWriterFactory.Create(ProjectFolders.TestProject, AndroidTextures);
|
||||
writer.WriteGeneratedCodeWarning();
|
||||
writer.WriteLine();
|
||||
writer.WriteFileScopedNamespace(Namespace);
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"public static partial class {AndroidTextures}");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
foreach (TextureMetadata metadata in metadataList)
|
||||
{
|
||||
string withOrWithout = metadata.Mips ? "with" : "without";
|
||||
writer.WriteSummaryDocumentation($"{metadata.Format} {metadata.Width}x{metadata.Height} {withOrWithout} mips");
|
||||
writer.WriteLine($"public sealed class {metadata.Name} : {ITexture}");
|
||||
using (new CurlyBrackets(writer))
|
||||
{
|
||||
writer.WriteLine($"public const {TextureType} {nameof(TextureMetadata.Type)} = {TextureType}.{metadata.Type};");
|
||||
writer.WriteLine($"public const {TextureFormat} {nameof(TextureMetadata.Format)} = {TextureFormat}.{metadata.Format};");
|
||||
writer.WriteLine($"public const int {nameof(TextureMetadata.FileSize)} = {metadata.FileSize};");
|
||||
writer.WriteLine($"public const int {nameof(TextureMetadata.ImageSize)} = {metadata.ImageSize};");
|
||||
writer.WriteLine($"public const int {nameof(TextureMetadata.ImageCount)} = {metadata.ImageCount};");
|
||||
writer.WriteLine($"public const bool {nameof(TextureMetadata.Mips)} = {metadata.Mips.ToString().ToLowerInvariant()};");
|
||||
writer.WriteLine($"public const int {nameof(TextureMetadata.Width)} = {metadata.Width};");
|
||||
writer.WriteLine($"public const int {nameof(TextureMetadata.Height)} = {metadata.Height};");
|
||||
writer.WriteLine($"public const string Path = {TestFilesFolder} + \"{metadata.Name}\";");
|
||||
writer.WriteSummaryDocumentation($"Length: {metadata.FileSize}");
|
||||
writer.WriteLine("public static byte[] Data => File.ReadAllBytes(Path);");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"private {metadata.Name}() {{ }}");
|
||||
writer.WriteLine($"static {TextureType} {ITexture}.{nameof(TextureMetadata.Type)} => {nameof(TextureMetadata.Type)};");
|
||||
writer.WriteLine($"static {TextureFormat} {ITexture}.{nameof(TextureMetadata.Format)} => {nameof(TextureMetadata.Format)};");
|
||||
writer.WriteLine($"static int {ITexture}.{nameof(TextureMetadata.FileSize)} => {nameof(TextureMetadata.FileSize)};");
|
||||
writer.WriteLine($"static int {ITexture}.{nameof(TextureMetadata.ImageSize)} => {nameof(TextureMetadata.ImageSize)};");
|
||||
writer.WriteLine($"static int {ITexture}.{nameof(TextureMetadata.ImageCount)} => {nameof(TextureMetadata.ImageCount)};");
|
||||
writer.WriteLine($"static bool {ITexture}.{nameof(TextureMetadata.Mips)} => {nameof(TextureMetadata.Mips)};");
|
||||
writer.WriteLine($"static int {ITexture}.{nameof(TextureMetadata.Width)} => {nameof(TextureMetadata.Width)};");
|
||||
writer.WriteLine($"static int {ITexture}.{nameof(TextureMetadata.Height)} => {nameof(TextureMetadata.Height)};");
|
||||
writer.WriteLine($"static string {ITexture}.Path => Path;");
|
||||
}
|
||||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.TestGenerator;
|
||||
|
||||
public sealed class TextureMetadata
|
||||
{
|
||||
[JsonIgnore]
|
||||
public string? Name { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public string? Format { get; set; }
|
||||
public int FileSize { get; set; }
|
||||
public int ImageSize { get; set; }
|
||||
public int ImageCount { get; set; }
|
||||
public bool Mips { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
|
||||
public static TextureMetadata FromFile(string path)
|
||||
{
|
||||
using FileStream stream = File.OpenRead(path);
|
||||
TextureMetadata result = JsonSerializer.Deserialize(stream, TextureMetadataSerializerContext.Default.TextureMetadata)
|
||||
?? throw new NullReferenceException(nameof(TextureMetadata));
|
||||
result.Name = Path.GetFileNameWithoutExtension(path);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.TestGenerator;
|
||||
|
||||
[JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Metadata)]
|
||||
[JsonSerializable(typeof(TextureMetadata))]
|
||||
internal sealed partial class TextureMetadataSerializerContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
global using AssetRipper.TextureDecoder.Paths;
|
||||
@@ -0,0 +1,720 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests;
|
||||
|
||||
public static partial class AndroidTextures
|
||||
{
|
||||
/// <summary>
|
||||
/// BGRA32_14 512x512 without mips
|
||||
/// </summary>
|
||||
public sealed class Logo_00 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.BGRA32_14;
|
||||
public const int FileSize = 1048576;
|
||||
public const int ImageSize = 1048576;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = false;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_00";
|
||||
/// <summary>
|
||||
/// Length: 1048576
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_00() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_12x12 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_01 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_12x12;
|
||||
public const int FileSize = 40112;
|
||||
public const int ImageSize = 40112;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_01";
|
||||
/// <summary>
|
||||
/// Length: 40112
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_01() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_RGB_10x10 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_02 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_RGB_10x10;
|
||||
public const int FileSize = 57952;
|
||||
public const int ImageSize = 57952;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_02";
|
||||
/// <summary>
|
||||
/// Length: 57952
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_02() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_RGB_8x8 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_03 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_RGB_8x8;
|
||||
public const int FileSize = 87424;
|
||||
public const int ImageSize = 87424;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_03";
|
||||
/// <summary>
|
||||
/// Length: 87424
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_03() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_6x6 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_04 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_6x6;
|
||||
public const int FileSize = 158432;
|
||||
public const int ImageSize = 158432;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_04";
|
||||
/// <summary>
|
||||
/// Length: 158432
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_04() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_5x5 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_05 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_5x5;
|
||||
public const int FileSize = 227680;
|
||||
public const int ImageSize = 227680;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_05";
|
||||
/// <summary>
|
||||
/// Length: 227680
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_05() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_RGB_4x4 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_06 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_RGB_4x4;
|
||||
public const int FileSize = 349552;
|
||||
public const int ImageSize = 349552;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_06";
|
||||
/// <summary>
|
||||
/// Length: 349552
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_06() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ETC2_RGBA8 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_07 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ETC2_RGBA8;
|
||||
public const int FileSize = 349552;
|
||||
public const int ImageSize = 349552;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_07";
|
||||
/// <summary>
|
||||
/// Length: 349552
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_07() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ETC2_RGBA1 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_08 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ETC2_RGBA1;
|
||||
public const int FileSize = 174776;
|
||||
public const int ImageSize = 174776;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_08";
|
||||
/// <summary>
|
||||
/// Length: 174776
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_08() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PVRTC_4BPP_RGBA 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_09 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.PVRTC_4BPP_RGBA;
|
||||
public const int FileSize = 174848;
|
||||
public const int ImageSize = 174848;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_09";
|
||||
/// <summary>
|
||||
/// Length: 174848
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_09() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PVRTC_RGBA2 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_10 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.PVRTC_RGBA2;
|
||||
public const int FileSize = 87488;
|
||||
public const int ImageSize = 87488;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_10";
|
||||
/// <summary>
|
||||
/// Length: 87488
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_10() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ETC2_RGB 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_11 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ETC2_RGB;
|
||||
public const int FileSize = 174776;
|
||||
public const int ImageSize = 174776;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_11";
|
||||
/// <summary>
|
||||
/// Length: 174776
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_11() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ETC_RGB4 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_12 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ETC_RGB4;
|
||||
public const int FileSize = 174776;
|
||||
public const int ImageSize = 174776;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_12";
|
||||
/// <summary>
|
||||
/// Length: 174776
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_12() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PVRTC_4BPP_RGB 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_13 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.PVRTC_4BPP_RGB;
|
||||
public const int FileSize = 174848;
|
||||
public const int ImageSize = 174848;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_13";
|
||||
/// <summary>
|
||||
/// Length: 174848
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_13() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PVRTC_2BPP_RGB 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_14 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.PVRTC_2BPP_RGB;
|
||||
public const int FileSize = 87488;
|
||||
public const int ImageSize = 87488;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_14";
|
||||
/// <summary>
|
||||
/// Length: 87488
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_14() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EAC_RG 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_15 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.EAC_RG;
|
||||
public const int FileSize = 349552;
|
||||
public const int ImageSize = 349552;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_15";
|
||||
/// <summary>
|
||||
/// Length: 349552
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_15() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EAC_R 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_16 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.EAC_R;
|
||||
public const int FileSize = 174776;
|
||||
public const int ImageSize = 174776;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_16";
|
||||
/// <summary>
|
||||
/// Length: 174776
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_16() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_HDR_12x12 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_17 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_HDR_12x12;
|
||||
public const int FileSize = 40112;
|
||||
public const int ImageSize = 40112;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_17";
|
||||
/// <summary>
|
||||
/// Length: 40112
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_17() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_HDR_10x10 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_18 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_HDR_10x10;
|
||||
public const int FileSize = 57952;
|
||||
public const int ImageSize = 57952;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_18";
|
||||
/// <summary>
|
||||
/// Length: 57952
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_18() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_HDR_8x8 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_19 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_HDR_8x8;
|
||||
public const int FileSize = 87424;
|
||||
public const int ImageSize = 87424;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_19";
|
||||
/// <summary>
|
||||
/// Length: 87424
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_19() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_HDR_6x6 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_20 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_HDR_6x6;
|
||||
public const int FileSize = 158432;
|
||||
public const int ImageSize = 158432;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_20";
|
||||
/// <summary>
|
||||
/// Length: 158432
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_20() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_HDR_5x5 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_21 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_HDR_5x5;
|
||||
public const int FileSize = 227680;
|
||||
public const int ImageSize = 227680;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_21";
|
||||
/// <summary>
|
||||
/// Length: 227680
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_21() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASTC_HDR_4x4 512x512 with mips
|
||||
/// </summary>
|
||||
public sealed class Logo_22 : ITexture
|
||||
{
|
||||
public const TextureType Type = TextureType.Texture2D;
|
||||
public const TextureFormat Format = TextureFormat.ASTC_HDR_4x4;
|
||||
public const int FileSize = 349552;
|
||||
public const int ImageSize = 349552;
|
||||
public const int ImageCount = 1;
|
||||
public const bool Mips = true;
|
||||
public const int Width = 512;
|
||||
public const int Height = 512;
|
||||
public const string Path = TestFileFolders.AndroidTestFiles + "Logo_22";
|
||||
/// <summary>
|
||||
/// Length: 349552
|
||||
/// </summary>
|
||||
public static byte[] Data => File.ReadAllBytes(Path);
|
||||
|
||||
private Logo_22() { }
|
||||
static TextureType ITexture.Type => Type;
|
||||
static TextureFormat ITexture.Format => Format;
|
||||
static int ITexture.FileSize => FileSize;
|
||||
static int ITexture.ImageSize => ImageSize;
|
||||
static int ITexture.ImageCount => ImageCount;
|
||||
static bool ITexture.Mips => Mips;
|
||||
static int ITexture.Width => Width;
|
||||
static int ITexture.Height => Height;
|
||||
static string ITexture.Path => Path;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
|
||||
<PackageReference Include="NUnit" Version="4.5.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="6.1.0" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.11.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="8.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AssetRipper.TextureDecoder.Paths\AssetRipper.TextureDecoder.Paths.csproj" />
|
||||
<ProjectReference Include="..\AssetRipper.TextureDecoder\AssetRipper.TextureDecoder.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
using AssetRipper.TextureDecoder.Astc;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests;
|
||||
|
||||
public sealed class AstcTests
|
||||
{
|
||||
private const double MaxMeanDeviation4x4 = 0.2;
|
||||
private const double MaxStandardDeviation4x4 = 1;
|
||||
|
||||
private const double MaxMeanDeviation5x5 = 0.2;
|
||||
private const double MaxStandardDeviation5x5 = 1;
|
||||
|
||||
private const double MaxMeanDeviation6x6 = 0.2;
|
||||
private const double MaxStandardDeviation6x6 = 1;
|
||||
|
||||
private const double MaxMeanDeviation8x8 = 0.2;
|
||||
private const double MaxStandardDeviation8x8 = 2;
|
||||
|
||||
private const double MaxMeanDeviation10x10 = 0.2;
|
||||
private const double MaxStandardDeviation10x10 = 2.5;
|
||||
|
||||
private const double MaxMeanDeviation12x12 = 0.3;
|
||||
private const double MaxStandardDeviation12x12 = 3;
|
||||
|
||||
[Test]
|
||||
public void DecompressAstc4x4() => AssertCorrectDecompression<AndroidTextures.Logo_06>(4, 4, MaxMeanDeviation4x4, MaxStandardDeviation4x4);
|
||||
|
||||
[Test]
|
||||
public void DecompressAstc5x5() => AssertCorrectDecompression<AndroidTextures.Logo_05>(5, 5, MaxMeanDeviation5x5, MaxStandardDeviation5x5);
|
||||
|
||||
[Test]
|
||||
public void DecompressAstc6x6() => AssertCorrectDecompression<AndroidTextures.Logo_04>(6, 6, MaxMeanDeviation6x6, MaxStandardDeviation6x6);
|
||||
|
||||
[Test]
|
||||
public void DecompressAstc8x8() => AssertCorrectDecompression<AndroidTextures.Logo_03>(8, 8, MaxMeanDeviation8x8, MaxStandardDeviation8x8);
|
||||
|
||||
[Test]
|
||||
public void DecompressAstc10x10() => AssertCorrectDecompression<AndroidTextures.Logo_02>(10, 10, MaxMeanDeviation10x10, MaxStandardDeviation10x10);
|
||||
|
||||
[Test]
|
||||
public void DecompressAstc12x12() => AssertCorrectDecompression<AndroidTextures.Logo_01>(12, 12, MaxMeanDeviation12x12, MaxStandardDeviation12x12);
|
||||
|
||||
[Test]
|
||||
[Ignore("High dynamic range textures are not supported yet.")]
|
||||
public void DecompressAstc4x4HDR() => AssertCorrectDecompression<AndroidTextures.Logo_22>(4, 4, MaxMeanDeviation4x4, MaxStandardDeviation4x4);
|
||||
|
||||
[Test]
|
||||
[Ignore("High dynamic range textures are not supported yet.")]
|
||||
public void DecompressAstc5x5HDR() => AssertCorrectDecompression<AndroidTextures.Logo_21>(5, 5, MaxMeanDeviation5x5, MaxStandardDeviation5x5);
|
||||
|
||||
[Test]
|
||||
[Ignore("High dynamic range textures are not supported yet.")]
|
||||
public void DecompressAstc6x6HDR() => AssertCorrectDecompression<AndroidTextures.Logo_20>(6, 6, MaxMeanDeviation6x6, MaxStandardDeviation6x6);
|
||||
|
||||
[Test]
|
||||
[Ignore("High dynamic range textures are not supported yet.")]
|
||||
public void DecompressAstc8x8HDR() => AssertCorrectDecompression<AndroidTextures.Logo_19>(8, 8, MaxMeanDeviation8x8, MaxStandardDeviation8x8);
|
||||
|
||||
[Test]
|
||||
[Ignore("High dynamic range textures are not supported yet.")]
|
||||
public void DecompressAstc10x10HDR() => AssertCorrectDecompression<AndroidTextures.Logo_18>(10, 10, MaxMeanDeviation10x10, MaxStandardDeviation10x10);
|
||||
|
||||
[Test]
|
||||
[Ignore("High dynamic range textures are not supported yet.")]
|
||||
public void DecompressAstc12x12HDR() => AssertCorrectDecompression<AndroidTextures.Logo_17>(4, 4, MaxMeanDeviation12x12, MaxStandardDeviation12x12);
|
||||
|
||||
private static void AssertCorrectDecompression<T>(int blockWidth, int blockHeight, double maxMeanDeviation, double maxStandardDeviation) where T : ITexture
|
||||
{
|
||||
ReadOnlySpan<byte> data = T.Data;
|
||||
int bytesRead = AstcDecoder.DecodeASTC<ColorBGRA<byte>, byte>(data, T.Width, T.Height, blockWidth, blockHeight, out byte[] decompressedData);
|
||||
if (!T.Mips)
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
ByteArrayDeviation.AssertMinimalDeviation(decompressedData, AndroidTextures.Logo_00.Data, maxMeanDeviation, maxStandardDeviation);
|
||||
}
|
||||
|
||||
[TestCase(new byte[16] { 83, 1, 147, 104, 198, 173, 55, 116, 182, 66, 105, 11, 102, 43, 148, 125 }, 8, 8, TestName = "GetBits Should not throw in DecodeIntseq")]
|
||||
public void DecodesBlockWithoutThrowing(byte[] block, int blockWidth, int blockHeight)
|
||||
{
|
||||
Assert.DoesNotThrow(() => AstcDecoder.DecodeASTC<ColorBGRA<byte>, byte>(block, blockWidth, blockHeight, blockWidth, blockHeight, out _));
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,31 @@
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
public sealed class AtcTests
|
||||
{
|
||||
[Test]
|
||||
public void DecompressAtcRgb4Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.AtcTestFilesFolder + "test.atc_rgb4");
|
||||
int bytesRead = Atc.AtcDecoder.DecompressAtcRgb4(data, 256, 256, out _);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
byte[] data = File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgb4");
|
||||
int bytesRead = Atc.AtcDecoder.DecompressAtcRgb4<ColorBGRA<byte>, byte>(data, 256, 256, out byte[] decodedData);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Is.EqualTo(File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgb4_decoded")));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressAtcRgba8Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.AtcTestFilesFolder + "test.atc_rgba8");
|
||||
int bytesRead = Atc.AtcDecoder.DecompressAtcRgba8(data, 256, 256, out _);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
byte[] data = File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgba8");
|
||||
int bytesRead = Atc.AtcDecoder.DecompressAtcRgba8<ColorBGRA<byte>, byte>(data, 256, 256, out byte[] decodedData);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Is.EqualTo(File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgba8_decoded")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using AssetRipper.TextureDecoder.Bc;
|
||||
using AssetRipper.TextureDecoder.Dxt;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
@@ -15,18 +17,18 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[SetUp]
|
||||
public void InitializeOriginalData()
|
||||
{
|
||||
originalBgra32LogoData = File.ReadAllBytes(PathConstants.BcTestFilesFolder + "test.bgra32");
|
||||
originalBgra32LogoData = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bgra32");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressDXT1Test()
|
||||
public void Decompress_BC1()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.DxtTestFilesFolder + "test.dxt1");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt1");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output
|
||||
{
|
||||
int bytesRead = Bc1.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT1(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
int bytesRead = Bc1.Decompress<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT1<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
|
||||
}
|
||||
@@ -34,14 +36,14 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressDXT3Test()
|
||||
public void Decompress_BC2()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.DxtTestFilesFolder + "test.dxt3");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt3");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output
|
||||
{
|
||||
int bytesRead = Bc2.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT3(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
int bytesRead = Bc2.Decompress<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT3<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
|
||||
}
|
||||
@@ -49,14 +51,14 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressDXT5Test()
|
||||
public void Decompress_BC3()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.DxtTestFilesFolder + "test.dxt5");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt5");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output
|
||||
{
|
||||
int bytesRead = Bc3.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT5(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
int bytesRead = Bc3.Decompress<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
|
||||
DxtDecoder.DecompressDXT5<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
|
||||
}
|
||||
@@ -64,71 +66,135 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressBC4Test()
|
||||
public void Decompress_BC4()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.BcTestFilesFolder + "test.bc4");
|
||||
int bytesRead = Bc4.Decompress(data, 512, 512, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc4");
|
||||
int bytesRead = Bc4.Decompress<ColorBGRA<byte>, byte>(data, 512, 512, out _);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressBC5Test()
|
||||
public void Decompress_BC5()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.BcTestFilesFolder + "test.bc5");
|
||||
int bytesRead = Bc5.Decompress(data, 512, 512, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc5");
|
||||
int bytesRead = Bc5.Decompress<ColorBGRA<byte>, byte>(data, 512, 512, out _);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressBC6HFastTest()
|
||||
[TestCase("test.bc6h_fast")]
|
||||
[TestCase("test.bc6h_normal")]
|
||||
[TestCase("test.bc6h_best")]
|
||||
public void Decompress_BC6H(string fileName)
|
||||
{
|
||||
AssertCorrectBC6HDecompression(PathConstants.BcTestFilesFolder + "test.bc6h_fast", 512, 512, false);
|
||||
AssertCorrectBC6HDecompression(TestFileFolders.BcTestFiles + fileName, 512, 512, false);
|
||||
}
|
||||
|
||||
[TestCase("test.bc7_fast")]
|
||||
[TestCase("test.bc7_normal")]
|
||||
[TestCase("test.bc7_best")]
|
||||
public void Decompress_BC7(string fileName)
|
||||
{
|
||||
AssertCorrectBC7Decompression(TestFileFolders.BcTestFiles + fileName, 512, 512);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressBC6HNormalTest()
|
||||
public void PartialBlock_BC1([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
AssertCorrectBC6HDecompression(PathConstants.BcTestFilesFolder + "test.bc6h_normal", 512, 512, false);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt1").AsSpan()[..Bc1.BlockSize];
|
||||
int bytesRead = Bc1.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressBC6HBestTest()
|
||||
public void PartialBlock_BC2([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
AssertCorrectBC6HDecompression(PathConstants.BcTestFilesFolder + "test.bc6h_best", 512, 512, false);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt3").AsSpan()[..Bc2.BlockSize];
|
||||
int bytesRead = Bc2.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressBC7FastTest()
|
||||
public void PartialBlock_BC3([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
AssertCorrectBC7Decompression(PathConstants.BcTestFilesFolder + "test.bc7_fast", 512, 512);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt5").AsSpan()[..Bc3.BlockSize];
|
||||
int bytesRead = Bc3.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressBC7NormalTest()
|
||||
public void PartialBlock_BC4([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
AssertCorrectBC7Decompression(PathConstants.BcTestFilesFolder + "test.bc7_normal", 512, 512);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc4").AsSpan()[..Bc4.BlockSize];
|
||||
int bytesRead = Bc4.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressBC7BestTest()
|
||||
public void PartialBlock_BC5([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
AssertCorrectBC7Decompression(PathConstants.BcTestFilesFolder + "test.bc7_best", 512, 512);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc5").AsSpan()[..Bc5.BlockSize];
|
||||
int bytesRead = Bc5.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartialBlock_BC6H([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc6h_best").AsSpan()[..Bc6h.BlockSize];
|
||||
int bytesRead = Bc6h.Decompress<ColorBGRA<byte>, byte>(data, width, height, false, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartialBlock_BC7([Range(1, 4)] int width, [Range(1, 4)] int height)
|
||||
{
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc7_best").AsSpan()[..Bc7.BlockSize];
|
||||
int bytesRead = Bc7.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertCorrectBC6HDecompression(string path, int width, int height, bool isSigned)
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(path);
|
||||
int bytesRead = Bc6h.Decompress(data, width, height, isSigned, out byte[] decodedData);
|
||||
int bytesRead = Bc6h.Decompress<ColorBGRA<byte>, byte>(data, width, height, isSigned, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
AssertMinimalDeviation(decodedData, originalBgra32LogoData, MaxMeanDeviationBc6h, MaxStandardDeviationBc6h);
|
||||
ByteArrayDeviation.AssertMinimalDeviation(decodedData, originalBgra32LogoData, MaxMeanDeviationBc6h, MaxStandardDeviationBc6h);
|
||||
}
|
||||
|
||||
private static void AssertCorrectBC7Decompression(string path, int width, int height)
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(path);
|
||||
int bytesRead = Bc7.Decompress(data, width, height, out byte[] decodedData);
|
||||
int bytesRead = Bc7.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
AssertMinimalDeviation(decodedData, originalBgra32LogoData, MaxMeanDeviationBc7, MaxStandardDeviationBc7);
|
||||
ByteArrayDeviation.AssertMinimalDeviation(decodedData, originalBgra32LogoData, MaxMeanDeviationBc7, MaxStandardDeviationBc7);
|
||||
}
|
||||
|
||||
private static void AssertAlmostEqual(byte[] array1, byte[] array2, int maxDifference = 2)
|
||||
@@ -149,41 +215,5 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertMinimalDeviation(byte[] decoded, byte[] original, double maxMeanDeviation, double maxStandardDeviation)
|
||||
{
|
||||
if (decoded.Length != original.Length)
|
||||
{
|
||||
Assert.Fail($"Differing array lengths\nDecoded length {decoded.Length}\nOriginal length {original.Length}");
|
||||
return;
|
||||
}
|
||||
|
||||
long differenceSum = 0;
|
||||
|
||||
for (int i = 0; i < decoded.Length; i++)
|
||||
{
|
||||
differenceSum += decoded[i] - original[i];
|
||||
}
|
||||
|
||||
double mean = differenceSum / (double)decoded.Length;
|
||||
|
||||
double sumOfSquaredDeviations = 0;
|
||||
|
||||
for (int i = 0; i < decoded.Length; i++)
|
||||
{
|
||||
double deviation = decoded[i] - original[i] - mean;
|
||||
sumOfSquaredDeviations += deviation * deviation;
|
||||
}
|
||||
|
||||
double standardDeviation = Math.Sqrt(sumOfSquaredDeviations / (decoded.Length - 1));
|
||||
//Not sure if Bessel's correction is needed here, but it doesn't hurt, especially since length is around 1 million in the current use.
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(mean, Is.LessThan(maxMeanDeviation), "Mean too far positive");
|
||||
Assert.That(mean, Is.GreaterThan(-maxMeanDeviation), "Mean too far negative");
|
||||
Assert.That(standardDeviation, Is.LessThan(maxStandardDeviation), "Standard deviation too large");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace AssetRipper.TextureDecoder.Tests;
|
||||
|
||||
internal static class ByteArrayDeviation
|
||||
{
|
||||
internal static void AssertMinimalDeviation(byte[] decoded, byte[] original, double maxMeanDeviation, double maxStandardDeviation)
|
||||
{
|
||||
if (decoded.Length != original.Length)
|
||||
{
|
||||
Assert.Fail($"Differing array lengths\nDecoded length {decoded.Length}\nOriginal length {original.Length}");
|
||||
return;
|
||||
}
|
||||
|
||||
long differenceSum = 0;
|
||||
|
||||
for (int i = 0; i < decoded.Length; i++)
|
||||
{
|
||||
differenceSum += decoded[i] - original[i];
|
||||
}
|
||||
|
||||
double mean = differenceSum / (double)decoded.Length;
|
||||
|
||||
double sumOfSquaredDeviations = 0;
|
||||
|
||||
for (int i = 0; i < decoded.Length; i++)
|
||||
{
|
||||
double deviation = decoded[i] - original[i] - mean;
|
||||
sumOfSquaredDeviations += deviation * deviation;
|
||||
}
|
||||
|
||||
double standardDeviation = Math.Sqrt(sumOfSquaredDeviations / (decoded.Length - 1));
|
||||
//Not sure if Bessel's correction is needed here, but it doesn't hurt, especially since length is around 1 million in the current use.
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(mean, Is.LessThan(maxMeanDeviation), "Mean too far positive");
|
||||
Assert.That(mean, Is.GreaterThan(-maxMeanDeviation), "Mean too far negative");
|
||||
Assert.That(standardDeviation, Is.LessThan(maxStandardDeviation), "Standard deviation too large");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,17 @@
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
public sealed class DxtTests
|
||||
{
|
||||
[Test]
|
||||
public void DecompressDXT1Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.DxtTestFilesFolder + "test.dxt1");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt1");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT1(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT1<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -18,11 +20,11 @@
|
||||
[Test]
|
||||
public void DecompressDXT3Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.DxtTestFilesFolder + "test.dxt3");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt3");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT3(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT3<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -31,14 +33,14 @@
|
||||
[Test]
|
||||
public void DecompressDXT5Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.DxtTestFilesFolder + "test.dxt5");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt5");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT5(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = Dxt.DxtDecoder.DecompressDXT5<ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,109 +1,102 @@
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
using AssetRipper.TextureDecoder.Etc;
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests;
|
||||
|
||||
public sealed class EtcTests
|
||||
{
|
||||
public sealed class EtcTests
|
||||
private static DecodingDelegate ETCDelegate { get; } = EtcDecoder.DecompressETC<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate ETC2Delegate { get; } = EtcDecoder.DecompressETC2<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate ETC2A1Delegate { get; } = EtcDecoder.DecompressETC2A1<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate ETC2A8Delegate { get; } = EtcDecoder.DecompressETC2A8<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate EACRSignedDelegate { get; } = EtcDecoder.DecompressEACRSigned<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate EACRUnsignedDelegate { get; } = EtcDecoder.DecompressEACRUnsigned<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate EACRGSignedDelegate { get; } = EtcDecoder.DecompressEACRGSigned<ColorBGRA<byte>, byte>;
|
||||
private static DecodingDelegate EACRGUnsignedDelegate { get; } = EtcDecoder.DecompressEACRGUnsigned<ColorBGRA<byte>, byte>;
|
||||
|
||||
[Test]
|
||||
public void DecompressETCTest() => AssertCorrectByteCountReadFor256SquareWithMips(TestFileFolders.EtcTestFiles + "test.etc", ETCDelegate);
|
||||
|
||||
[Test]
|
||||
public void DecompressETC2Test() => AssertCorrectByteCountReadFor256SquareWithMips(TestFileFolders.EtcTestFiles + "test.etc2", ETC2Delegate);
|
||||
|
||||
[Test]
|
||||
public void DecompressETC2A1Test() => AssertCorrectByteCountReadFor256SquareWithMips(TestFileFolders.EtcTestFiles + "test.etc2a1", ETC2A1Delegate);
|
||||
|
||||
[Test]
|
||||
public void DecompressETC2A8Test() => AssertCorrectByteCountReadFor256SquareWithMips(TestFileFolders.EtcTestFiles + "test.etc2a8", ETC2A8Delegate);
|
||||
|
||||
[Test]
|
||||
public void DecompressEACRSignedTest() => AssertCorrectByteCountReadFor256SquareWithMips(TestFileFolders.EtcTestFiles + "test.eac_r", EACRSignedDelegate);
|
||||
|
||||
[Test]
|
||||
public void DecompressEACRUnsignedTest() => AssertCorrectByteCountReadFor256SquareWithMips(TestFileFolders.EtcTestFiles + "test.eac_r", EACRUnsignedDelegate);
|
||||
|
||||
[Test]
|
||||
public void DecompressEACRGSignedTest() => AssertCorrectByteCountReadFor256SquareWithMips(TestFileFolders.EtcTestFiles + "test.eac_rg", EACRGSignedDelegate);
|
||||
|
||||
[Test]
|
||||
public void DecompressEACRGUnsignedTest() => AssertCorrectByteCountReadFor256SquareWithMips(TestFileFolders.EtcTestFiles + "test.eac_rg", EACRGUnsignedDelegate);
|
||||
|
||||
[Test]
|
||||
public void CorrectnessETCTest() => AssertCorrectDecompression<AndroidTextures.Logo_12, ColorRGB<byte>>(ETCDelegate, .05, 2.1);
|
||||
|
||||
[Test]
|
||||
public void CorrectnessETC2Test() => AssertCorrectDecompression<AndroidTextures.Logo_11, ColorRGB<byte>>(ETC2Delegate, .15, 1.6);
|
||||
|
||||
[Test]
|
||||
public void CorrectnessETC2A1Test() => AssertCorrectDecompression<AndroidTextures.Logo_08>(ETC2A1Delegate, .15, 1.7);
|
||||
|
||||
[Test]
|
||||
public void CorrectnessETC2A8Test() => AssertCorrectDecompression<AndroidTextures.Logo_07>(ETC2A8Delegate, .15, 1.6);
|
||||
|
||||
[Test]
|
||||
public void CorrectnessEACRUnsignedTest() => AssertCorrectDecompression<AndroidTextures.Logo_16, ColorR<byte>>(EACRUnsignedDelegate, .05, .5);
|
||||
|
||||
[Test]
|
||||
public void CorrectnessEACRGUnsignedTest() => AssertCorrectDecompression<AndroidTextures.Logo_15, ColorRG<byte>>(EACRGUnsignedDelegate, .1, .6);
|
||||
|
||||
private delegate int DecodingDelegate(ReadOnlySpan<byte> data, int width, int height, out byte[] decompressedData);
|
||||
|
||||
private static void AssertCorrectByteCountReadFor256SquareWithMips(string path, DecodingDelegate decoder)
|
||||
{
|
||||
[Test]
|
||||
public void DecompressETCTest()
|
||||
byte[] data = File.ReadAllBytes(path);
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.EtcTestFilesFolder + "test.etc");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Etc.EtcDecoder.DecompressETC(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressETC2Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.EtcTestFilesFolder + "test.etc2");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Etc.EtcDecoder.DecompressETC2(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressETC2A1Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.EtcTestFilesFolder + "test.etc2a1");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Etc.EtcDecoder.DecompressETC2A1(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressETC2A8Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.EtcTestFilesFolder + "test.etc2a8");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Etc.EtcDecoder.DecompressETC2A8(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressEACRSignedTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.EtcTestFilesFolder + "test.eac_r");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Etc.EtcDecoder.DecompressEACRSigned(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressEACRUnsignedTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.EtcTestFilesFolder + "test.eac_r");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Etc.EtcDecoder.DecompressEACRUnsigned(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressEACRGSignedTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.EtcTestFilesFolder + "test.eac_rg");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Etc.EtcDecoder.DecompressEACRGSigned(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecompressEACRGUnsignedTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.EtcTestFilesFolder + "test.eac_rg");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Etc.EtcDecoder.DecompressEACRGUnsigned(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
int bytesRead = decoder.Invoke(new ReadOnlySpan<byte>(data, totalBytesRead, data.Length - totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertCorrectDecompression<T>(DecodingDelegate decoder, double maxMeanDeviation, double maxStandardDeviation) where T : ITexture
|
||||
{
|
||||
AssertCorrectDecompression<T, ColorRGBA<byte>>(decoder, maxMeanDeviation, maxStandardDeviation);
|
||||
}
|
||||
|
||||
private static void AssertCorrectDecompression<TTexture, TColor>(DecodingDelegate decoder, double maxMeanDeviation, double maxStandardDeviation) where TTexture : ITexture where TColor : unmanaged, IColor<TColor, byte>
|
||||
{
|
||||
byte[] data = TTexture.Data;
|
||||
int bytesRead = decoder.Invoke(new ReadOnlySpan<byte>(data), TTexture.Width, TTexture.Height, out byte[] decompressedData);
|
||||
if (!TTexture.Mips)
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
byte[] comparisonData = AndroidTextures.Logo_00.Data;
|
||||
|
||||
//Remove unused color channels
|
||||
if (typeof(TColor) != typeof(ColorBGRA<byte>) && typeof(TColor) != typeof(ColorRGBA<byte>))
|
||||
{
|
||||
Span<ColorBGRA<byte>> pixels = MemoryMarshal.Cast<byte, ColorBGRA<byte>>((Span<byte>)comparisonData);
|
||||
for (int i = 0; i < pixels.Length; i++)
|
||||
{
|
||||
pixels[i] = pixels[i].Convert<ColorBGRA<byte>, byte, TColor, byte>().Convert<TColor, byte, ColorBGRA<byte>, byte>();
|
||||
}
|
||||
}
|
||||
|
||||
ByteArrayDeviation.AssertMinimalDeviation(decompressedData, comparisonData, maxMeanDeviation, maxStandardDeviation);
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
//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 ColorA8Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorA8>(), 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 ColorA8 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0b11010101,
|
||||
G = 0b01110010,
|
||||
B = 0b10001111,
|
||||
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,6 +1,5 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -13,7 +12,7 @@ public partial class ColorARGB16Tests
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorARGB16>(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_R()
|
||||
{
|
||||
@@ -57,13 +56,13 @@ public partial class ColorARGB16Tests
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.R = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -73,13 +72,13 @@ public partial class ColorARGB16Tests
|
||||
var r = color.R;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.G = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -89,13 +88,13 @@ public partial class ColorARGB16Tests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.B = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -105,13 +104,13 @@ public partial class ColorARGB16Tests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.A = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -119,92 +118,103 @@ public partial class ColorARGB16Tests
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
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(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorARGB16 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0b11010101,
|
||||
G = 0b01110010,
|
||||
B = 0b10001111,
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static ColorARGB16 MakeRandomColor() => ColorRandom<ColorARGB16, byte>.MakeRandomColor();
|
||||
|
||||
public static byte MakeRandomValue() => ColorRandom<ColorARGB16, byte>.MakeRandomValue();
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_sbyte()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<sbyte>, sbyte>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_byte()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<byte>, byte>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_short()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<short>, short>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_ushort()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<ushort>, ushort>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_int()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<int>, int>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_uint()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<uint>, uint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_nint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<nint>, nint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_nuint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<nuint>, nuint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_long()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<long>, long>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_ulong()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<ulong>, ulong>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_Int128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<Int128>, Int128>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_UInt128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorARGB16, byte, ColorRGBA<UInt128>, UInt128>();
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
//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 ColorARGB32Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorARGB32>(), Is.EqualTo(4));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_R()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var r = color.R;
|
||||
color.R = r;
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_G()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var g = color.G;
|
||||
color.G = g;
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_B()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var b = color.B;
|
||||
color.B = b;
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_A()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var a = color.A;
|
||||
color.A = a;
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_R()
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = 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 ColorARGB32 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0b11010101,
|
||||
G = 0b01110010,
|
||||
B = 0b10001111,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
//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));
|
||||
}
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
//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));
|
||||
}
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
//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,228 +0,0 @@
|
||||
//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 ColorR16Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorR16>(), 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 = 33871;
|
||||
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 = 33871;
|
||||
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 = 33871;
|
||||
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 = 33871;
|
||||
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 ColorR16 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 44000,
|
||||
G = 21354,
|
||||
B = 60080,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
//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));
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
//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));
|
||||
}
|
||||
}
|
||||
@@ -1,318 +0,0 @@
|
||||
//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,318 +0,0 @@
|
||||
//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 ColorR8Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorR8>(), 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 ColorR8 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0b11010101,
|
||||
G = 0b01110010,
|
||||
B = 0b10001111,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
//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 ColorRG128DoubleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRG128Double>(), Is.EqualTo(16));
|
||||
}
|
||||
|
||||
[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 ColorRG128Double MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,282 +0,0 @@
|
||||
//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,282 +0,0 @@
|
||||
//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 ColorRG16Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRG16>(), 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 ColorRG16 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0b11010101,
|
||||
G = 0b01110010,
|
||||
B = 0b10001111,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
//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));
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
//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,210 +0,0 @@
|
||||
//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 ColorRG32Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRG32>(), 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 = 33871;
|
||||
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 = 33871;
|
||||
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 = 33871;
|
||||
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 = 33871;
|
||||
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 ColorRG32 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 44000,
|
||||
G = 21354,
|
||||
B = 60080,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
//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,6 +1,5 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -13,7 +12,7 @@ public partial class ColorRGB16Tests
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB16>(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_R()
|
||||
{
|
||||
@@ -57,13 +56,13 @@ public partial class ColorRGB16Tests
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.R = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -73,13 +72,13 @@ public partial class ColorRGB16Tests
|
||||
var r = color.R;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.G = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -89,13 +88,13 @@ public partial class ColorRGB16Tests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.B = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -105,13 +104,13 @@ public partial class ColorRGB16Tests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.A = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -119,128 +118,175 @@ public partial class ColorRGB16Tests
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
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(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRGB16 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0b11010101,
|
||||
G = 0b01110010,
|
||||
B = 0b10001111,
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static ColorRGB16 MakeRandomColor() => ColorRandom<ColorRGB16, byte>.MakeRandomColor();
|
||||
|
||||
public static byte MakeRandomValue() => ColorRandom<ColorRGB16, byte>.MakeRandomValue();
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_sbyte()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<sbyte>, sbyte>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
public void ConversionIsLosslessToColorRGB_sbyte()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<sbyte>, sbyte>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_byte()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<byte>, byte>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB24SignedIsLossless()
|
||||
public void ConversionIsLosslessToColorRGB_byte()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<byte>, byte>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_short()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<short>, short>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB48SignedIsLossless()
|
||||
public void ConversionIsLosslessToColorRGB_short()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<short>, short>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_ushort()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<ushort>, ushort>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
public void ConversionIsLosslessToColorRGB_ushort()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<ushort>, ushort>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_int()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<int>, int>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
public void ConversionIsLosslessToColorRGB_int()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<int>, int>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_uint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<uint>, uint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGB_uint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<uint>, uint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_nint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<nint>, nint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGB_nint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<nint>, nint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_nuint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<nuint>, nuint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGB_nuint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<nuint>, nuint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_long()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<long>, long>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGB_long()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<long>, long>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_ulong()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<ulong>, ulong>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGB_ulong()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<ulong>, ulong>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_Int128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<Int128>, Int128>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGB_Int128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<Int128>, Int128>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_UInt128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGBA<UInt128>, UInt128>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGB_UInt128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGB16, byte, ColorRGB<UInt128>, UInt128>();
|
||||
}
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
//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 ColorRGB192DoubleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB192Double>(), Is.EqualTo(24));
|
||||
}
|
||||
|
||||
[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 ColorRGB192Double MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
//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,246 +0,0 @@
|
||||
//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 ColorRGB24Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB24>(), 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 ColorRGB24 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0b11010101,
|
||||
G = 0b01110010,
|
||||
B = 0b10001111,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
//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 ColorRGB32HalfTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB32Half>(), 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 ColorRGB32Half MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = (Half)0.447f,
|
||||
G = (Half)0.224f,
|
||||
B = (Half)0.95f,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
//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));
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
//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,192 +0,0 @@
|
||||
//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 ColorRGB48Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB48>(), 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 = 33871;
|
||||
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 = 33871;
|
||||
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 = 33871;
|
||||
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 = 33871;
|
||||
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 ColorRGB48 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 44000,
|
||||
G = 21354,
|
||||
B = 60080,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
//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 ColorRGB96SingleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB96Single>(), Is.EqualTo(12));
|
||||
}
|
||||
|
||||
[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 ColorRGB96Single MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0.447f,
|
||||
G = 0.224f,
|
||||
B = 0.95f,
|
||||
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,6 +1,5 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -13,162 +12,49 @@ public partial class ColorRGB9e5Tests
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGB9e5>(), 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.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(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
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(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRGB9e5 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0.447,
|
||||
G = 0.224,
|
||||
B = 0.95,
|
||||
A = 0.897,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static ColorRGB9e5 MakeRandomColor() => ColorRandom<ColorRGB9e5, double>.MakeRandomColor();
|
||||
|
||||
public static double MakeRandomValue() => ColorRandom<ColorRGB9e5, double>.MakeRandomValue();
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGB192DoubleIsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_double()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB9e5, double, ColorRGBA<double>, double>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA256DoubleIsLossless()
|
||||
public void ConversionIsLosslessToColorRGB_double()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGB9e5, double, ColorRGB<double>, double>();
|
||||
}
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
//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 ColorRGBA128SingleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA128Single>(), Is.EqualTo(16));
|
||||
}
|
||||
|
||||
[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 ColorRGBA128Single MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0.447f,
|
||||
G = 0.224f,
|
||||
B = 0.95f,
|
||||
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,6 +1,5 @@
|
||||
//This code is source generated. Do not edit manually.
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -13,7 +12,7 @@ public partial class ColorRGBA16Tests
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA16>(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_R()
|
||||
{
|
||||
@@ -57,13 +56,13 @@ public partial class ColorRGBA16Tests
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.R = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.R = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -73,13 +72,13 @@ public partial class ColorRGBA16Tests
|
||||
var r = color.R;
|
||||
var b = color.B;
|
||||
var a = color.A;
|
||||
color.G = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.G = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -89,13 +88,13 @@ public partial class ColorRGBA16Tests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var a = color.A;
|
||||
color.B = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.B = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -105,13 +104,13 @@ public partial class ColorRGBA16Tests
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
color.A = 0b01001110;
|
||||
Assert.Multiple(() =>
|
||||
color.A = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -119,92 +118,103 @@ public partial class ColorRGBA16Tests
|
||||
{
|
||||
var color = MakeRandomColor();
|
||||
color.GetChannels(out var r, out var g, out var b, out var a);
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
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(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
});
|
||||
}
|
||||
|
||||
public static ColorRGBA16 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0b11010101,
|
||||
G = 0b01110010,
|
||||
B = 0b10001111,
|
||||
A = 0b11000111,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static ColorRGBA16 MakeRandomColor() => ColorRandom<ColorRGBA16, byte>.MakeRandomColor();
|
||||
|
||||
public static byte MakeRandomValue() => ColorRandom<ColorRGBA16, byte>.MakeRandomValue();
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorARGB32IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_sbyte()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<sbyte>, sbyte>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorBGRA32IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_byte()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<byte>, byte>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_short()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<short>, short>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA32SignedIsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_ushort()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<ushort>, ushort>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64IsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_int()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<int>, int>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ConversionToColorRGBA64SignedIsLossless()
|
||||
public void ConversionIsLosslessToColorRGBA_uint()
|
||||
{
|
||||
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));
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<uint>, uint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_nint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<nint>, nint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_nuint()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<nuint>, nuint>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_long()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<long>, long>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_ulong()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<ulong>, ulong>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_Int128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<Int128>, Int128>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLosslessToColorRGBA_UInt128()
|
||||
{
|
||||
LosslessConversion.Assert<ColorRGBA16, byte, ColorRGBA<UInt128>, UInt128>();
|
||||
}
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
//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 ColorRGBA256DoubleTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA256Double>(), Is.EqualTo(32));
|
||||
}
|
||||
|
||||
[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 ColorRGBA256Double MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
//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,210 +0,0 @@
|
||||
//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 ColorRGBA32Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA32>(), 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 ColorRGBA32 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 0b11010101,
|
||||
G = 0b01110010,
|
||||
B = 0b10001111,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
//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 ColorRGBA64HalfTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA64Half>(), 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 = (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 ColorRGBA64Half MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = (Half)0.447f,
|
||||
G = (Half)0.224f,
|
||||
B = (Half)0.95f,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
//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 ColorRGBA64SignedTests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA64Signed>(), 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 = 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 ColorRGBA64Signed MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
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,174 +0,0 @@
|
||||
//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 ColorRGBA64Tests
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<ColorRGBA64>(), 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 = 33871;
|
||||
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 = 33871;
|
||||
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 = 33871;
|
||||
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 = 33871;
|
||||
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 ColorRGBA64 MakeRandomColor()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
R = 44000,
|
||||
G = 21354,
|
||||
B = 60080,
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
internal static class ColorRandom<TColor, TChannelValue> where TColor : unmanaged, IColor<TChannelValue> where TChannelValue : unmanaged
|
||||
{
|
||||
public static TChannelValue MakeRandomValue()
|
||||
{
|
||||
ulong value = TestContext.CurrentContext.Random.NextULong();
|
||||
return NumericConversion.Convert<ulong, TChannelValue>(value);
|
||||
}
|
||||
|
||||
public static TColor MakeRandomColor()
|
||||
{
|
||||
TColor color = default;
|
||||
color.SetChannels(MakeRandomValue(), MakeRandomValue(), MakeRandomValue(), MakeRandomValue());
|
||||
return color;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats.Generic;
|
||||
|
||||
internal partial class GenericColorTests<TColor, TChannelValue> where TColor : unmanaged, IColor<TChannelValue> where TChannelValue : unmanaged
|
||||
{
|
||||
[Test]
|
||||
public void CorrectSizeTest()
|
||||
{
|
||||
Assert.That(Unsafe.SizeOf<TColor>(), Is.EqualTo(Color.GetChannelCount<TColor>() * Unsafe.SizeOf<TChannelValue>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_R()
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
TChannelValue r = color.R;
|
||||
color.R = r;
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_G()
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
TChannelValue g = color.G;
|
||||
color.G = g;
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_B()
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
TChannelValue b = color.B;
|
||||
color.B = b;
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropertyIsSymmetric_A()
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
TChannelValue a = color.A;
|
||||
color.A = a;
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_R()
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
TChannelValue g = color.G;
|
||||
TChannelValue b = color.B;
|
||||
TChannelValue a = color.A;
|
||||
color.R = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_G()
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
TChannelValue r = color.R;
|
||||
TChannelValue b = color.B;
|
||||
TChannelValue a = color.A;
|
||||
color.G = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_B()
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
TChannelValue r = color.R;
|
||||
TChannelValue g = color.G;
|
||||
TChannelValue a = color.A;
|
||||
color.B = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChannelsAreIndependent_A()
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
TChannelValue r = color.R;
|
||||
TChannelValue g = color.G;
|
||||
TChannelValue b = color.B;
|
||||
color.A = MakeRandomValue();
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetMethodMatchesProperties()
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
color.GetChannels(out TChannelValue r, out TChannelValue g, out TChannelValue b, out TChannelValue a);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MethodsAreSymmetric()
|
||||
{
|
||||
TColor color = MakeRandomColor();
|
||||
color.GetChannels(out TChannelValue r, out TChannelValue g, out TChannelValue b, out TChannelValue a);
|
||||
color.SetChannels(r, g, b, a);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(color.R, Is.EqualTo(r));
|
||||
Assert.That(color.G, Is.EqualTo(g));
|
||||
Assert.That(color.B, Is.EqualTo(b));
|
||||
Assert.That(color.A, Is.EqualTo(a));
|
||||
}
|
||||
}
|
||||
|
||||
private static TChannelValue MakeRandomValue() => ColorRandom<TColor, TChannelValue>.MakeRandomValue();
|
||||
|
||||
private static TColor MakeRandomColor() => ColorRandom<TColor, TChannelValue>.MakeRandomColor();
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats.Generic;
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<sbyte>), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<byte>), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<short>), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<ushort>), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<int>), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<uint>), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<nint>), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<nuint>), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<long>), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<ulong>), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<Int128>), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<UInt128>), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<Half>), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<float>), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<NFloat>), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<double>), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorR<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRG<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGB<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorRGBA<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorA<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorARGB<decimal>), typeof(decimal) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ColorBGRA<decimal>), typeof(decimal) })]
|
||||
partial class GenericColorTests<TColor, TChannelValue>
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using System.Numerics;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for lossless color conversions.
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The "smaller" type that can be losslessly converted into <typeparamref name="T2"/>.</typeparam>
|
||||
/// <typeparam name="T2">The "larger" type capable of storing <typeparamref name="T1"/> losslessly.</typeparam>
|
||||
internal partial class LosslessColorTests<T1, T2>
|
||||
where T1 : unmanaged, INumberBase<T1>, IMinMaxValue<T1>
|
||||
where T2 : unmanaged, INumberBase<T2>, IMinMaxValue<T2>
|
||||
{
|
||||
[Test]
|
||||
public void ConversionIsLossless_R_T1_R_T2() => LosslessConversion.Assert<ColorR<T1>, T1, ColorR<T2>, T2>();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLossless_R_T1_RG_T2() => LosslessConversion.Assert<ColorR<T1>, T1, ColorRG<T2>, T2>();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLossless_R_T1_RGB_T2() => LosslessConversion.Assert<ColorR<T1>, T1, ColorRGB<T2>, T2>();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLossless_R_T1_RGBA_T2() => LosslessConversion.Assert<ColorR<T1>, T1, ColorRGBA<T2>, T2>();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLossless_RG_T1_RGB_T2() => LosslessConversion.Assert<ColorRG<T1>, T1, ColorRGB<T2>, T2>();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLossless_RG_T1_RGBA_T2() => LosslessConversion.Assert<ColorRG<T1>, T1, ColorRGBA<T2>, T2>();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLossless_RGB_T1_RGBA_T2() => LosslessConversion.Assert<ColorRGB<T1>, T1, ColorRGBA<T2>, T2>();
|
||||
|
||||
[Test]
|
||||
public void ConversionIsLossless_A_T1_RGBA_T2() => LosslessConversion.Assert<ColorA<T1>, T1, ColorRGBA<T2>, T2>();
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats.Generic;
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(sbyte), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(sbyte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(byte) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(byte), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(short), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(short), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(short), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(short), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(short), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(short), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(short), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(short), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(short), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(short), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ushort), typeof(short) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ushort), typeof(ushort) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ushort), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ushort), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ushort), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ushort), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ushort), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ushort), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ushort), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ushort), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(int), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(int), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(int), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(int), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(int), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(int), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(int), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(int), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(uint), typeof(int) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(uint), typeof(uint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(uint), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(uint), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(uint), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(uint), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(uint), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(uint), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nint), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nint), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nint), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nint), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nint), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nint), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nuint), typeof(nint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nuint), typeof(nuint) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nuint), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nuint), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nuint), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(nuint), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(long), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(long), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(long), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(long), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ulong), typeof(long) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ulong), typeof(ulong) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ulong), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(ulong), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(Int128), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(Int128), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(UInt128), typeof(Int128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(UInt128), typeof(UInt128) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(Half), typeof(Half) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(Half), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(Half), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(Half), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(float), typeof(float) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(float), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(float), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(NFloat), typeof(NFloat) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(NFloat), typeof(double) })]
|
||||
[TestFixture(TypeArgs = new Type[] { typeof(double), typeof(double) })]
|
||||
partial class LosslessColorTests<T1, T2>
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using System.Numerics;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats.Generic;
|
||||
|
||||
[TestFixture(TypeArgs = [typeof(sbyte), typeof(byte)])]
|
||||
[TestFixture(TypeArgs = [typeof(short), typeof(ushort)])]
|
||||
[TestFixture(TypeArgs = [typeof(int), typeof(uint)])]
|
||||
[TestFixture(TypeArgs = [typeof(long), typeof(ulong)])]
|
||||
[TestFixture(TypeArgs = [typeof(Int128), typeof(UInt128)])]
|
||||
internal class NumericConversionExtremesTests<TSigned, TUnsigned>
|
||||
where TSigned : unmanaged, IMinMaxValue<TSigned>
|
||||
where TUnsigned : unmanaged, IMinMaxValue<TUnsigned>
|
||||
{
|
||||
[Test]
|
||||
public void SignedToUnsignedExtremesAreCorrect()
|
||||
{
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(NumericConversion.Convert<TSigned, TUnsigned>(TSigned.MinValue), Is.EqualTo(TUnsigned.MinValue));
|
||||
Assert.That(NumericConversion.Convert<TSigned, TUnsigned>(TSigned.MaxValue), Is.EqualTo(TUnsigned.MaxValue));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnsignedToSignedExtremesAreCorrect()
|
||||
{
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(NumericConversion.Convert<TUnsigned, TSigned>(TUnsigned.MinValue), Is.EqualTo(TSigned.MinValue));
|
||||
Assert.That(NumericConversion.Convert<TUnsigned, TSigned>(TUnsigned.MaxValue), Is.EqualTo(TSigned.MaxValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests.Formats;
|
||||
internal static class LosslessConversion
|
||||
{
|
||||
internal static void Assert<TColor1, TChannelValue1, TColor2, TChannelValue2>()
|
||||
where TChannelValue1 : unmanaged
|
||||
where TChannelValue2 : unmanaged
|
||||
where TColor1 : unmanaged, IColor<TChannelValue1>
|
||||
where TColor2 : unmanaged, IColor<TChannelValue2>
|
||||
{
|
||||
TColor1 original = ColorRandom<TColor1, TChannelValue1>.MakeRandomColor();
|
||||
TColor2 converted = original.Convert<TColor1, TChannelValue1, TColor2, TChannelValue2>();
|
||||
TColor1 convertedBack = converted.Convert<TColor2, TChannelValue2, TColor1, TChannelValue1>();
|
||||
NUnit.Framework.Assert.That(convertedBack, Is.EqualTo(original));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests;
|
||||
|
||||
public partial interface ITexture
|
||||
{
|
||||
static abstract TextureType Type { get; }
|
||||
static abstract TextureFormat Format { get; }
|
||||
static abstract int FileSize { get; }
|
||||
static abstract int ImageSize { get; }
|
||||
static abstract int ImageCount { get; }
|
||||
static abstract bool Mips { get; }
|
||||
static abstract int Width { get; }
|
||||
static abstract int Height { get; }
|
||||
static abstract string Path { get; }
|
||||
static abstract byte[] Data { get; }
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
public sealed class NewRgbTests
|
||||
{
|
||||
[Test]
|
||||
public void ConvertA8Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.alpha8");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.A8ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorA8, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
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 = RgbConverter.Convert<ColorARGB16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB24Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgb24");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.RGB24ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB24, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBA32Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgba32");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.RGBA32ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA32, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertARGB32Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.argb32");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.ARGB32ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorARGB32, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgb565");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.RGB16ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
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 = RgbConverter.Convert<ColorR16, ushort, ColorBGRA32, byte>(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 = RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRG16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rg16");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.RG16ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG16, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertR8Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.r8");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.R8ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorR8, byte, ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRHalfTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rhalf");
|
||||
RgbConverter.RHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorR16Half, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGHalfTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rghalf");
|
||||
RgbConverter.RGHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
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<ColorRGBA64Half, Half, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRFloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rfloat");
|
||||
RgbConverter.RFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorR32Single, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGFloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgfloat");
|
||||
RgbConverter.RGFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG64Single, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBAFloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgbafloat");
|
||||
RgbConverter.RGBAFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA128Single, float, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB9e5FloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgb9e5float");
|
||||
RgbConverter.RGB9e5FloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA32, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRG32Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rg32");
|
||||
RgbConverter.RG32ToBGRA32(data, 512, 512, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG32, ushort, ColorBGRA32, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB48Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgb48");
|
||||
RgbConverter.RGB48ToBGRA32(data, 512, 512, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB48, ushort, ColorBGRA32, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBA64Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgba64");
|
||||
RgbConverter.RGBA64ToBGRA32(data, 512, 512, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA64, ushort, ColorBGRA32, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,512 @@
|
||||
using System.Buffers.Binary;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests;
|
||||
|
||||
internal static class OldRgbConverter
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int A8ToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return A8ToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int A8ToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
output[oo + 0] = 0; // b
|
||||
output[oo + 1] = 0; // g
|
||||
output[oo + 2] = 0; // r
|
||||
output[oo + 3] = input[io]; // a
|
||||
oo += 4;
|
||||
io++;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGB24ToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RGB24ToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGB24ToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
output[oo + 0] = input[io + 2]; // b
|
||||
output[oo + 1] = input[io + 1]; // g
|
||||
output[oo + 2] = input[io + 0]; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 3;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGBA32ToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RGBA32ToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGBA32ToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
output[oo + 0] = input[io + 2]; // b
|
||||
output[oo + 1] = input[io + 1]; // g
|
||||
output[oo + 2] = input[io + 0]; // r
|
||||
output[oo + 3] = input[io + 3]; // a
|
||||
io += 4;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int ARGB32ToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return ARGB32ToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int ARGB32ToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
output[oo + 0] = input[io + 3]; // b
|
||||
output[oo + 1] = input[io + 2]; // g
|
||||
output[oo + 2] = input[io + 1]; // r
|
||||
output[oo + 3] = input[io + 0]; // a
|
||||
io += 4;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGB16ToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RGB16ToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGB16ToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
byte r = (byte)(input[io + 1] & 0xF8);
|
||||
byte g = unchecked((byte)((input[io + 1] << 5) | ((input[io + 0] & 0xE0) >> 3)));
|
||||
byte b = unchecked((byte)(input[io + 0] << 3));
|
||||
output[oo + 0] = b; // b
|
||||
output[oo + 1] = g; // g
|
||||
output[oo + 2] = r; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 2;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RG16ToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RG16ToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RG16ToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
output[oo + 0] = 0; // b
|
||||
output[oo + 1] = input[io + 1]; // g
|
||||
output[oo + 2] = input[io + 0]; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 2;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int R8ToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return R8ToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int R8ToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
output[oo + 0] = 0; // b
|
||||
output[oo + 1] = 0; // g
|
||||
output[oo + 2] = input[io + 0]; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 1;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RHalfToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RHalfToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RHalfToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
byte r = ClampByte(ToHalf(input, io) * 255f);
|
||||
output[oo + 0] = 0; // b
|
||||
output[oo + 1] = 0; // g
|
||||
output[oo + 2] = r; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 2;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGHalfToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RGHalfToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGHalfToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
byte r = ClampByte(ToHalf(input, io + 0) * 255f);
|
||||
byte g = ClampByte(ToHalf(input, io + 2) * 255f);
|
||||
output[oo + 0] = 0; // b
|
||||
output[oo + 1] = g; // g
|
||||
output[oo + 2] = r; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 4;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGBAHalfToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RGBAHalfToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGBAHalfToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
byte r = ClampByte(ToHalf(input, io + 0) * 255f);
|
||||
byte g = ClampByte(ToHalf(input, io + 2) * 255f);
|
||||
byte b = ClampByte(ToHalf(input, io + 4) * 255f);
|
||||
byte a = ClampByte(ToHalf(input, io + 6) * 255f);
|
||||
output[oo + 0] = b; // b
|
||||
output[oo + 1] = g; // g
|
||||
output[oo + 2] = r; // r
|
||||
output[oo + 3] = a; // a
|
||||
io += 8;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RFloatToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RFloatToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RFloatToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
byte r = ClampByte(ToSingle(input, io) * 255f);
|
||||
output[oo + 0] = 0; // b
|
||||
output[oo + 1] = 0; // g
|
||||
output[oo + 2] = r; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 4;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGFloatToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RGFloatToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGFloatToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
byte r = ClampByte(ToSingle(input, io + 0) * 255f);
|
||||
byte g = ClampByte(ToSingle(input, io + 4) * 255f);
|
||||
output[oo + 0] = 0; // b
|
||||
output[oo + 1] = g; // g
|
||||
output[oo + 2] = r; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 8;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGBAFloatToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RGBAFloatToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGBAFloatToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
byte r = ClampByte(ToSingle(input, io + 0) * 255f);
|
||||
byte g = ClampByte(ToSingle(input, io + 4) * 255f);
|
||||
byte b = ClampByte(ToSingle(input, io + 8) * 255f);
|
||||
byte a = ClampByte(ToSingle(input, io + 12) * 255f);
|
||||
output[oo + 0] = b; // b
|
||||
output[oo + 1] = g; // g
|
||||
output[oo + 2] = r; // r
|
||||
output[oo + 3] = a; // a
|
||||
io += 16;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGB9e5FloatToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RGB9e5FloatToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGB9e5FloatToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
uint value = BinaryPrimitives.ReadUInt32LittleEndian(input.Slice(io, 4));
|
||||
double scale = Math.Pow(2, unchecked((int)(value >> 27) - 24));
|
||||
byte r = ClampByte((value >> 0 & 0x1FF) * scale * 255.0);
|
||||
byte g = ClampByte((value >> 9 & 0x1FF) * scale * 255.0);
|
||||
byte b = ClampByte((value >> 18 & 0x1FF) * scale * 255.0);
|
||||
output[oo + 0] = b; // b
|
||||
output[oo + 1] = g; // g
|
||||
output[oo + 2] = r; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 4;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RG32ToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RG32ToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RG32ToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
output[oo + 0] = 0; // b
|
||||
output[oo + 1] = input[io + 3]; // g
|
||||
output[oo + 2] = input[io + 1]; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 4;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGB48ToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RGB48ToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGB48ToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
output[oo + 0] = input[io + 5]; // b
|
||||
output[oo + 1] = input[io + 3]; // g
|
||||
output[oo + 2] = input[io + 1]; // r
|
||||
output[oo + 3] = 255; // a
|
||||
io += 6;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGBA64ToBGRA32(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
|
||||
{
|
||||
output = new byte[width * height * 4];
|
||||
return RGBA64ToBGRA32(input, width, height, output);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static int RGBA64ToBGRA32(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
|
||||
{
|
||||
int io = 0;
|
||||
int oo = 0;
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
output[oo + 0] = input[io + 5]; // b
|
||||
output[oo + 1] = input[io + 3]; // g
|
||||
output[oo + 2] = input[io + 1]; // r
|
||||
output[oo + 3] = input[io + 7]; // a
|
||||
io += 8;
|
||||
oo += 4;
|
||||
}
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static float ToHalf(ReadOnlySpan<byte> input, int offset)
|
||||
{
|
||||
return (float)BinaryPrimitives.ReadHalfLittleEndian(input.Slice(offset, 2));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static float ToSingle(ReadOnlySpan<byte> input, int offset)
|
||||
{
|
||||
return BinaryPrimitives.ReadSingleLittleEndian(input.Slice(offset, 4));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static byte ClampByte(float x)
|
||||
{
|
||||
return byte.MaxValue < x ? byte.MaxValue : (x > byte.MinValue ? (byte)x : byte.MinValue);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static byte ClampByte(double x)
|
||||
{
|
||||
return byte.MaxValue < x ? byte.MaxValue : (x > byte.MinValue ? (byte)x : byte.MinValue);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
internal static class PathConstants
|
||||
{
|
||||
public const string ThisTestProjectFolder = "../../../";
|
||||
public const string RepositoryRootFolder = ThisTestProjectFolder + "../";
|
||||
public const string TestFilesFolder = RepositoryRootFolder + "TestFiles/";
|
||||
|
||||
public const string AstcTestFilesFolder = TestFilesFolder + "Astc/";
|
||||
public const string AtcTestFilesFolder = TestFilesFolder + "Atc/";
|
||||
public const string BcTestFilesFolder = TestFilesFolder + "Bc/";
|
||||
public const string DxtTestFilesFolder = TestFilesFolder + "Dxt/";
|
||||
public const string EtcTestFilesFolder = TestFilesFolder + "Etc/";
|
||||
public const string PvrtcTestFilesFolder = TestFilesFolder + "Pvrtc/";
|
||||
public const string RgbTestFilesFolder = TestFilesFolder + "Rgb/";
|
||||
public const string Yuy2TestFilesFolder = TestFilesFolder + "Yuy2/";
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,43 @@
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
using AssetRipper.TextureDecoder.Pvrtc;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests;
|
||||
|
||||
public sealed class PvrtcTests
|
||||
{
|
||||
public sealed class PvrtcTests
|
||||
[Test]
|
||||
public void DecompressPVRTCTest()
|
||||
{
|
||||
[Test]
|
||||
public void DecompressPVRTCTest()
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.PvrtcTestFiles + "test.pvrtc4");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.PvrtcTestFilesFolder + "test.pvrtc4");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Pvrtc.PvrtcDecoder.DecompressPVRTC(data, size, size, false, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
int bytesRead = PvrtcDecoder.DecompressPVRTC<ColorBGRA<byte>, byte>(data, size, size, false, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
}
|
||||
|
||||
private const double MaxMeanDeviation4 = 0.05;
|
||||
private const double MaxStandardDeviation4 = 1.4;
|
||||
|
||||
private const double MaxMeanDeviation2 = 0.10;
|
||||
private const double MaxStandardDeviation2 = 2.6;
|
||||
|
||||
[Test]
|
||||
public void Decompress_4() => AssertCorrectDecompression<AndroidTextures.Logo_13>(false, MaxMeanDeviation4, MaxStandardDeviation4);
|
||||
|
||||
[Test]
|
||||
public void Decompress_2() => AssertCorrectDecompression<AndroidTextures.Logo_14>(true, MaxMeanDeviation2, MaxStandardDeviation2);
|
||||
|
||||
private static void AssertCorrectDecompression<T>(bool do2bitMode, double maxMeanDeviation, double maxStandardDeviation) where T : ITexture
|
||||
{
|
||||
ReadOnlySpan<byte> data = T.Data;
|
||||
int bytesRead = PvrtcDecoder.DecompressPVRTC<ColorBGRA<byte>, byte>(data, T.Width, T.Height, do2bitMode, out byte[] decompressedData);
|
||||
if (!T.Mips)
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
ByteArrayDeviation.AssertMinimalDeviation(decompressedData, AndroidTextures.Logo_00.Data, maxMeanDeviation, maxStandardDeviation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
using AssetRipper.TextureDecoder.Rgb;
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
public sealed class RgbConsistencyTests
|
||||
{
|
||||
[Test]
|
||||
public void ConvertA8Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.alpha8");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = OldRgbConverter.A8ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorA<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertARGB16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.argb4444");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.Convert<ColorARGB16, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB24Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgb24");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = OldRgbConverter.RGB24ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBA32Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgba32");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = OldRgbConverter.RGBA32ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertARGB32Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.argb32");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = OldRgbConverter.ARGB32ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorARGB<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgb565");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = OldRgbConverter.RGB16ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB16, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertR16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.r16");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.Convert<ColorR<ushort>, ushort, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBA16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgba4444");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out _);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRG16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rg16");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = OldRgbConverter.RG16ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertR8Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.r8");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = OldRgbConverter.R8ToBGRA32(data.Slice(totalBytesRead), size, size, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorR<byte>, byte, ColorBGRA<byte>, byte>(data.Slice(totalBytesRead), size, size, out byte[] newDecodedData);
|
||||
totalBytesRead += bytesRead;
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRHalfTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rhalf");
|
||||
OldRgbConverter.RHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorR<Half>, Half, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGHalfTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rghalf");
|
||||
OldRgbConverter.RGHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG<Half>, Half, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBAHalfTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgbahalf");
|
||||
OldRgbConverter.RGBAHalfToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<Half>, Half, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRFloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rfloat");
|
||||
OldRgbConverter.RFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorR<float>, float, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGFloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgfloat");
|
||||
OldRgbConverter.RGFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG<float>, float, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBAFloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgbafloat");
|
||||
OldRgbConverter.RGBAFloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<float>, float, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB9e5FloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgb9e5float");
|
||||
OldRgbConverter.RGB9e5FloatToBGRA32(data, 256, 256, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA<byte>, byte>(data, 256, 256, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRG32Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rg32");
|
||||
OldRgbConverter.RG32ToBGRA32(data, 512, 512, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRG<ushort>, ushort, ColorBGRA<byte>, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB48Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgb48");
|
||||
OldRgbConverter.RGB48ToBGRA32(data, 512, 512, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGB<ushort>, ushort, ColorBGRA<byte>, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBA64Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgba64");
|
||||
OldRgbConverter.RGBA64ToBGRA32(data, 512, 512, out byte[] originalDecodedData);
|
||||
RgbConverter.Convert<ColorRGBA<ushort>, ushort, ColorBGRA<byte>, byte>(data, 512, 512, out byte[] newDecodedData);
|
||||
Assert.That(originalDecodedData, Is.EqualTo(newDecodedData));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,11 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[Test]
|
||||
public void ConvertA8Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.alpha8");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.alpha8");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Rgb.RgbConverter.A8ToBGRA32(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = ConvertSquare<ColorA<byte>, byte>(data.Slice(totalBytesRead), size);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -21,11 +21,11 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[Test]
|
||||
public void ConvertRGB24Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgb24");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgb24");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Rgb.RgbConverter.RGB24ToBGRA32(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = ConvertSquare<ColorRGB<byte>, byte>(data.Slice(totalBytesRead), size);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -34,11 +34,11 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[Test]
|
||||
public void ConvertRGBA32Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgba32");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgba32");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Rgb.RgbConverter.RGBA32ToBGRA32(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = ConvertSquare<ColorRGBA<byte>, byte>(data.Slice(totalBytesRead), size);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -47,11 +47,11 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[Test]
|
||||
public void ConvertARGB32Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.argb32");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.argb32");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Rgb.RgbConverter.ARGB32ToBGRA32(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = ConvertSquare<ColorARGB<byte>, byte>(data.Slice(totalBytesRead), size);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -60,11 +60,11 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[Test]
|
||||
public void ConvertRGB16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgb565");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgb565");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Rgb.RgbConverter.RGB16ToBGRA32(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = ConvertSquare<ColorRGB16, byte>(data.Slice(totalBytesRead), size);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -73,11 +73,11 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[Test]
|
||||
public void ConvertRG16Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rg16");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rg16");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Rgb.RgbConverter.RG16ToBGRA32(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = ConvertSquare<ColorRG<byte>, byte>(data.Slice(totalBytesRead), size);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -86,11 +86,11 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[Test]
|
||||
public void ConvertR8Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.r8");
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.r8");
|
||||
int totalBytesRead = 0;
|
||||
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
|
||||
{
|
||||
int bytesRead = Rgb.RgbConverter.R8ToBGRA32(data.Slice(totalBytesRead), size, size, out _);
|
||||
int bytesRead = ConvertSquare<ColorR<byte>, byte>(data.Slice(totalBytesRead), size);
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
|
||||
@@ -99,81 +99,88 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[Test]
|
||||
public void ConvertRHalfTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rhalf");
|
||||
int bytesRead = Rgb.RgbConverter.RHalfToBGRA32(data, 256, 256, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rhalf");
|
||||
int bytesRead = ConvertSquare<ColorR<Half>, Half>(data, 256);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGHalfTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rghalf");
|
||||
int bytesRead = Rgb.RgbConverter.RGHalfToBGRA32(data, 256, 256, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rghalf");
|
||||
int bytesRead = ConvertSquare<ColorRG<Half>, Half>(data, 256);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBAHalfTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgbahalf");
|
||||
int bytesRead = Rgb.RgbConverter.RGBAHalfToBGRA32(data, 256, 256, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgbahalf");
|
||||
int bytesRead = ConvertSquare<ColorRGBA<Half>, Half>(data, 256);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRFloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rfloat");
|
||||
int bytesRead = Rgb.RgbConverter.RFloatToBGRA32(data, 256, 256, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rfloat");
|
||||
int bytesRead = ConvertSquare<ColorR<float>, float>(data, 256);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGFloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgfloat");
|
||||
int bytesRead = Rgb.RgbConverter.RGFloatToBGRA32(data, 256, 256, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgfloat");
|
||||
int bytesRead = ConvertSquare<ColorRG<float>, float>(data, 256);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBAFloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgbafloat");
|
||||
int bytesRead = Rgb.RgbConverter.RGBAFloatToBGRA32(data, 256, 256, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgbafloat");
|
||||
int bytesRead = ConvertSquare<ColorRGBA<float>, float>(data, 256);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB9e5FloatTest()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgb9e5float");
|
||||
int bytesRead = Rgb.RgbConverter.RGB9e5FloatToBGRA32(data, 256, 256, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgb9e5float");
|
||||
int bytesRead = ConvertSquare<ColorRGB9e5, double>(data, 256);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRG32Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rg32");
|
||||
int bytesRead = Rgb.RgbConverter.RG32ToBGRA32(data, 512, 512, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rg32");
|
||||
int bytesRead = ConvertSquare<ColorRG<ushort>, ushort>(data, 512);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGB48Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgb48");
|
||||
int bytesRead = Rgb.RgbConverter.RGB48ToBGRA32(data, 512, 512, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgb48");
|
||||
int bytesRead = ConvertSquare<ColorRGB<ushort>, ushort>(data, 512);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertRGBA64Test()
|
||||
{
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(PathConstants.RgbTestFilesFolder + "test.rgba64");
|
||||
int bytesRead = Rgb.RgbConverter.RGBA64ToBGRA32(data, 512, 512, out _);
|
||||
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.RgbTestFiles + "test.rgba64");
|
||||
int bytesRead = ConvertSquare<ColorRGBA<ushort>, ushort>(data, 512);
|
||||
Assert.That(bytesRead, Is.EqualTo(data.Length));
|
||||
}
|
||||
|
||||
private static int ConvertSquare<TColor, TChannel>(ReadOnlySpan<byte> data, int size)
|
||||
where TColor : unmanaged, IColor<TChannel>
|
||||
where TChannel : unmanaged
|
||||
{
|
||||
return RgbConverter.Convert<TColor, TChannel, ColorBGRA<byte>, byte>(data, size, size, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests;
|
||||
|
||||
public enum TextureFormat
|
||||
{
|
||||
ASTC_12x12,
|
||||
ASTC_5x5,
|
||||
ASTC_6x6,
|
||||
ASTC_HDR_10x10,
|
||||
ASTC_HDR_12x12,
|
||||
ASTC_HDR_4x4,
|
||||
ASTC_HDR_5x5,
|
||||
ASTC_HDR_6x6,
|
||||
ASTC_HDR_8x8,
|
||||
ASTC_RGB_10x10,
|
||||
ASTC_RGB_4x4,
|
||||
ASTC_RGB_8x8,
|
||||
BGRA32_14,
|
||||
EAC_R,
|
||||
EAC_RG,
|
||||
ETC_RGB4,
|
||||
ETC2_RGB,
|
||||
ETC2_RGBA1,
|
||||
ETC2_RGBA8,
|
||||
PVRTC_2BPP_RGB,
|
||||
PVRTC_4BPP_RGB,
|
||||
PVRTC_4BPP_RGBA,
|
||||
PVRTC_RGBA2,
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Auto-generated code. Do not modify manually.
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests;
|
||||
|
||||
public enum TextureType
|
||||
{
|
||||
Texture2D,
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
global using NUnit.Framework;
|
||||
global using AssetRipper.TextureDecoder.Paths;
|
||||
global using NUnit.Framework;
|
||||
global using System.Runtime.InteropServices;
|
||||
@@ -1,5 +1,6 @@
|
||||
using AssetRipper.TextureDecoder.Rgb.Formats;
|
||||
using AssetRipper.TextureDecoder.Yuy2;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AssetRipper.TextureDecoder.Tests
|
||||
{
|
||||
@@ -11,11 +12,13 @@ namespace AssetRipper.TextureDecoder.Tests
|
||||
[Test]
|
||||
public void DecompressYUY2Test()
|
||||
{
|
||||
byte[] input = File.ReadAllBytes(PathConstants.Yuy2TestFilesFolder + "test.yuy2");
|
||||
int bytesRead = Yuy2Decoder.DecompressYUY2(input, TestImageWidth, TestImageHeight, out byte[] originalOutput);
|
||||
Assert.That(bytesRead, Is.EqualTo(input.Length));
|
||||
Yuy2Decoder.DecompressYUY2<ColorBGRA32, byte>(input, TestImageWidth, TestImageHeight, out byte[] genericOutput);
|
||||
Assert.That(originalOutput, Is.EqualTo(genericOutput));
|
||||
byte[] input = File.ReadAllBytes(TestFileFolders.Yuy2TestFiles + "test.yuy2");
|
||||
int bytesRead = Yuy2Decoder.DecompressYUY2<ColorBGRA<byte>, byte>(input, TestImageWidth, TestImageHeight, out byte[] decodedData);
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(bytesRead, Is.EqualTo(input.Length));
|
||||
Assert.That(decodedData, Has.Length.EqualTo(TestImageWidth * TestImageHeight * Unsafe.SizeOf<ColorBGRA<byte>>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<Solution>
|
||||
<Folder Name="/Solution Items/">
|
||||
<File Path=".editorconfig" />
|
||||
<File Path=".gitignore" />
|
||||
<File Path="Directory.Build.props" />
|
||||
<File Path="LICENSE" />
|
||||
<File Path="README.md" />
|
||||
</Folder>
|
||||
<Folder Name="/Solution Items/Licenses/">
|
||||
<File Path="Licenses/bcdec.md" />
|
||||
<File Path="Licenses/uTinyRipper.md" />
|
||||
</Folder>
|
||||
<Folder Name="/Solution Items/Workflows/">
|
||||
<File Path=".github/workflows/build.yml" />
|
||||
</Folder>
|
||||
<Project Path="AssetRipper.TextureDecoder.ColorGenerator/AssetRipper.TextureDecoder.ColorGenerator.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.ConsoleApp/AssetRipper.TextureDecoder.ConsoleApp.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.Paths/AssetRipper.TextureDecoder.Paths.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.SourceGeneration.Common/AssetRipper.TextureDecoder.SourceGeneration.Common.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.TestGenerator/AssetRipper.TextureDecoder.TestGenerator.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder.Tests/AssetRipper.TextureDecoder.Tests.csproj" />
|
||||
<Project Path="AssetRipper.TextureDecoder/AssetRipper.TextureDecoder.csproj" />
|
||||
<Project Path="IntegerConversion.ConstantEstimation/IntegerConversion.ConstantEstimation.csproj" />
|
||||
</Solution>
|
||||
@@ -1,47 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net5.0;net6.0;net7.0</TargetFrameworks>
|
||||
<LangVersion>Latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<IsTrimmable>true</IsTrimmable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<RootNamespace>AssetRipper.TextureDecoder</RootNamespace>
|
||||
<Authors>ds5678</Authors>
|
||||
<Company>AssetRipper</Company>
|
||||
<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 - 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" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
|
||||
<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 - 2026 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="10.0.103">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,30 +1,35 @@
|
||||
namespace AssetRipper.TextureDecoder.Astc
|
||||
namespace AssetRipper.TextureDecoder.Astc;
|
||||
|
||||
public static partial class AstcDecoder
|
||||
{
|
||||
public static partial class AstcDecoder
|
||||
private struct BlockData
|
||||
{
|
||||
private unsafe struct BlockData
|
||||
{
|
||||
public int bw;
|
||||
public int bh;
|
||||
public int width;
|
||||
public int height;
|
||||
public int part_num;
|
||||
public int dual_plane;
|
||||
public int plane_selector;
|
||||
public int weight_range;
|
||||
/// <summary>
|
||||
/// max: 120
|
||||
/// </summary>
|
||||
public int weight_num;
|
||||
public fixed int cem[4];
|
||||
public int cem_range;
|
||||
/// <summary>
|
||||
/// max: 32
|
||||
/// </summary>
|
||||
public int endpoint_value_num;
|
||||
public fixed int endpoints[4 * 8];
|
||||
public fixed int weights[144 * 2];
|
||||
public fixed int partition[144];
|
||||
}
|
||||
public int bw;
|
||||
public int bh;
|
||||
public int width;
|
||||
public int height;
|
||||
public int part_num;
|
||||
public int dual_plane;
|
||||
public int plane_selector;
|
||||
public int weight_range;
|
||||
/// <summary>
|
||||
/// max: 120
|
||||
/// </summary>
|
||||
public int weight_num;
|
||||
public IntBuffer4 cem;
|
||||
public int cem_range;
|
||||
/// <summary>
|
||||
/// max: 32
|
||||
/// </summary>
|
||||
public int endpoint_value_num;
|
||||
/// <summary>
|
||||
/// 4 * 8
|
||||
/// </summary>
|
||||
public EndpointBuffer endpoints;
|
||||
/// <summary>
|
||||
/// 144 * 2
|
||||
/// </summary>
|
||||
public IntBuffer288 weights;
|
||||
public IntBuffer144 partition;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace AssetRipper.TextureDecoder.Astc;
|
||||
|
||||
public static partial class AstcDecoder
|
||||
{
|
||||
[InlineArray(4)]
|
||||
private struct EndpointBuffer
|
||||
{
|
||||
private Endpoint _element0;
|
||||
|
||||
[InlineArray(8)]
|
||||
public struct Endpoint
|
||||
{
|
||||
private int _element0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace AssetRipper.TextureDecoder.Astc;
|
||||
|
||||
public static partial class AstcDecoder
|
||||
{
|
||||
[InlineArray(144)]
|
||||
private struct IntBuffer144
|
||||
{
|
||||
private int _element0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace AssetRipper.TextureDecoder.Astc;
|
||||
|
||||
public static partial class AstcDecoder
|
||||
{
|
||||
[InlineArray(288)]
|
||||
private struct IntBuffer288
|
||||
{
|
||||
private int _element0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace AssetRipper.TextureDecoder.Astc;
|
||||
|
||||
public static partial class AstcDecoder
|
||||
{
|
||||
[InlineArray(4)]
|
||||
private struct IntBuffer4
|
||||
{
|
||||
private int _element0;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
namespace AssetRipper.TextureDecoder.Astc
|
||||
namespace AssetRipper.TextureDecoder.Astc;
|
||||
|
||||
public static partial class AstcDecoder
|
||||
{
|
||||
public static partial class AstcDecoder
|
||||
private struct IntSeqData
|
||||
{
|
||||
private struct IntSeqData
|
||||
{
|
||||
public int bits;
|
||||
public int nonbits;
|
||||
}
|
||||
public int bits;
|
||||
public int nonbits;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Loaded 100 of 270 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user