1
0
mirror of synced 2025-01-31 12:23:52 +01:00

Fix DDS headers in SDF archive

This commit is contained in:
KillzXGaming 2019-06-16 20:34:04 -04:00
parent 8f849bf260
commit cee244669e
8 changed files with 21 additions and 4 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Switch_Toolbox; using Switch_Toolbox;
using System.Windows.Forms; using System.Windows.Forms;
@ -241,7 +241,17 @@ namespace FirstPlugin
if (UseDDS) if (UseDDS)
{ {
Data.Add(SDFParent.block2Array[DdsType].Data); bool IsDX10 = false;
using (var filereader = new FileReader(SDFParent.block2Array[DdsType].Data))
{
filereader.Position = 84;
IsDX10 = filereader.ReadString(4) == "DX10";
if (IsDX10)
Data.Add(SDFParent.block2Array[DdsType].Data.Take((int)0x94).ToArray());
else
Data.Add(SDFParent.block2Array[DdsType].Data.Take((int)0x80).ToArray());
}
} }
for (var i = 0; i < CompressedSizes.Count; i++) for (var i = 0; i < CompressedSizes.Count; i++)

View File

@ -766,7 +766,7 @@ namespace Switch_Toolbox.Library
ArrayCount = DX10header.arrayFlag; ArrayCount = DX10header.arrayFlag;
} }
public bool SwitchSwizzle = false; public bool SwitchSwizzle = true;
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0) public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
{ {
if (SwitchSwizzle) if (SwitchSwizzle)

View File

@ -370,7 +370,10 @@ namespace Switch_Toolbox.Library.Forms
var image = ActiveTexture.GetBitmap(CurArrayDisplayLevel, CurMipDisplayLevel); var image = ActiveTexture.GetBitmap(CurArrayDisplayLevel, CurMipDisplayLevel);
//Keep base image for channel viewer updating/editing //Keep base image for channel viewer updating/editing
BaseImage = new Bitmap(image); if (image != null)
BaseImage = new Bitmap(image);
else
BaseImage = null;
if (propertiesEditor.InvokeRequired) if (propertiesEditor.InvokeRequired)
{ {

View File

@ -33,6 +33,10 @@ namespace Switch_Toolbox.Library
{ {
string FilePath = ((ArchiveFileWrapper)file).ArchiveFileInfo.FileName; string FilePath = ((ArchiveFileWrapper)file).ArchiveFileInfo.FileName;
string FolderPath = Path.GetDirectoryName(FilePath.RemoveIllegaleFolderNameCharacters()); string FolderPath = Path.GetDirectoryName(FilePath.RemoveIllegaleFolderNameCharacters());
string FolderPathDir = Path.Combine(folderDialog.SelectedPath, FolderPath);
if (!Directory.Exists(FolderPathDir))
Directory.CreateDirectory(FolderPathDir);
string FileName = file.Text.RemoveIllegaleFileNameCharacters(); string FileName = file.Text.RemoveIllegaleFileNameCharacters();