From 62a822f3ab56a1d484b7f7f05a83eb94c85754c5 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Mon, 4 May 2020 20:39:28 -0400 Subject: [PATCH] Fix importing textures with BC4 alpha --- .../GUI/TextureUI/Importers/GX2/GTXImporterSettings.cs | 3 +++ .../GUI/TextureUI/Importers/GX2/GTXTextureImporter.cs | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/File_Format_Library/GUI/TextureUI/Importers/GX2/GTXImporterSettings.cs b/File_Format_Library/GUI/TextureUI/Importers/GX2/GTXImporterSettings.cs index 8f2e7528..16737741 100644 --- a/File_Format_Library/GUI/TextureUI/Importers/GX2/GTXImporterSettings.cs +++ b/File_Format_Library/GUI/TextureUI/Importers/GX2/GTXImporterSettings.cs @@ -140,6 +140,9 @@ namespace FirstPlugin Bitmap Image = BitmapExtension.GetBitmap(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight); if (FlipY) Image.RotateFlip(RotateFlipType.RotateNoneFlipY); + if (UseBc4Alpha && (Format == GX2.GX2SurfaceFormat.T_BC4_UNORM || Format == GX2.GX2SurfaceFormat.T_BC4_SNORM)) { + Image = BitmapExtension.SetChannel(Image, STChannelType.Alpha, STChannelType.Alpha, STChannelType.Alpha, STChannelType.One); + } Console.WriteLine($"FlipY {FlipY}"); diff --git a/File_Format_Library/GUI/TextureUI/Importers/GX2/GTXTextureImporter.cs b/File_Format_Library/GUI/TextureUI/Importers/GX2/GTXTextureImporter.cs index bbdbca4e..da95af9a 100644 --- a/File_Format_Library/GUI/TextureUI/Importers/GX2/GTXTextureImporter.cs +++ b/File_Format_Library/GUI/TextureUI/Importers/GX2/GTXTextureImporter.cs @@ -210,9 +210,11 @@ namespace FirstPlugin if (setting.FlipY) bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); - if (setting.UseBc4Alpha) { + if (setting.UseBc4Alpha && (setting.Format == GX2.GX2SurfaceFormat.T_BC4_UNORM || + setting.Format == GX2.GX2SurfaceFormat.T_BC4_UNORM)) + { bitmap = BitmapExtension.SetChannel(bitmap, - STChannelType.Red, STChannelType.Red, STChannelType.Red, STChannelType.Red); + STChannelType.One, STChannelType.One, STChannelType.One, STChannelType.Red); } if (pictureBox1.InvokeRequired)