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.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
@ -241,7 +241,17 @@ namespace FirstPlugin
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++)

View file

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

View file

@ -370,7 +370,10 @@ namespace Switch_Toolbox.Library.Forms
var image = ActiveTexture.GetBitmap(CurArrayDisplayLevel, CurMipDisplayLevel);
//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)
{

View file

@ -33,6 +33,10 @@ namespace Switch_Toolbox.Library
{
string FilePath = ((ArchiveFileWrapper)file).ArchiveFileInfo.FileName;
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();