mirror of
https://github.com/AssetRipper/AssetRipper.TextureDecoder.git
synced 2026-11-12 18:07:28 -10:00
IColor.Convert extension method
This commit is contained in:
1 parent
dc1ecc5d46
commit
a5cfc5cbf7
2 files changed
+21
-5
No files matched your search
@@ -56,5 +56,25 @@
|
||||
ConversionUtilities.ConvertValue<TSourceArg, TThisArg>(b),
|
||||
ConversionUtilities.ConvertValue<TSourceArg, TThisArg>(a));
|
||||
}
|
||||
|
||||
[MethodImpl(OptimizationConstants.AggressiveInliningAndOptimization)]
|
||||
internal static TTarget Convert<TThis, TThisArg, TTarget, TTargetArg>(this TThis color)
|
||||
where TThisArg : unmanaged
|
||||
where TTargetArg : unmanaged
|
||||
where TThis : unmanaged, IColor<TThisArg>
|
||||
where TTarget : unmanaged, IColor<TTargetArg>
|
||||
{
|
||||
if (typeof(TThis) == typeof(TTarget))
|
||||
{
|
||||
return Unsafe.As<TThis, TTarget>(ref color);
|
||||
}
|
||||
else
|
||||
{
|
||||
TTarget destination = default;
|
||||
color.GetChannels(out TThisArg r, out TThisArg g, out TThisArg b, out TThisArg a);
|
||||
destination.SetConvertedChannels<TTarget, TTargetArg, TThisArg>(r, g, b, a);
|
||||
return destination;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -600,11 +600,7 @@ namespace AssetRipper.TextureDecoder.Rgb
|
||||
{
|
||||
for (int i = 0; i < sourceSpan.Length; i++)
|
||||
{
|
||||
TSource source = sourceSpan[i];
|
||||
TDestination destination = default;
|
||||
source.GetChannels(out TSourceArg r, out TSourceArg g, out TSourceArg b, out TSourceArg a);
|
||||
destination.SetConvertedChannels<TDestination, TDestinationArg, TSourceArg>(r, g, b, a);
|
||||
destinationSpan[i] = destination;
|
||||
destinationSpan[i] = sourceSpan[i].Convert<TSource, TSourceArg, TDestination, TDestinationArg>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user