diff --git a/File_Format_Library/FileFormats/HyruleWarriors/G1T.cs b/File_Format_Library/FileFormats/HyruleWarriors/G1T.cs
index 409b4ebd..4487ae21 100644
--- a/File_Format_Library/FileFormats/HyruleWarriors/G1T.cs
+++ b/File_Format_Library/FileFormats/HyruleWarriors/G1T.cs
@@ -134,12 +134,10 @@ namespace FirstPlugin
switch (format)
{
case 0x5F:
- case 0x01:
+ case 0x01:
+ case 0x09:
tex.Format = TEX_FORMAT.R8G8B8A8_UNORM;
break;
- case 0x09:
- tex.Format = TEX_FORMAT.R32G32B32A32_FLOAT;
- break;
case 0x06:
case 0x59: //Switch
case 0x60: //Wii U
@@ -156,6 +154,13 @@ namespace FirstPlugin
}
uint textureSize = (Width * Height * STGenericTexture.GetBytesPerPixel(tex.Format)) / 8;
+ if (format == 0x09)
+ textureSize = (Width * Height * 64) / 8;
+ if (format == 0x01)
+ {
+ textureSize = (Width * Height * 32) / 8;
+ tex.Parameters.DontSwapRG = true;
+ }
tex.ImageData = reader.ReadBytes((int)textureSize);
Nodes.Add(tex);
diff --git a/File_Format_Library/FileFormats/HyruleWarriors/HWBinGzResource.cs b/File_Format_Library/FileFormats/HyruleWarriors/HWBinGzResource.cs
index 8a5f0bd4..95c152f3 100644
--- a/File_Format_Library/FileFormats/HyruleWarriors/HWBinGzResource.cs
+++ b/File_Format_Library/FileFormats/HyruleWarriors/HWBinGzResource.cs
@@ -140,12 +140,12 @@ namespace FirstPlugin
Nodes.Add(GITextureU);
break;
default:
- files.Add(fileEntry);
break;
-
}
+
+ files.Add(fileEntry);
}
- }
+ }
}
public void Unload()
diff --git a/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs b/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs
index 81a220c5..99fb6414 100644
--- a/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs
+++ b/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs
@@ -422,7 +422,7 @@ namespace Toolbox.Library
if (Runtime.UseDirectXTexDecoder)
{
- return BitmapExtension.GetBitmap(DecodeBlock(data, width, height, Format, new byte[0]),
+ return BitmapExtension.GetBitmap(DecodeBlock(data, width, height, Format, new byte[0], Parameters),
(int)width, (int)height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
}
else
@@ -487,7 +487,7 @@ namespace Toolbox.Library
public static Bitmap DecodeBlockGetBitmap(byte[] data, uint Width, uint Height, TEX_FORMAT Format, byte[] paletteData, PALETTE_FORMAT PaletteFormat = PALETTE_FORMAT.None)
{
- Bitmap bitmap = BitmapExtension.GetBitmap(DecodeBlock(data, Width, Height, Format, paletteData, PaletteFormat),
+ Bitmap bitmap = BitmapExtension.GetBitmap(DecodeBlock(data, Width, Height, Format, paletteData, null, PaletteFormat),
(int)Width, (int)Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
return bitmap;
@@ -501,7 +501,7 @@ namespace Toolbox.Library
/// The height of the image in pixels.
/// The image format.
/// Returns a byte array of decoded data.
- public static byte[] DecodeBlock(byte[] data, uint Width, uint Height, TEX_FORMAT Format, byte[] paletteData, PALETTE_FORMAT PaletteFormat = PALETTE_FORMAT.None, PlatformSwizzle PlatformSwizzle = PlatformSwizzle.None)
+ public static byte[] DecodeBlock(byte[] data, uint Width, uint Height, TEX_FORMAT Format, byte[] paletteData, ImageParameters parameters, PALETTE_FORMAT PaletteFormat = PALETTE_FORMAT.None, PlatformSwizzle PlatformSwizzle = PlatformSwizzle.None)
{
if (data == null) throw new Exception($"Data is null!");
if (Format <= 0) throw new Exception($"Invalid Format!");
@@ -509,33 +509,37 @@ namespace Toolbox.Library
if (Width <= 0) throw new Exception($"Invalid width size {Width}!");
if (Height <= 0) throw new Exception($"Invalid height size {Height}!");
+ byte[] imageData = new byte[0];
+ bool DontSwapRG = false;
+
if (PlatformSwizzle == PlatformSwizzle.Platform_3DS && !IsCompressed(Format))
{
- return CTR_3DS.DecodeBlock(data, (int)Width, (int)Height, Format);
+ imageData = CTR_3DS.DecodeBlock(data, (int)Width, (int)Height, Format);
+ DontSwapRG = true;
}
if (PlatformSwizzle == PlatformSwizzle.Platform_Gamecube)
- {
- return ConvertBgraToRgba(Decode_Gamecube.DecodeData(data, paletteData, Width, Height, Format, PaletteFormat));
- }
-
+ imageData = Decode_Gamecube.DecodeData(data, paletteData, Width, Height, Format, PaletteFormat);
+
if (Format == TEX_FORMAT.R32G8X24_FLOAT)
- return ConvertBgraToRgba(DDSCompressor.DecodePixelBlock(data, (int)Width, (int)Height, DDS.DXGI_FORMAT.DXGI_FORMAT_R32G8X24_TYPELESS));
+ imageData = DDSCompressor.DecodePixelBlock(data, (int)Width, (int)Height, DDS.DXGI_FORMAT.DXGI_FORMAT_R32G8X24_TYPELESS);
if (Format == TEX_FORMAT.BC5_SNORM)
- return ConvertBgraToRgba(DDSCompressor.DecompressBC5(data, (int)Width, (int)Height, true, true));
+ imageData = DDSCompressor.DecompressBC5(data, (int)Width, (int)Height, true, true);
if (IsCompressed(Format))
- return ConvertBgraToRgba(DDSCompressor.DecompressBlock(data, (int)Width, (int)Height, (DDS.DXGI_FORMAT)Format));
+ imageData = DDSCompressor.DecompressBlock(data, (int)Width, (int)Height, (DDS.DXGI_FORMAT)Format);
else
{
- //If blue channel becomes first, do not swap them!
- // if (Format.ToString().StartsWith("B") || Format == TEX_FORMAT.B5G6R5_UNORM)
- // return DDSCompressor.DecodePixelBlock(data, (int)Width, (int)Height, (DDS.DXGI_FORMAT)Format);
if (IsAtscFormat(Format))
- return ConvertBgraToRgba(ASTCDecoder.DecodeToRGBA8888(data, (int)GetBlockWidth(Format), (int)GetBlockHeight(Format), 1, (int)Width, (int)Height, 1));
+ imageData = ASTCDecoder.DecodeToRGBA8888(data, (int)GetBlockWidth(Format), (int)GetBlockHeight(Format), 1, (int)Width, (int)Height, 1);
else
- return ConvertBgraToRgba(DDSCompressor.DecodePixelBlock(data, (int)Width, (int)Height, (DDS.DXGI_FORMAT)Format));
+ imageData = DDSCompressor.DecodePixelBlock(data, (int)Width, (int)Height, (DDS.DXGI_FORMAT)Format);
}
+
+ if (parameters.DontSwapRG || DontSwapRG)
+ return imageData;
+ else
+ return ConvertBgraToRgba(imageData);
}
public string DebugInfo()
diff --git a/Switch_Toolbox_Library/Generics/Texture/ImageParameters.cs b/Switch_Toolbox_Library/Generics/Texture/ImageParameters.cs
index 12dcddfe..096fa4a3 100644
--- a/Switch_Toolbox_Library/Generics/Texture/ImageParameters.cs
+++ b/Switch_Toolbox_Library/Generics/Texture/ImageParameters.cs
@@ -8,6 +8,10 @@ namespace Toolbox.Library
{
public class ImageParameters
{
+ //Flip the image on the Y axis
public bool FlipY { get; set; }
+
+ //Dont swap the red and green channels
+ public bool DontSwapRG { get; set; }
}
}
diff --git a/Switch_Toolbox_Library/Rendering/RenderableTex.cs b/Switch_Toolbox_Library/Rendering/RenderableTex.cs
index 1fbd3163..24a2f74f 100644
--- a/Switch_Toolbox_Library/Rendering/RenderableTex.cs
+++ b/Switch_Toolbox_Library/Rendering/RenderableTex.cs
@@ -252,6 +252,7 @@ namespace Toolbox.Library.Rendering
height,
GenericTexture.Format,
new byte[0],
+ GenericTexture.Parameters,
PALETTE_FORMAT.None,
GenericTexture.PlatformSwizzle);
}
diff --git a/Switch_Toolbox_Library/Toolbox.Library.dll b/Switch_Toolbox_Library/Toolbox.Library.dll
index ae7ce42b..f8418143 100644
Binary files a/Switch_Toolbox_Library/Toolbox.Library.dll and b/Switch_Toolbox_Library/Toolbox.Library.dll differ
diff --git a/Switch_Toolbox_Library/Toolbox.Library.pdb b/Switch_Toolbox_Library/Toolbox.Library.pdb
index 2a5d4328..4bc66be8 100644
Binary files a/Switch_Toolbox_Library/Toolbox.Library.pdb and b/Switch_Toolbox_Library/Toolbox.Library.pdb differ