mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 20:43:09 +00:00
Add swizzle checks for sdf files
This commit is contained in:
parent
54e88cdef5
commit
fab1c82fd1
6 changed files with 17 additions and 4 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -196,6 +196,7 @@ namespace FirstPlugin
|
|||
public ulong DdsType;
|
||||
public bool UseDDS;
|
||||
public bool IsCompressed = false;
|
||||
public bool IsSwizzled = false;
|
||||
|
||||
public override byte[] FileData
|
||||
{
|
||||
|
@ -209,11 +210,12 @@ namespace FirstPlugin
|
|||
|
||||
public override IFileFormat OpenFile()
|
||||
{
|
||||
byte[] Data = FileData;
|
||||
var FileFormat = STFileLoader.OpenFileFormat(
|
||||
IOExtensions.RemoveIllegaleFolderNameCharacters(FileName), FileData, true);
|
||||
IOExtensions.RemoveIllegaleFolderNameCharacters(FileName), Data, true);
|
||||
|
||||
if (FileFormat is DDS)
|
||||
((DDS)FileFormat).SwitchSwizzle = true;
|
||||
((DDS)FileFormat).SwitchSwizzle = IsSwizzled;
|
||||
|
||||
return FileFormat;
|
||||
}
|
||||
|
@ -245,16 +247,27 @@ namespace FirstPlugin
|
|||
|
||||
if (UseDDS)
|
||||
{
|
||||
// Data.Add(SDFParent.block2Array[DdsType].Data.Take((int)SDFParent.block2Array[DdsType].UsedBytes).ToArray());
|
||||
bool IsDX10 = false;
|
||||
using (var filereader = new FileReader(SDFParent.block2Array[DdsType].Data))
|
||||
{
|
||||
filereader.Position = 84;
|
||||
IsDX10 = filereader.ReadString(4) == "DX10";
|
||||
|
||||
if (IsDX10)
|
||||
if (IsDX10)
|
||||
{
|
||||
if (SDFParent.block2Array[DdsType].UsedBytes > 0x94)
|
||||
IsSwizzled = true;
|
||||
|
||||
Data.Add(SDFParent.block2Array[DdsType].Data.Take((int)0x94).ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SDFParent.block2Array[DdsType].UsedBytes > 0x80)
|
||||
IsSwizzled = true;
|
||||
|
||||
Data.Add(SDFParent.block2Array[DdsType].Data.Take((int)0x80).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
|
@ -776,7 +776,7 @@ namespace Switch_Toolbox.Library
|
|||
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
if (IsAtscFormat(Format))
|
||||
SwitchSwizzle = true;
|
||||
SwitchSwizzle = false;
|
||||
|
||||
if (SwitchSwizzle)
|
||||
return TegraX1Swizzle.GetImageData(this, bdata, ArrayLevel, MipLevel);
|
||||
|
|
Loading…
Reference in a new issue