Skip to content

Commit cfd9ab0

Browse files
committed
argb4444 fix?
1 parent 85c7ba6 commit cfd9ab0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Source/AssetRipper.Export.UnityProjects/Textures/TextureConverter.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private static bool TryConvertToBitmap(
185185
}
186186
Span<byte> outputSpan = bitmap.Bits.Slice(i * outputSize, outputSize);
187187

188-
if (!TryDecodeTexture(textureFormat, width, height, uncompressedSpan, outputSpan))
188+
if (!TryDecodeTexture(textureFormat, width, height, uncompressedSpan, outputSpan, version))
189189
{
190190
bitmap = default;
191191
return false;
@@ -194,7 +194,7 @@ private static bool TryConvertToBitmap(
194194
return true;
195195
}
196196

197-
private static bool TryDecodeTexture(TextureFormat textureFormat, int width, int height, ReadOnlySpan<byte> inputSpan, Span<byte> outputSpan)
197+
private static bool TryDecodeTexture(TextureFormat textureFormat, int width, int height, ReadOnlySpan<byte> inputSpan, Span<byte> outputSpan, UnityVersion version)
198198
{
199199
switch (textureFormat)
200200
{
@@ -319,8 +319,15 @@ private static bool TryDecodeTexture(TextureFormat textureFormat, int width, int
319319
return true;
320320

321321
case TextureFormat.ARGB4444:
322-
RgbConverter.Convert<ColorARGB16, byte, ColorBGRA32, byte>(inputSpan, width, height, outputSpan);
323-
//RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA32, byte>(inputSpan, width, height, outputSpan);
322+
// I think this is right??
323+
if (version.IsLess(4, 0, 0))
324+
{
325+
RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA32, byte>(inputSpan, width, height, outputSpan);
326+
}
327+
else
328+
{
329+
RgbConverter.Convert<ColorARGB16, byte, ColorBGRA32, byte>(inputSpan, width, height, outputSpan);
330+
}
324331
return true;
325332

326333
case TextureFormat.RGBA4444:

0 commit comments

Comments
 (0)