Update GTX code and update data types.

This commit is contained in:
KillzXGaming 2018-12-02 15:01:51 -05:00
parent 5cfec193bf
commit 785f5657b2
41 changed files with 7460 additions and 241 deletions

View file

@ -282,7 +282,7 @@ namespace Bfres.Structs
ftexContainer.Nodes.Add(texture);
ftexContainer.Textures.Add(texture.Text, texture);
}
// PluginRuntime.ftexContainers.Add(ftexContainer);
PluginRuntime.ftexContainers.Add(ftexContainer);
}
private void AddSkeletonAnims(ResU.ResFile resFile)
{

View file

@ -434,8 +434,7 @@ namespace FirstPlugin
else
{
settings.Add(LoadSettings(name));
}
}
if (settings.Count == 0)
{
importer.Dispose();
@ -482,6 +481,9 @@ namespace FirstPlugin
}
}
}
}
}
settings.Clear();
GC.Collect();
Cursor.Current = Cursors.Default;
@ -1177,7 +1179,6 @@ namespace FirstPlugin
if (setting.DataBlockOutput != null)
{
Texture = setting.FromBitMap(setting.DataBlockOutput[0], setting);
LoadTexture(Texture, 1);
LoadOpenGLTexture();
}
else

View file

@ -25,6 +25,9 @@ namespace FirstPlugin
Name = "FTEXCONT";
ContextMenu = new ContextMenu();
MenuItem importTex = new MenuItem("Import");
ContextMenu.MenuItems.Add(importTex);
importTex.Click += Import;
MenuItem exportAll = new MenuItem("Export All Textures");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
@ -50,7 +53,117 @@ namespace FirstPlugin
Textures.Remove(textureData.Text);
Viewport.Instance.UpdateViewport();
}
private void Import(object sender, EventArgs args)
{
ImportTexture();
}
public void ImportTexture()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
GTXTextureImporter importer = new GTXTextureImporter();
List<GTXImporterSettings> settings = new List<GTXImporterSettings>();
foreach (string name in ofd.FileNames)
{
string ext = System.IO.Path.GetExtension(name);
ext = ext.ToLower();
if (ext == ".dds")
{
settings.Add(LoadSettings(name));
if (settings.Count == 0)
{
importer.Dispose();
return;
}
importer.LoadSettings(settings);
foreach (var setting in settings)
{
if (setting.DataBlockOutput != null)
{
GTX.GX2Surface tex = setting.CreateGx2Texture(setting.DataBlockOutput[0]);
FTEX ftex = new FTEX();
ftex.texture = ftex.FromGx2Surface(tex, setting);
ftex.Read(ftex.texture);
Nodes.Add(ftex);
Textures.Add(ftex.Text, ftex);
ftex.LoadOpenGLTexture();
}
}
}
else
{
settings.Add(LoadSettings(name));
if (settings.Count == 0)
{
importer.Dispose();
return;
}
importer.LoadSettings(settings);
if (importer.ShowDialog() == DialogResult.OK)
{
Cursor.Current = Cursors.WaitCursor;
foreach (var setting in settings)
{
if (setting.GenerateMipmaps)
{
setting.DataBlockOutput.Clear();
setting.DataBlockOutput.Add(setting.GenerateMips());
}
if (setting.DataBlockOutput != null)
{
GTX.GX2Surface tex = setting.CreateGx2Texture(setting.DataBlockOutput[0]);
FTEX ftex = new FTEX();
ftex.texture = ftex.FromGx2Surface(tex, setting);
ftex.Read(ftex.texture);
Nodes.Add(ftex);
Textures.Add(ftex.Text, ftex);
ftex.LoadOpenGLTexture();
}
else
{
MessageBox.Show("Something went wrong???");
}
}
}
}
settings.Clear();
GC.Collect();
Cursor.Current = Cursors.Default;
}
}
}
public GTXImporterSettings LoadSettings(string name)
{
var importer = new GTXImporterSettings();
string ext = System.IO.Path.GetExtension(name);
ext = ext.ToLower();
switch (ext)
{
case ".dds":
importer.LoadDDS(name);
break;
default:
importer.LoadBitMap(name);
break;
}
return importer;
}
private void ExportAll(object sender, EventArgs args)
{
List<string> Formats = new List<string>();
@ -94,10 +207,7 @@ namespace FirstPlugin
{
public int format;
public RenderableTex renderedTex = new RenderableTex();
GX2CompSel ChannelRed;
GX2CompSel ChannelBlue;
GX2CompSel ChannelGreen;
GX2CompSel ChannelAlpha;
public Texture texture;
public FTEX()
{
@ -105,6 +215,9 @@ namespace FirstPlugin
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
MenuItem remove = new MenuItem("Remove");
ContextMenu.MenuItems.Add(remove);
remove.Click += Remove;
@ -115,7 +228,91 @@ namespace FirstPlugin
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
Replace(ofd.FileName);
}
}
public void Replace(string FileName)
{
string ext = System.IO.Path.GetExtension(FileName);
ext = ext.ToLower();
GTXImporterSettings setting = new GTXImporterSettings();
GTXTextureImporter importer = new GTXTextureImporter();
switch (ext)
{
case ".dds":
setting.LoadDDS(FileName, null);
break;
default:
setting.LoadBitMap(FileName);
importer.LoadSetting(setting);
break;
}
if (importer.ShowDialog() == DialogResult.OK)
{
Cursor.Current = Cursors.WaitCursor;
if (setting.GenerateMipmaps)
{
setting.DataBlockOutput.Clear();
setting.DataBlockOutput.Add(setting.GenerateMips());
}
if (setting.DataBlockOutput != null)
{
var surface = setting.CreateGx2Texture(setting.DataBlockOutput[0]);
texture = FromGx2Surface(surface, setting);
LoadOpenGLTexture();
}
else
{
MessageBox.Show("Something went wrong???");
}
UpdateEditor();
}
}
//We reuse GX2 data as it's the same thing
public Texture FromGx2Surface(GTX.GX2Surface surf, GTXImporterSettings settings)
{
Texture tex = new Texture();
tex.Name = settings.TexName;
tex.AAMode = (GX2AAMode)surf.aa;
tex.Alignment = (uint)surf.alignment;
tex.ArrayLength = 1;
tex.Data = surf.data;
tex.MipData = surf.mipData;
tex.Format = (GX2SurfaceFormat)surf.format;
tex.Dim = (GX2SurfaceDim)surf.dim;
tex.Use = (GX2SurfaceUse)surf.use;
tex.TileMode = (GX2TileMode)surf.tileMode;
tex.Swizzle = (uint)surf.swizzle;
tex.Pitch = (uint)surf.pitch;
tex.Depth = (uint)surf.depth;
tex.MipCount = (uint)surf.numMips;
tex.MipOffsets = surf.mipOffset;
tex.Height = (uint)surf.height;
tex.Width = (uint)surf.width;
tex.Regs = new uint[0];
var channels = SetChannelsByFormat((GX2SurfaceFormat)surf.format);
tex.CompSelR = channels[0];
tex.CompSelG = channels[1];
tex.CompSelB = channels[2];
tex.CompSelA = channels[3];
return tex;
}
private void Rename(object sender, EventArgs args)
{
@ -160,11 +357,7 @@ namespace FirstPlugin
SelectedImageKey = "Texture";
Text = tex.Name;
ChannelRed = tex.CompSelR;
ChannelGreen = tex.CompSelG;
ChannelBlue = tex.CompSelB;
ChannelAlpha = tex.CompSelA;
renderedTex = new RenderableTex();
renderedTex.width = (int)tex.Width;
renderedTex.height = (int)tex.Height;
format = (int)tex.Format;
@ -172,30 +365,70 @@ namespace FirstPlugin
int pitch = (int)tex.Pitch;
uint bpp = GTX.surfaceGetBitsPerPixel((uint)format) >> 3;
Console.WriteLine(tex.Width);
Console.WriteLine(tex.Height);
Console.WriteLine(tex.Format);
Console.WriteLine(tex.Swizzle);
Console.WriteLine(tex.Pitch);
Console.WriteLine(tex.Alignment);
Console.WriteLine(tex.Depth);
Console.WriteLine(tex.Dim);
Console.WriteLine(tex.MipCount);
Console.WriteLine(tex.MipOffsets);
Console.WriteLine(tex.AAMode);
Console.WriteLine(tex.Use);
GTX.GX2Surface surf = new GTX.GX2Surface();
surf.bpp = bpp;
surf.height = (int)tex.Height;
surf.width = (int)tex.Width;
surf.aa = (int)tex.AAMode;
surf.alignment = (int)tex.Alignment;
surf.depth = (int)tex.Depth;
surf.dim = (int)tex.Dim;
surf.format = (int)tex.Format;
surf.use = (int)tex.Use;
surf.pitch = (int)tex.Pitch;
surf.height = tex.Height;
surf.width = tex.Width;
surf.aa = (uint)tex.AAMode;
surf.alignment = tex.Alignment;
surf.depth = tex.Depth;
surf.dim = (uint)tex.Dim;
surf.format = (uint)tex.Format;
surf.use = (uint)tex.Use;
surf.pitch = tex.Pitch;
surf.data = tex.Data;
surf.numMips = (int)tex.MipCount;
surf.numMips = tex.MipCount;
surf.mipOffset = tex.MipOffsets;
surf.mipData = tex.MipData;
surf.tileMode = (int)tex.TileMode;
surf.swizzle = (int)tex.Swizzle;
surf.tileMode = (uint)tex.TileMode;
surf.swizzle = tex.Swizzle;
List<byte[]> mips = GTX.Decode(surf);
renderedTex.mipmaps.Add(mips);
// LoadOpenGLTexture();
// else
// Console.WriteLine("Failed to load image!");
renderedTex.data = renderedTex.mipmaps[0][0];
}
public static GX2CompSel[] SetChannelsByFormat(GX2SurfaceFormat Format)
{
GX2CompSel[] channels = new GX2CompSel[4];
switch (Format)
{
case GX2SurfaceFormat.T_BC5_UNorm:
case GX2SurfaceFormat.T_BC5_SNorm:
channels[0] = GX2CompSel.ChannelR;
channels[1] = GX2CompSel.ChannelG;
channels[2] = GX2CompSel.Always0;
channels[3] = GX2CompSel.Always1;
break;
case GX2SurfaceFormat.T_BC4_SNorm:
case GX2SurfaceFormat.T_BC4_UNorm:
channels[0] = GX2CompSel.ChannelR;
channels[1] = GX2CompSel.ChannelR;
channels[2] = GX2CompSel.ChannelR;
channels[3] = GX2CompSel.ChannelR;
break;
default:
channels[0] = GX2CompSel.ChannelR;
channels[1] = GX2CompSel.ChannelG;
channels[2] = GX2CompSel.ChannelB;
channels[3] = GX2CompSel.Always1;
break;
}
return channels;
}
public void Export(string FileName, bool ExportSurfaceLevel = false,
@ -252,6 +485,7 @@ namespace FirstPlugin
if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Unitialized)
return;
switch (format)
{
case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC1_UNORM):
@ -283,8 +517,7 @@ namespace FirstPlugin
break;
case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC5_SNORM):
//OpenTK doesn't load BC5 SNORM textures right so I'll use the same decompress method bntx has
byte[] fixBC5 = DDSCompressor.DecompressBC5(renderedTex.data, renderedTex.width, renderedTex.height, true, true);
renderedTex.data = fixBC5;
renderedTex.data = DDSCompressor.DecompressBC5(renderedTex.mipmaps[0][0], (int)renderedTex.width, (int)renderedTex.height, true, true);
renderedTex.pixelInternalFormat = PixelInternalFormat.Rgba;
renderedTex.pixelFormat = OpenTK.Graphics.OpenGL.PixelFormat.Rgba;
break;
@ -356,12 +589,24 @@ namespace FirstPlugin
public override void OnClick(TreeView treeView)
{
FTEXEditor FTEXEditor = new FTEXEditor();
FTEXEditor.Text = Text;
FTEXEditor.Dock = DockStyle.Fill;
FTEXEditor.LoadPicture(DisplayTexture());
FTEXEditor.LoadProperty(this);
LibraryGUI.Instance.LoadDockContent(FTEXEditor, PluginRuntime.FSHPDockState);
UpdateEditor();
}
public void UpdateEditor()
{
if (Viewport.Instance.gL_ControlModern1.Visible == false)
PluginRuntime.FSHPDockState = WeifenLuo.WinFormsUI.Docking.DockState.Document;
FTEXEditor docked = (FTEXEditor)LibraryGUI.Instance.GetContentDocked(new FTEXEditor());
if (docked == null)
{
docked = new FTEXEditor();
LibraryGUI.Instance.LoadDockContent(docked, PluginRuntime.FSHPDockState);
}
docked.Text = Text;
docked.Dock = DockStyle.Fill;
docked.LoadPicture(DisplayTexture());
docked.LoadProperty(this);
}
public class RenderableTex
@ -373,21 +618,8 @@ namespace FirstPlugin
public PixelType pixelType = PixelType.UnsignedByte;
public int mipMapCount;
public List<List<byte[]>> mipmaps = new List<List<byte[]>>();
public byte[] data;
public byte[] data
{
get
{
return mipmaps[0][0];
}
set
{
mipmaps.Clear();
List<byte[]> mips = new List<byte[]>();
mips.Add(value);
mipmaps.Add(mips);
}
}
public class Surface
{
@ -435,18 +667,23 @@ namespace FirstPlugin
{
throw new Exception($"Bad size from format {Format}");
}
}
public static byte[] CompressBlock(byte[] data, int width, int height, GTX.GX2SurfaceFormat format)
{
if (IsCompressedFormat((GX2SurfaceFormat)format))
return DDSCompressor.CompressBlock(data, width, height, GetCompressedDXGI_FORMAT((GX2SurfaceFormat)format));
else
return DDSCompressor.EncodePixelBlock(data, width, height, GetUncompressedDXGI_FORMAT((GX2SurfaceFormat)format));
}
private static DDS.DXGI_FORMAT GetUncompressedDXGI_FORMAT(GX2SurfaceFormat Format)
{
switch (Format)
{
case GX2SurfaceFormat.TC_R5_G5_B5_A1_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM;
case GX2SurfaceFormat.TC_A1_B5_G5_R5_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM;
case GX2SurfaceFormat.TC_R4_G4_B4_A4_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM;
case GX2SurfaceFormat.TCS_R5_G6_B5_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM;
case GX2SurfaceFormat.TCS_R8_G8_B8_A8_SRGB: return DDS.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
case GX2SurfaceFormat.TCS_R8_G8_B8_A8_SRGB: return DDS.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM;
case GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM;
case GX2SurfaceFormat.TCS_R10_G10_B10_A2_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM;
case GX2SurfaceFormat.TC_R11_G11_B10_Float: return DDS.DXGI_FORMAT.DXGI_FORMAT_R11G11B10_FLOAT;
@ -484,11 +721,11 @@ namespace FirstPlugin
switch (Format)
{
case GX2SurfaceFormat.T_BC1_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM;
case GX2SurfaceFormat.T_BC1_SRGB: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM_SRGB;
case GX2SurfaceFormat.T_BC1_SRGB: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM;
case GX2SurfaceFormat.T_BC2_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM;
case GX2SurfaceFormat.T_BC2_SRGB: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM_SRGB;
case GX2SurfaceFormat.T_BC2_SRGB: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM;
case GX2SurfaceFormat.T_BC3_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM;
case GX2SurfaceFormat.T_BC3_SRGB: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM_SRGB;
case GX2SurfaceFormat.T_BC3_SRGB: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM;
case GX2SurfaceFormat.T_BC4_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC4_UNORM;
case GX2SurfaceFormat.T_BC4_SNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC4_SNORM;
case GX2SurfaceFormat.T_BC5_UNorm: return DDS.DXGI_FORMAT.DXGI_FORMAT_BC5_UNORM;
@ -503,7 +740,8 @@ namespace FirstPlugin
}
public Bitmap UpdateBitmap(Bitmap image)
{
return ColorComponentSelector(image, ChannelRed, ChannelGreen, ChannelBlue, ChannelAlpha);
return ColorComponentSelector(image, texture.CompSelR,
texture.CompSelG, texture.CompSelB, texture.CompSelA);
}
public static Bitmap ColorComponentSelector(Bitmap image, GX2CompSel R, GX2CompSel G, GX2CompSel B, GX2CompSel A)
{

View file

@ -72,24 +72,24 @@ namespace FirstPlugin
//Todo. Add swizzling back
public struct GX2Surface
{
public int dim;
public int width;
public int height;
public int depth;
public int numMips;
public int format;
public int aa;
public int use;
public uint dim;
public uint width;
public uint height;
public uint depth;
public uint numMips;
public uint format;
public uint aa;
public uint use;
public int resourceFlags;
public int imageSize;
public int imagePtr;
public uint imageSize;
public uint imagePtr;
public int pMem;
public int mipSize;
public int mipPtr;
public int tileMode;
public int swizzle;
public int alignment;
public int pitch;
public uint mipSize;
public uint mipPtr;
public uint tileMode;
public uint swizzle;
public uint alignment;
public uint pitch;
public uint bpp;
public byte[] data;
@ -483,49 +483,52 @@ namespace FirstPlugin
Console.WriteLine($"tileType {surf.tileType}");
Console.WriteLine($"tileIndex {surf.tileIndex}");
}
static bool DebugSurface = true;
static bool DebugSurface = false;
public static List<byte[]> Decode(GX2Surface tex)
{
var surfInfo = getSurfaceInfo((GX2SurfaceFormat)tex.format, tex.width, tex.height, tex.depth, (uint)tex.dim, (uint)tex.tileMode, (uint)tex.aa, 0);
uint blkWidth, blkHeight;
if (IsFormatBCN((GX2SurfaceFormat)tex.format))
{
blkWidth = 4;
blkHeight = 4;
}
else
{
blkWidth = 1;
blkHeight = 1;
}
Console.WriteLine(tex.tileMode);
byte[] data = tex.data;
var surfInfo = getSurfaceInfo((GX2SurfaceFormat)tex.format, tex.width, tex.height, tex.depth, (uint)tex.dim, (uint)tex.tileMode, (uint)tex.aa, 0);
Debug(surfInfo);
uint bpp = TegraX1Swizzle.DIV_ROUND_UP(surfInfo.bpp, 8);
if (surfInfo.depth != 1)
throw new Exception("Unsupported Depth!");
throw new Exception($"Unsupported Depth {surfInfo.depth}!");
List<byte[]> result = new List<byte[]>();
for (int mipLevel = 0; mipLevel < tex.numMips; mipLevel++)
{
int size;
if (IsFormatBCN((GX2SurfaceFormat)tex.format))
size = ((Math.Max(1, tex.width >> mipLevel) + 3) >> 2) * ((Math.Max(1, tex.height >> mipLevel) + 3) >> 2) * (int)tex.bpp;
else
size = Math.Max(1, tex.width >> mipLevel) * Math.Max(1, tex.height >> mipLevel) * (int)tex.bpp;
uint width_ = (uint)Math.Max(1, tex.width >> mipLevel);
uint height_ = (uint)Math.Max(1, tex.height >> mipLevel);
uint size = TegraX1Swizzle.DIV_ROUND_UP(width_, blkWidth) * TegraX1Swizzle.DIV_ROUND_UP(height_, blkHeight) * bpp;
byte[] data;
if (mipLevel == 0)
{
data = new byte[surfInfo.surfSize];
}
else
{
uint mipOffset;
if (mipLevel != 0)
{
mipOffset = (tex.mipOffset[mipLevel - 1]);
if (mipLevel == 1)
mipOffset = (uint)(tex.mipOffset[mipLevel - 1] - surfInfo.surfSize);
else
mipOffset = (uint)tex.mipOffset[mipLevel - 1];
// Console.WriteLine("mipOffset " + tex.mipOffset[mipLevel - 1]);
// Console.WriteLine("surfSize " + surfInfo.surfSize);
mipOffset -= (uint)surfInfo.surfSize;
surfInfo = getSurfaceInfo((GX2SurfaceFormat)tex.format, tex.width, tex.height, tex.depth, (uint)tex.dim, (uint)tex.tileMode, (uint)tex.aa, mipLevel);
data = new byte[surfInfo.surfSize + mipOffset];
Array.Copy(tex.mipData, mipOffset, data, 0, surfInfo.surfSize);
}
byte[] deswizzled = deswizzle(Math.Max(1, (uint)tex.width >> mipLevel), Math.Max(1, (uint)tex.height >> mipLevel), (uint)surfInfo.height, (uint)tex.format,
(uint)surfInfo.tileMode, (uint)tex.swizzle, (uint)surfInfo.pitch, (uint)surfInfo.bpp, data);
byte[] deswizzled = deswizzle(width_, height_, surfInfo.height, (uint)tex.format,
surfInfo.tileMode, (uint)tex.swizzle, surfInfo.pitch, surfInfo.bpp, data);
//Create a copy and use that to remove uneeded data
byte[] result_ = new byte[size];
Array.Copy(deswizzled, 0, result_, 0, size);
@ -591,17 +594,17 @@ namespace FirstPlugin
private static byte[] swizzleSurf(uint width, uint height, uint height_, uint format, uint tileMode, uint swizzle_,
uint pitch, uint bitsPerPixel, byte[] data, int swizzle)
{
Console.WriteLine("swizzle");
Console.WriteLine("swizzling level....");
Console.WriteLine("---------------------------");
Console.WriteLine(width);
Console.WriteLine(height);
Console.WriteLine(height_);
Console.WriteLine(format);
Console.WriteLine(tileMode);
Console.WriteLine(swizzle_);
Console.WriteLine(pitch);
Console.WriteLine(bitsPerPixel);
Console.WriteLine(swizzle);
Console.WriteLine("width " + width);
Console.WriteLine("height " + height);
Console.WriteLine("height_ " + height_);
Console.WriteLine("format " + format);
Console.WriteLine("tileMode " + tileMode);
Console.WriteLine("swizzle_ " + swizzle_);
Console.WriteLine("pitch " + pitch);
Console.WriteLine("bitsPerPixel " + bitsPerPixel);
Console.WriteLine("swizzle " + swizzle);
Console.WriteLine("---------------------------");
uint bytesPerPixel = bitsPerPixel / 8;
@ -2265,7 +2268,7 @@ namespace FirstPlugin
return ~(align - 1) & (x + align - 1);
}
public static surfaceOut getSurfaceInfo(GX2SurfaceFormat surfaceFormat, int surfaceWidth, int surfaceHeight, int surfaceDepth, uint surfaceDim, uint surfaceTileMode, uint surfaceAA, int level)
public static surfaceOut getSurfaceInfo(GX2SurfaceFormat surfaceFormat, uint surfaceWidth, uint surfaceHeight, uint surfaceDepth, uint surfaceDim, uint surfaceTileMode, uint surfaceAA, int level)
{
GX2Surface surface = new GX2Surface();
@ -2312,34 +2315,34 @@ namespace FirstPlugin
}
else if (dim == 1)
{
pSurfOut.height = (uint)Math.Max(1, surfaceHeight >> level);
pSurfOut.height = Math.Max(1, surfaceHeight >> level);
pSurfOut.depth = 1;
}
else if (dim == 2)
{
pSurfOut.height = (uint)Math.Max(1, surfaceHeight >> level);
pSurfOut.depth = (uint)Math.Max(1, surfaceDepth >> level);
pSurfOut.height = Math.Max(1, surfaceHeight >> level);
pSurfOut.depth = Math.Max(1, surfaceDepth >> level);
}
else if (dim == 3)
{
pSurfOut.height = (uint)Math.Max(1, surfaceHeight >> level);
pSurfOut.depth = (uint)Math.Max(6, surfaceDepth);
pSurfOut.height = Math.Max(1, surfaceHeight >> level);
pSurfOut.depth = Math.Max(6, surfaceDepth);
}
else if (dim == 4)
{
pSurfOut.height = 1;
pSurfOut.depth = (uint)surfaceDepth;
pSurfOut.depth = surfaceDepth;
}
else if (dim == 5)
{
pSurfOut.height = (uint)Math.Max(1, surfaceHeight >> level);
pSurfOut.depth = (uint)surfaceDepth;
pSurfOut.height = Math.Max(1, surfaceHeight >> level);
pSurfOut.depth = surfaceDepth;
}
pSurfOut.height = (uint)(~(blockSize - 1) & (pSurfOut.height + blockSize - 1)) / blockSize;
pSurfOut.pixelPitch = (uint)(~(blockSize - 1) & ((surfaceWidth >> level) + blockSize - 1));
pSurfOut.height = (~(blockSize - 1) & (pSurfOut.height + blockSize - 1)) / blockSize;
pSurfOut.pixelPitch = (~(blockSize - 1) & ((surfaceWidth >> level) + blockSize - 1));
pSurfOut.pixelPitch = Math.Max(blockSize, pSurfOut.pixelPitch);
pSurfOut.pixelHeight = (uint)(~(blockSize - 1) & ((surfaceHeight >> level) + blockSize - 1));
pSurfOut.pixelHeight = (~(blockSize - 1) & ((surfaceHeight >> level) + blockSize - 1));
pSurfOut.pixelHeight = Math.Max(blockSize, pSurfOut.pixelHeight);
pSurfOut.pitch = Math.Max(1, pSurfOut.pitch);
pSurfOut.height = Math.Max(1, pSurfOut.height);

View file

@ -36,7 +36,7 @@
this.Format = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.SwizzleNum = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.GPUAccessFlgComb = new System.Windows.Forms.ComboBox();
this.tileModeCB = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.ImgDimComb = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
@ -57,7 +57,7 @@
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.ForeColor = System.Drawing.Color.White;
this.button2.Location = new System.Drawing.Point(941, 517);
this.button2.Location = new System.Drawing.Point(1009, 517);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(79, 33);
this.button2.TabIndex = 5;
@ -69,7 +69,7 @@
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.ForeColor = System.Drawing.Color.White;
this.button1.Location = new System.Drawing.Point(843, 517);
this.button1.Location = new System.Drawing.Point(911, 517);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(79, 33);
this.button1.TabIndex = 4;
@ -121,23 +121,23 @@
this.label5.TabIndex = 27;
this.label5.Text = "Swizzle";
//
// GPUAccessFlgComb
// tileModeCB
//
this.GPUAccessFlgComb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.GPUAccessFlgComb.FormattingEnabled = true;
this.GPUAccessFlgComb.Location = new System.Drawing.Point(855, 79);
this.GPUAccessFlgComb.Name = "GPUAccessFlgComb";
this.GPUAccessFlgComb.Size = new System.Drawing.Size(172, 21);
this.GPUAccessFlgComb.TabIndex = 26;
this.tileModeCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.tileModeCB.FormattingEnabled = true;
this.tileModeCB.Location = new System.Drawing.Point(855, 79);
this.tileModeCB.Name = "tileModeCB";
this.tileModeCB.Size = new System.Drawing.Size(233, 21);
this.tileModeCB.TabIndex = 26;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(759, 82);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(96, 13);
this.label4.Size = new System.Drawing.Size(54, 13);
this.label4.TabIndex = 25;
this.label4.Text = "GPU Access Flags";
this.label4.Text = "Tile Mode";
//
// ImgDimComb
//
@ -145,7 +145,7 @@
this.ImgDimComb.FormattingEnabled = true;
this.ImgDimComb.Location = new System.Drawing.Point(853, 46);
this.ImgDimComb.Name = "ImgDimComb";
this.ImgDimComb.Size = new System.Drawing.Size(172, 21);
this.ImgDimComb.Size = new System.Drawing.Size(233, 21);
this.ImgDimComb.TabIndex = 24;
//
// label3
@ -222,7 +222,7 @@
this.formatComboBox.FormattingEnabled = true;
this.formatComboBox.Location = new System.Drawing.Point(853, 16);
this.formatComboBox.Name = "formatComboBox";
this.formatComboBox.Size = new System.Drawing.Size(172, 21);
this.formatComboBox.Size = new System.Drawing.Size(233, 21);
this.formatComboBox.TabIndex = 16;
this.formatComboBox.SelectedIndexChanged += new System.EventHandler(this.formatComboBox_SelectedIndexChanged);
//
@ -231,10 +231,10 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.ClientSize = new System.Drawing.Size(1036, 562);
this.ClientSize = new System.Drawing.Size(1100, 562);
this.Controls.Add(this.SwizzleNum);
this.Controls.Add(this.label5);
this.Controls.Add(this.GPUAccessFlgComb);
this.Controls.Add(this.tileModeCB);
this.Controls.Add(this.label4);
this.Controls.Add(this.ImgDimComb);
this.Controls.Add(this.label3);
@ -265,7 +265,7 @@
private Switch_Toolbox.Library.Forms.ListViewCustom listViewCustom1;
private System.Windows.Forms.NumericUpDown SwizzleNum;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox GPUAccessFlgComb;
private System.Windows.Forms.ComboBox tileModeCB;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox ImgDimComb;
private System.Windows.Forms.Label label3;

View file

@ -62,9 +62,9 @@ namespace FirstPlugin
{
ImgDimComb.Items.Add(dim);
}
GPUAccessFlgComb.Items.Add("Texture");
tileModeCB.Items.Add("Texture");
ImgDimComb.SelectedIndex = 1;
GPUAccessFlgComb.SelectedIndex = 0;
tileModeCB.SelectedIndex = 0;
formatComboBox.SelectedItem = SurfaceFormat.BC1_SRGB;
}
TextureImporterSettings SelectedTexSettings;

View file

@ -0,0 +1,375 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Drawing;
using System.Threading.Tasks;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
using Syroot.NintenTools.Bfres.GX2;
namespace FirstPlugin
{
public class GTXImporterSettings
{
public string TexName;
public uint TexWidth;
public uint TexHeight;
public uint MipCount;
public uint bpp;
public uint Depth = 1;
public uint arrayLength = 1;
public List<byte[]> DataBlockOutput = new List<byte[]>();
public List<byte[]> DecompressedData = new List<byte[]>();
public GTX.GX2SurfaceFormat Format;
public bool GenerateMipmaps;
public bool IsSRGB;
public uint tileMode = 4;
public uint swizzle = 4;
public GX2CompSel[] compSel = new GX2CompSel[4];
public GX2SurfaceDim SurfaceDim = GX2SurfaceDim.Dim2D;
public GX2AAMode AAMode = GX2AAMode.Mode1X;
private GTX.GX2SurfaceFormat LoadDDSFormat(uint fourCC, DDS dds = null, bool IsSRGB = false)
{
bool IsDX10 = false;
switch (fourCC)
{
case DDS.FOURCC_DXT1:
if (IsSRGB)
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC1_SRGB;
else
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC1_UNORM;
case DDS.FOURCC_DXT3:
if (IsSRGB)
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC2_SRGB;
else
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC2_UNORM;
case DDS.FOURCC_DXT5:
if (IsSRGB)
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC3_SRGB;
else
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC3_UNORM;
case DDS.FOURCC_BC4U:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC4_UNORM;
case DDS.FOURCC_ATI1:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC4_UNORM;
case DDS.FOURCC_ATI2:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC5_UNORM;
case DDS.FOURCC_BC5U:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC4_UNORM;
case DDS.FOURCC_DX10:
IsDX10 = true;
break;
default:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM;
}
if (IsDX10)
{
switch (dds.DX10header.DXGI_Format)
{
case DDS.DXGI_FORMAT.DXGI_FORMAT_BC4_UNORM:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC4_UNORM;
case DDS.DXGI_FORMAT.DXGI_FORMAT_BC4_SNORM:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC4_SNORM;
case DDS.DXGI_FORMAT.DXGI_FORMAT_BC4_TYPELESS:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC4_UNORM;
case DDS.DXGI_FORMAT.DXGI_FORMAT_BC5_UNORM:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC5_UNORM;
case DDS.DXGI_FORMAT.DXGI_FORMAT_BC5_SNORM:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC5_SNORM;
case DDS.DXGI_FORMAT.DXGI_FORMAT_BC5_TYPELESS:
return GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC5_UNORM;
default:
throw new Exception($"Format {dds.DX10header.DXGI_Format} not supported!");
}
}
throw new Exception($"This shouldn't happen :(");
}
public void LoadDDS(string FileName, byte[] FileData = null)
{
TexName = Path.GetFileNameWithoutExtension(FileName);
DDS dds = new DDS();
if (FileData != null)
dds.Load(new FileReader(new MemoryStream(FileData)));
else
dds.Load(new FileReader(FileName));
MipCount = dds.header.mipmapCount;
TexWidth = dds.header.width;
TexHeight = dds.header.height;
arrayLength = 1;
if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES)
{
arrayLength = 6;
}
DataBlockOutput.Add(dds.bdata);
Format = LoadDDSFormat(dds.header.ddspf.fourCC, dds, IsSRGB);
GTX.GX2Surface tex = CreateGx2Texture(DataBlockOutput[0]);
}
public void LoadBitMap(string FileName)
{
DecompressedData.Clear();
TexName = Path.GetFileNameWithoutExtension(FileName);
Format = GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC1_SRGB;
GenerateMipmaps = true;
Bitmap Image = new Bitmap(FileName);
Image = TextureData.SwapBlueRedChannels(Image);
TexWidth = (uint)Image.Width;
TexHeight = (uint)Image.Height;
MipCount = (uint)GetTotalMipCount();
DecompressedData.Add(BitmapExtension.ImageToByte(Image));
Image.Dispose();
if (DecompressedData.Count == 0)
{
throw new Exception("Failed to load " + Format);
}
}
public int GetTotalMipCount()
{
int MipmapNum = 0;
uint num = Math.Max(TexHeight, TexWidth);
int width = (int)TexWidth;
int height = (int)TexHeight;
while (true)
{
num >>= 1;
width = width / 2;
height = height / 2;
if (width <= 0 || height <= 0)
break;
if (num > 0)
++MipmapNum;
else
break;
}
return MipmapNum;
}
public byte[] GenerateMips(int SurfaceLevel = 0)
{
Bitmap Image = BitmapExtension.GetBitmap(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight);
List<byte[]> mipmaps = new List<byte[]>();
mipmaps.Add(FTEX.CompressBlock(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight, Format));
//while (Image.Width / 2 > 0 && Image.Height / 2 > 0)
// for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
{
Image = BitmapExtension.Resize(Image, Image.Width / 2, Image.Height / 2);
mipmaps.Add(FTEX.CompressBlock(BitmapExtension.ImageToByte(Image), Image.Width, Image.Height, Format));
}
Image.Dispose();
return Utils.CombineByteArray(mipmaps.ToArray());
}
public void Compress()
{
DataBlockOutput.Clear();
foreach (var surface in DecompressedData)
{
DataBlockOutput.Add(FTEX.CompressBlock(surface, (int)TexWidth, (int)TexHeight, Format));
}
}
public GTX.GX2Surface CreateGx2Texture(byte[] imageData)
{
var surfOut = GTX.getSurfaceInfo(Format, TexWidth, TexHeight, 1, 1, tileMode, 0, 0);
uint imageSize = (uint)surfOut.surfSize;
uint alignment = surfOut.baseAlign;
uint pitch = surfOut.pitch;
uint mipSize = 0;
uint dataSize = (uint)imageData.Length;
if (imageData.Length <= 0)
throw new Exception($"Image is empty!!");
if (surfOut.depth != 1)
throw new Exception($"Unsupported Depth {surfOut.depth}!");
uint s = 0;
switch (tileMode)
{
case 1:
case 2:
case 3:
case 16:
s = 0;
break;
default:
s = 0xd0000 | swizzle << 8;
break;
}
uint blkWidth, blkHeight;
if (GTX.IsFormatBCN(Format))
{
blkWidth = 4;
blkHeight = 4;
}
else
{
blkWidth = 1;
blkHeight = 1;
}
List<uint> mipOffsets = new List<uint>();
List<byte[]> Swizzled = new List<byte[]>();
byte[] data;
for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
{
var result = TextureHelper.GetCurrentMipSize(TexWidth, TexHeight, blkWidth, blkHeight, bpp, mipLevel);
uint offset = result.Item1;
uint size = result.Item2;
byte[] data_ = Utils.SubArray(imageData, offset, size);
uint width_ = Math.Max(1, TexWidth >> mipLevel);
uint height_ = Math.Max(1, TexHeight >> mipLevel);
if (mipLevel != 0)
{
surfOut = GTX.getSurfaceInfo(Format, TexWidth, TexHeight, 1, 1, tileMode, 0, mipLevel);
if (mipLevel == 1)
{
if (mipLevel == 1)
mipOffsets.Add(imageSize);
else
mipOffsets.Add(mipSize);
}
}
data_ = Utils.CombineByteArray(data_, new byte[surfOut.surfSize - size]);
byte[] dataAlignBytes = new byte[RoundUp(mipSize, surfOut.baseAlign) - mipSize];
if (mipLevel != 0)
mipSize += (uint)(surfOut.surfSize + dataAlignBytes.Length);
Swizzled.Add(Utils.CombineByteArray(dataAlignBytes, GTX.swizzle(width_, height_, surfOut.height, (uint)Format, surfOut.tileMode, s,
surfOut.pitch, surfOut.bpp, data_)));
}
File.WriteAllBytes("NewSwizzle.bin",Swizzled[0]);
compSel[0] = GX2CompSel.ChannelR;
compSel[1] = GX2CompSel.ChannelG;
compSel[2] = GX2CompSel.ChannelB;
compSel[3] = GX2CompSel.ChannelA;
GTX.GX2Surface surf = new GTX.GX2Surface();
surf.depth = Depth;
surf.width = TexWidth;
surf.height = TexHeight;
surf.depth = 1;
surf.dim = (uint)SurfaceDim;
surf.bpp = GTX.surfaceGetBitsPerPixel((uint)Format >> 3);
surf.tileMode = tileMode;
surf.swizzle = s;
surf.resourceFlags = 0;
surf.pitch = surfOut.pitch;
surf.format = (uint)Format;
surf.numMips = MipCount;
surf.aa = (uint)AAMode;
surf.mipOffset = mipOffsets.ToArray();
surf.numMips = (uint)Swizzled.Count;
surf.alignment = alignment;
surf.mipSize = mipSize;
surf.imageSize = imageSize;
surf.data = Swizzled[0];
List<byte[]> mips = new List<byte[]>();
for (int mipLevel = 1; mipLevel < Swizzled.Count; mipLevel++)
{
mips.Add(Swizzled[mipLevel]);
}
surf.mipData = Utils.CombineByteArray(mips.ToArray());
mips.Clear();
Console.WriteLine("");
Console.WriteLine("// ----- GX2Surface Info ----- ");
Console.WriteLine(" dim = 1");
Console.WriteLine(" width = " + surf.width);
Console.WriteLine(" height = " + surf.height);
Console.WriteLine(" depth = 1");
Console.WriteLine(" numMips = " + surf.numMips);
Console.WriteLine(" format = " + surf.format);
Console.WriteLine(" aa = 0");
Console.WriteLine(" use = 1");
Console.WriteLine(" imageSize = " + surf.imageSize);
Console.WriteLine(" mipSize = " + surf.mipSize);
Console.WriteLine(" tileMode = " + surf.tileMode);
Console.WriteLine(" swizzle = " + surf.swizzle);
Console.WriteLine(" alignment = " + surf.alignment);
Console.WriteLine(" pitch = " + surf.pitch);
Console.WriteLine("");
Console.WriteLine(" GX2 Component Selector:");
Console.WriteLine(" Red Channel: " + compSel[0]);
Console.WriteLine(" Green Channel: " + compSel[1]);
Console.WriteLine(" Blue Channel: " + compSel[2]);
Console.WriteLine(" Alpha Channel: " + compSel[3]);
Console.WriteLine("");
Console.WriteLine(" bits per pixel = " + (surf.bpp << 3));
Console.WriteLine(" bytes per pixel = " + surf.bpp);
Console.WriteLine(" realSize = " + imageData.Length);
return surf;
}
private static Tuple<uint, uint> GetCurrentMipSize(uint width, uint height, uint bpp, int CurLevel, bool IsCompressed)
{
uint offset = 0;
uint size = 0;
for (int mipLevel = 0; mipLevel < CurLevel; mipLevel++)
{
int level = mipLevel + 1;
if (IsCompressed)
offset += ((Math.Max(1, width >> level) + 3) >> 2) * ((Math.Max(1, height >> level) + 3) >> 2) * bpp;
else
offset += Math.Max(1, width >> level) * Math.Max(1, height >> level) * bpp;
}
if (IsCompressed)
size = ((Math.Max(1, width >> CurLevel) + 3) >> 2) * ((Math.Max(1, height >> CurLevel) + 3) >> 2) * bpp;
else
size = Math.Max(1, width >> CurLevel) * Math.Max(1, height >> CurLevel) * bpp;
return Tuple.Create(offset, size);
}
private uint getAlignBlockSize(uint dataOffset, uint alignment)
{
uint alignSize = RoundUp(dataOffset, alignment) - dataOffset - 32;
uint z = 1;
while (alignSize <= 0)
{
alignSize = RoundUp(dataOffset + (alignment * z), alignment) - dataOffset - 32;
z += 1;
}
return alignSize;
}
private int RoundUp(int X, int Y)
{
return ((X - 1) | (Y - 1)) + 1;
}
private uint RoundUp(uint X, uint Y)
{
return ((X - 1) | (Y - 1)) + 1;
}
}
}

View file

@ -0,0 +1,281 @@
namespace FirstPlugin
{
partial class GTXTextureImporter
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GTXTextureImporter));
this.SwizzleNum = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.tileModeCB = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.ImgDimComb = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.MipmapNum = new System.Windows.Forms.NumericUpDown();
this.WidthLabel = new System.Windows.Forms.Label();
this.HeightLabel = new System.Windows.Forms.Label();
this.formatComboBox = new System.Windows.Forms.ComboBox();
this.listViewCustom1 = new Switch_Toolbox.Library.Forms.ListViewCustom();
this.Name = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.Format = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.pictureBox1 = new Switch_Toolbox.Library.Forms.PictureBoxCustom();
((System.ComponentModel.ISupportInitialize)(this.SwizzleNum)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.MipmapNum)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// SwizzleNum
//
this.SwizzleNum.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.SwizzleNum.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.SwizzleNum.ForeColor = System.Drawing.Color.White;
this.SwizzleNum.Location = new System.Drawing.Point(877, 142);
this.SwizzleNum.Name = "SwizzleNum";
this.SwizzleNum.Size = new System.Drawing.Size(130, 16);
this.SwizzleNum.TabIndex = 44;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(769, 142);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(42, 13);
this.label5.TabIndex = 43;
this.label5.Text = "Swizzle";
//
// tileModeCB
//
this.tileModeCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.tileModeCB.FormattingEnabled = true;
this.tileModeCB.Location = new System.Drawing.Point(877, 69);
this.tileModeCB.Name = "tileModeCB";
this.tileModeCB.Size = new System.Drawing.Size(172, 21);
this.tileModeCB.TabIndex = 42;
this.tileModeCB.SelectedIndexChanged += new System.EventHandler(this.tileModeCB_SelectedIndexChanged);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(769, 72);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(54, 13);
this.label4.TabIndex = 41;
this.label4.Text = "Tile Mode";
//
// ImgDimComb
//
this.ImgDimComb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ImgDimComb.FormattingEnabled = true;
this.ImgDimComb.Location = new System.Drawing.Point(875, 36);
this.ImgDimComb.Name = "ImgDimComb";
this.ImgDimComb.Size = new System.Drawing.Size(172, 21);
this.ImgDimComb.TabIndex = 40;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(769, 39);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(88, 13);
this.label3.TabIndex = 39;
this.label3.Text = "Image Dimension";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(766, 9);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(39, 13);
this.label2.TabIndex = 38;
this.label2.Text = "Format";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(769, 107);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(90, 13);
this.label1.TabIndex = 37;
this.label1.Text = "Number MipMaps";
//
// MipmapNum
//
this.MipmapNum.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.MipmapNum.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.MipmapNum.ForeColor = System.Drawing.Color.White;
this.MipmapNum.Location = new System.Drawing.Point(877, 105);
this.MipmapNum.Name = "MipmapNum";
this.MipmapNum.Size = new System.Drawing.Size(130, 16);
this.MipmapNum.TabIndex = 36;
//
// WidthLabel
//
this.WidthLabel.AutoSize = true;
this.WidthLabel.Location = new System.Drawing.Point(769, 210);
this.WidthLabel.Name = "WidthLabel";
this.WidthLabel.Size = new System.Drawing.Size(35, 13);
this.WidthLabel.TabIndex = 35;
this.WidthLabel.Text = "Width";
//
// HeightLabel
//
this.HeightLabel.AutoSize = true;
this.HeightLabel.Location = new System.Drawing.Point(769, 175);
this.HeightLabel.Name = "HeightLabel";
this.HeightLabel.Size = new System.Drawing.Size(38, 13);
this.HeightLabel.TabIndex = 34;
this.HeightLabel.Text = "Height";
//
// formatComboBox
//
this.formatComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.formatComboBox.FormattingEnabled = true;
this.formatComboBox.Location = new System.Drawing.Point(875, 6);
this.formatComboBox.Name = "formatComboBox";
this.formatComboBox.Size = new System.Drawing.Size(172, 21);
this.formatComboBox.TabIndex = 32;
this.formatComboBox.SelectedIndexChanged += new System.EventHandler(this.formatComboBox_SelectedIndexChanged);
//
// listViewCustom1
//
this.listViewCustom1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.listViewCustom1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Name,
this.Format});
this.listViewCustom1.Dock = System.Windows.Forms.DockStyle.Left;
this.listViewCustom1.ForeColor = System.Drawing.Color.White;
this.listViewCustom1.Location = new System.Drawing.Point(0, 0);
this.listViewCustom1.Name = "listViewCustom1";
this.listViewCustom1.Size = new System.Drawing.Size(237, 515);
this.listViewCustom1.TabIndex = 31;
this.listViewCustom1.UseCompatibleStateImageBehavior = false;
this.listViewCustom1.View = System.Windows.Forms.View.Details;
this.listViewCustom1.SelectedIndexChanged += new System.EventHandler(this.listViewCustom1_SelectedIndexChanged);
//
// Name
//
this.Name.Text = "Name";
this.Name.Width = 104;
//
// Format
//
this.Format.Text = "Format";
//
// button2
//
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.ForeColor = System.Drawing.Color.White;
this.button2.Location = new System.Drawing.Point(993, 470);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(79, 33);
this.button2.TabIndex = 30;
this.button2.Text = "Cancel";
this.button2.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.ForeColor = System.Drawing.Color.White;
this.button1.Location = new System.Drawing.Point(895, 470);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(79, 33);
this.button1.TabIndex = 29;
this.button1.Text = "Ok";
this.button1.UseVisualStyleBackColor = true;
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Left;
this.pictureBox1.Location = new System.Drawing.Point(237, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(513, 515);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 33;
this.pictureBox1.TabStop = false;
//
// GTXTextureImporter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.ClientSize = new System.Drawing.Size(1084, 515);
this.Controls.Add(this.SwizzleNum);
this.Controls.Add(this.label5);
this.Controls.Add(this.tileModeCB);
this.Controls.Add(this.label4);
this.Controls.Add(this.ImgDimComb);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.MipmapNum);
this.Controls.Add(this.WidthLabel);
this.Controls.Add(this.HeightLabel);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.formatComboBox);
this.Controls.Add(this.listViewCustom1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.ForeColor = System.Drawing.Color.White;
this.Text = "GTXTextureImporter";
((System.ComponentModel.ISupportInitialize)(this.SwizzleNum)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.MipmapNum)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.NumericUpDown SwizzleNum;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox tileModeCB;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox ImgDimComb;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.NumericUpDown MipmapNum;
private System.Windows.Forms.Label WidthLabel;
private System.Windows.Forms.Label HeightLabel;
private Switch_Toolbox.Library.Forms.PictureBoxCustom pictureBox1;
private System.Windows.Forms.ComboBox formatComboBox;
private Switch_Toolbox.Library.Forms.ListViewCustom listViewCustom1;
private System.Windows.Forms.ColumnHeader Name;
private System.Windows.Forms.ColumnHeader Format;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
}
}

View file

@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FirstPlugin
{
public partial class GTXTextureImporter : Form
{
public GTXTextureImporter()
{
InitializeComponent();
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TCS_R10_G10_B10_A2_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TCS_R5_G6_B5_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TC_R5_G5_B5_A1_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TC_R4_G4_B4_A4_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TC_R8_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TC_R8_G8_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC1_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC1_SRGB);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC2_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC2_SRGB);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC3_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC3_SRGB);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC4_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC4_SNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC5_UNORM);
formatComboBox.Items.Add(GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC5_SNORM);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_DEFAULT);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_LINEAR_ALIGNED);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_1D_TILED_THIN1);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_1D_TILED_THICK);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_2D_TILED_THIN1);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_2D_TILED_THIN2);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_2D_TILED_THIN4);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_2D_TILED_THICK);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_2B_TILED_THIN1);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_2B_TILED_THIN2);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_2B_TILED_THIN4);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_2B_TILED_THICK);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_3D_TILED_THIN1);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_3D_TILED_THICK);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_3B_TILED_THIN1);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_3B_TILED_THICK);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_LINEAR_SPECIAL);
tileModeCB.Items.Add(GTX.GX2TileMode.GX2_TILE_MODE_DEFAULT_FIX2197);
tileModeCB.SelectedItem = GTX.GX2TileMode.GX2_TILE_MODE_2D_TILED_THIN1;
formatComboBox.SelectedItem = GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC1_SRGB;
}
GTXImporterSettings SelectedTexSettings;
List<GTXImporterSettings> settings = new List<GTXImporterSettings>();
public void LoadSettings(List<GTXImporterSettings> s)
{
settings = s;
foreach (var setting in settings)
{
listViewCustom1.Items.Add(setting.TexName).SubItems.Add(setting.Format.ToString());
}
listViewCustom1.Items[0].Selected = true;
listViewCustom1.Select();
}
public void LoadSetting(GTXImporterSettings setting)
{
settings = new List<GTXImporterSettings>();
settings.Add(setting);
listViewCustom1.Items.Add(setting.TexName).SubItems.Add(setting.Format.ToString());
listViewCustom1.Items[0].Selected = true;
listViewCustom1.Select();
}
private Thread Thread;
public void SetupSettings()
{
if (SelectedTexSettings.Format == GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_INVALID)
return;
if (Thread != null && Thread.IsAlive)
Thread.Abort();
if (formatComboBox.SelectedItem is GTX.GX2SurfaceFormat)
{
SelectedTexSettings.Format = (GTX.GX2SurfaceFormat)formatComboBox.SelectedItem;
listViewCustom1.SelectedItems[0].SubItems[1].Text = SelectedTexSettings.Format.ToString();
}
Bitmap bitmap = Switch_Toolbox.Library.Imaging.GetLoadingImage();
Thread = new Thread((ThreadStart)(() =>
{
pictureBox1.Image = bitmap;
SelectedTexSettings.Compress();
bitmap = FTEX.DecodeBlock(SelectedTexSettings.DataBlockOutput[0], SelectedTexSettings.
TexWidth, SelectedTexSettings.TexHeight, (Syroot.NintenTools.Bfres.GX2.GX2SurfaceFormat)SelectedTexSettings.Format);
pictureBox1.Image = bitmap;
}));
Thread.Start();
}
private void tileModeCB_SelectedIndexChanged(object sender, EventArgs e)
{
if (tileModeCB.SelectedIndex > -1 && SelectedTexSettings != null)
SelectedTexSettings.tileMode = (uint)tileModeCB.SelectedItem;
}
private void formatComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (formatComboBox.SelectedIndex > -1 && SelectedTexSettings != null)
{
SetupSettings();
}
}
private void listViewCustom1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listViewCustom1.SelectedItems.Count > 0)
{
SelectedTexSettings = settings[listViewCustom1.SelectedIndices[0]];
formatComboBox.SelectedItem = SelectedTexSettings.Format;
SetupSettings();
MipmapNum.Maximum = SelectedTexSettings.GetTotalMipCount();
MipmapNum.Value = SelectedTexSettings.MipCount;
}
}
}
}

View file

@ -0,0 +1,328 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pictureBox1.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAlgAAAJYCAMAAACJuGjuAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAADAFBMVEXMzMzNzc3Ozs7Pz8/Q0NDR0dHS
0tLT09PU1NTV1dXW1tbX19fY2NjZ2dna2trb29vc3Nzd3d3e3t7f39/g4ODh4eHi4uLj4+Pk5OTl5eXm
5ubn5+fo6Ojp6enq6urr6+vs7Ozt7e3u7u7v7+/w8PDx8fHy8vLz8/P09PT19fX29vb39/f4+Pj5+fn6
+vr7+/v8/Pz9/f3+/v7///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA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goBw1OTv
PhP65gOeCX1AQPGZ0HfvPxM6PEv5hzwT+owEas+Ebnz8M6GfZwhMfNjyu8+EPn/8M6Fv6s+ERkL/xjOh
cesy2vNO2vPu4g8z8ZunPkzhVCyjYjkVi1Qsp2KRiuVULKNiGRXLqFhGxXIqFqlYTsUiFcupWEbFMiqW
UbGMiuVULFKxnIpFKpZTsYyKZVQso2KZH1Is/D4jM+80LrRKBLQZIoHmCIFJmoigv0FAZZjRKRDQqYuE
kvArnu7TMGOwQkBrBGaOgI59BJSFX8p1KhBQJ17HuoWEyvhbosYIaBiu4xxnNGq/GayHAJq139oVZ/QQ
mGk4zW7tt3aFGa0JAhPXKv5Grfv8ckaj93+veSuXxEAIUwAAAABJRU5ErkJggg==
</value>
</data>
</root>

View file

@ -145,7 +145,7 @@ namespace FirstPlugin
DataBlockOutput.Add(dds.bdata);
Format = LoadDDSFormat(dds.header.ddspf.fourCC, dds, IsSRGB);
Format = LoadDDSFormat(dds.header.ddspf.fourCC.ToString(), dds, IsSRGB);
Texture tex = FromBitMap(DataBlockOutput[0], this);
@ -237,31 +237,6 @@ namespace FirstPlugin
{
return TegraX1Swizzle.DIV_ROUND_UP(value1, value2);
}
public static byte[] SubArray(byte[] data, uint offset, uint length)
{
return data.Skip((int)offset).Take((int)length).ToArray();
}
private static Tuple<uint, uint> GetCurrentMipSize(uint width, uint height, uint blkHeight, uint blkWidth, uint bpp, int CurLevel)
{
uint offset = 0;
uint width_ = 0;
uint height_ = 0;
for (int mipLevel = 0; mipLevel < CurLevel; mipLevel++)
{
width_ = DIV_ROUND_UP(Math.Max(1, width >> mipLevel), blkWidth);
height_ = DIV_ROUND_UP(Math.Max(1, height >> mipLevel), blkHeight);
offset += width_ * height_ * bpp;
}
width_ = DIV_ROUND_UP(Math.Max(1, width >> CurLevel), blkWidth);
height_ = DIV_ROUND_UP(Math.Max(1, height >> CurLevel), blkHeight);
uint size = width_ * height_ * bpp;
return Tuple.Create(offset, size);
}
public Texture FromBitMap(byte[] data, TextureImporterSettings settings)
{
Texture tex = new Texture();
@ -357,11 +332,11 @@ namespace FirstPlugin
List<byte[]> mipmaps = new List<byte[]>();
for (int mipLevel = 0; mipLevel < tex.MipCount; mipLevel++)
{
var result = GetCurrentMipSize(tex.Width, tex.Height, blkWidth, blkHeight, bpp, mipLevel);
var result = TextureHelper.GetCurrentMipSize(tex.Width, tex.Height, blkWidth, blkHeight, bpp, mipLevel);
uint offset = result.Item1;
uint size = result.Item2;
byte[] data_ = SubArray(data, offset, size);
byte[] data_ = Utils.SubArray(data, offset, size);
uint width_ = Math.Max(1, tex.Width >> mipLevel);
uint height_ = Math.Max(1, tex.Height >> mipLevel);

View file

@ -21,7 +21,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Switch_Toolbox\Lib\Plugins\</OutputPath>
<OutputPath>..\Switch_Toolbox\bin\Debug\Lib\Plugins\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@ -267,6 +267,13 @@
<DependentUpon>BfresShapeEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\FormLoader.cs" />
<Compile Include="GUI\TextureUI\GTXImporterSettings.cs" />
<Compile Include="GUI\TextureUI\GTXTextureImporter.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\TextureUI\GTXTextureImporter.Designer.cs">
<DependentUpon>GTXTextureImporter.cs</DependentUpon>
</Compile>
<Compile Include="GUI\TextureUI\XTXEditor.cs">
<SubType>UserControl</SubType>
</Compile>
@ -424,6 +431,9 @@
<EmbeddedResource Include="GUI\BFRES\BfresShapeEditor.resx">
<DependentUpon>BfresShapeEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\TextureUI\GTXTextureImporter.resx">
<DependentUpon>GTXTextureImporter.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\TextureUI\XTXEditor.resx">
<DependentUpon>XTXEditor.cs</DependentUpon>
</EmbeddedResource>
@ -490,7 +500,6 @@
<ProjectReference Include="..\Switch_Toolbox_Library\Switch_Toolbox_Library.csproj">
<Project>{96820047-2a39-4e5a-bfa4-e84fff5c66cf}</Project>
<Name>Switch_Toolbox_Library</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>

View file

@ -18,8 +18,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Updater\Updater.
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "Switch_Toolbox\Lib\DirectXTex\DirectXTex.vcxproj", "{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GTXDEBUG", "GTXDEBUG\GTXDEBUG.csproj", "{C610B02F-97AE-48A8-B967-1F4E97DB2903}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -68,21 +66,14 @@ Global
{D82A2C08-2A65-43AF-BDA6-A36CC27AA003}.Release|Any CPU.Build.0 = Release|Any CPU
{D82A2C08-2A65-43AF-BDA6-A36CC27AA003}.Release|x64.ActiveCfg = Release|Any CPU
{D82A2C08-2A65-43AF-BDA6-A36CC27AA003}.Release|x64.Build.0 = Release|Any CPU
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Debug|Any CPU.ActiveCfg = Debug|x64
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Debug|Any CPU.ActiveCfg = Debug|Win32
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Debug|Any CPU.Build.0 = Debug|Win32
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Debug|x64.ActiveCfg = Debug|x64
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Debug|x64.Build.0 = Debug|x64
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Release|Any CPU.ActiveCfg = Release|Win32
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Release|Any CPU.Build.0 = Release|Win32
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Release|x64.ActiveCfg = Release|x64
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Release|x64.Build.0 = Release|x64
{C610B02F-97AE-48A8-B967-1F4E97DB2903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C610B02F-97AE-48A8-B967-1F4E97DB2903}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C610B02F-97AE-48A8-B967-1F4E97DB2903}.Debug|x64.ActiveCfg = Debug|Any CPU
{C610B02F-97AE-48A8-B967-1F4E97DB2903}.Debug|x64.Build.0 = Debug|Any CPU
{C610B02F-97AE-48A8-B967-1F4E97DB2903}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C610B02F-97AE-48A8-B967-1F4E97DB2903}.Release|Any CPU.Build.0 = Release|Any CPU
{C610B02F-97AE-48A8-B967-1F4E97DB2903}.Release|x64.ActiveCfg = Release|Any CPU
{C610B02F-97AE-48A8-B967-1F4E97DB2903}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -30,7 +30,6 @@
<ProjectGuid>{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>DirectXTex</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="OpenTK" publicKeyToken="bad199fe84eb3df4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="LZ4pn" publicKeyToken="62e1b5ec1eec9bdd" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.10.93" newVersion="1.0.10.93" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="K4os.Hash.xxHash" publicKeyToken="32cd54395057cec3" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.5.0" newVersion="1.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /></startup></configuration>

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -26,6 +26,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -266,7 +267,6 @@
<ProjectReference Include="..\Switch_Toolbox_Library\Switch_Toolbox_Library.csproj">
<Project>{96820047-2a39-4e5a-bfa4-e84fff5c66cf}</Project>
<Name>Switch_Toolbox_Library</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\Updater\Updater.csproj">
<Project>{d82a2c08-2a65-43af-bda6-a36cc27aa003}</Project>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
</PropertyGroup>
</Project>

View file

@ -18,6 +18,19 @@ namespace Switch_Toolbox.Library
//Data from https://github.com/jam1garner/Smash-Forge/blob/master/Smash%20Forge/Filetypes/Textures/DDS.cs
public class DDS
{
public const uint FOURCC_DXT1 = 0x31545844;
public const uint FOURCC_DXT2 = 0x32545844;
public const uint FOURCC_DXT3 = 0x33545844;
public const uint FOURCC_DXT4 = 0x34545844;
public const uint FOURCC_DXT5 = 0x35545844;
public const uint FOURCC_ATI1 = 0x31495441;
public const uint FOURCC_BC4U = 0x55344342;
public const uint FOURCC_BC5U = 0x55354342;
public const uint FOURCC_DX10 = 0x30315844;
public const uint FOURCC_ATI2 = 0x32495441;
public const uint FOURCC_RXGB = 0x42475852;
public enum CubemapFace
{
PosX,
@ -79,17 +92,21 @@ namespace Switch_Toolbox.Library
{
case 0x00000000: //RGBA
return 0x4;
case 0x31545844: //DXT1
case FOURCC_DXT1:
return 0x8;
case 0x33545844: //DXT3
case FOURCC_DXT2:
return 0x10;
case 0x35545844: //DXT5
case FOURCC_DXT3:
return 0x10;
case 0x31495441: //ATI1
case 0x55344342: //BC4U
case FOURCC_DXT4:
return 0x10;
case FOURCC_DXT5:
return 0x10;
case FOURCC_ATI1:
case FOURCC_BC4U:
return 0x8;
case 0x32495441: //ATI2
case 0x55354342: //BC5U
case FOURCC_ATI2:
case FOURCC_BC5U:
return 0x10;
default:
return 0;
@ -101,19 +118,21 @@ namespace Switch_Toolbox.Library
{
case DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM_SRGB:
header.ddspf.fourCC = "DXT1";
header.ddspf.fourCC = FOURCC_DXT1;
break;
case DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM_SRGB:
header.ddspf.fourCC = "DXT3";
header.ddspf.fourCC = FOURCC_DXT3;
break;
case DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM_SRGB:
header.ddspf.fourCC = "DXT5";
header.ddspf.fourCC = FOURCC_DXT5;
break;
}
}
public bool IsDX10;
public uint imageSize;
public Header header;
public DX10Header DX10header;
public class Header
@ -131,7 +150,7 @@ namespace Switch_Toolbox.Library
{
public uint size = 0x20;
public uint flags = 0x00000000;
public string fourCC;
public uint fourCC;
public uint RGBBitCount = 0;
public uint RBitMask = 0x00000000;
public uint GBitMask = 0x00000000;
@ -320,7 +339,7 @@ namespace Switch_Toolbox.Library
header.ddspf.size = reader.ReadUInt32();
header.ddspf.flags = reader.ReadUInt32();
header.ddspf.fourCC = reader.ReadString(4);
header.ddspf.fourCC = reader.ReadUInt32();
header.ddspf.RGBBitCount = reader.ReadUInt32();
header.ddspf.RBitMask = reader.ReadUInt32();
header.ddspf.GBitMask = reader.ReadUInt32();
@ -334,7 +353,7 @@ namespace Switch_Toolbox.Library
header.reserved2 = reader.ReadUInt32();
int DX10HeaderSize = 0;
if (header.ddspf.fourCC == "DX10")
if (header.ddspf.fourCC == FOURCC_DX10)
{
IsDX10 = true;
@ -342,8 +361,15 @@ namespace Switch_Toolbox.Library
ReadDX10Header(reader);
}
if (IsCompressed())
{
imageSize = ((header.width + 3) >> 2) * ((header.height + 3) >> 2) * getFormatSize(header.ddspf.fourCC);
}
else
imageSize = header.width * header.height * getFormatSize(header.ddspf.fourCC);
reader.TemporarySeek((int)(4 + header.size + DX10HeaderSize), SeekOrigin.Begin);
bdata = reader.ReadBytes((int)(reader.BaseStream.Length - reader.Position));
bdata = reader.ReadBytes((int)imageSize);
reader.Dispose();
reader.Close();
@ -398,17 +424,17 @@ namespace Switch_Toolbox.Library
case DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM_SRGB:
case DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM:
header.ddspf.flags = (uint)DDPF.FOURCC;
header.ddspf.fourCC = "DXT1";
header.ddspf.fourCC = FOURCC_DXT1;
break;
case DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM_SRGB:
case DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM:
header.ddspf.flags = (uint)DDPF.FOURCC;
header.ddspf.fourCC = "DXT3";
header.ddspf.fourCC = FOURCC_DXT3;
break;
case DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM_SRGB:
case DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM:
header.ddspf.flags = (uint)DDPF.FOURCC;
header.ddspf.fourCC = "DXT5";
header.ddspf.fourCC = FOURCC_DXT5;
break;
case DXGI_FORMAT.DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC4_SNORM:
@ -419,7 +445,7 @@ namespace Switch_Toolbox.Library
case DXGI_FORMAT.DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC7_UNORM_SRGB:
header.ddspf.flags = (uint)DDPF.FOURCC;
header.ddspf.fourCC = "DX10";
header.ddspf.fourCC = FOURCC_DX10;
if (DX10header == null)
DX10header = new DX10Header();
@ -428,9 +454,58 @@ namespace Switch_Toolbox.Library
break;
}
}
public bool IsCompressed()
{
if (header == null)
return false;
if (DX10header != null)
{
switch (DX10header.DXGI_Format)
{
case DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM_SRGB:
case DXGI_FORMAT.DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM_SRGB:
case DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM_SRGB:
case DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT.DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT.DXGI_FORMAT_BC4_SNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT.DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT.DXGI_FORMAT_BC5_SNORM:
return true;
default:
return false;
}
}
else
{
switch (header.ddspf.fourCC)
{
case FOURCC_DXT1:
case FOURCC_DXT2:
case FOURCC_DXT3:
case FOURCC_DXT4:
case FOURCC_DXT5:
case FOURCC_ATI1:
case FOURCC_BC4U:
case FOURCC_ATI2:
case FOURCC_BC5U:
return true;
default:
return false;
}
}
}
public void Save(DDS dds, string FileName, List<List<byte[]>> data = null)
{
FileWriter writer = new FileWriter(new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.Write));
var header = dds.header;
writer.Write(Encoding.ASCII.GetBytes("DDS "));
writer.Write(header.size);
writer.Write(header.flags);
@ -447,7 +522,7 @@ namespace Switch_Toolbox.Library
writer.Write(header.ddspf.size);
writer.Write(header.ddspf.flags);
writer.WriteSignature(header.ddspf.fourCC);
writer.Write(header.ddspf.fourCC);
writer.Write(header.ddspf.RGBBitCount);
writer.Write(header.ddspf.RBitMask);
writer.Write(header.ddspf.GBitMask);
@ -466,10 +541,7 @@ namespace Switch_Toolbox.Library
if (data != null)
{
foreach (byte[] mip in data[0])
{
writer.Write(mip);
}
writer.Write(data[0][0]);
}
else
{

View file

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Switch_Toolbox.Library
{
public class TextureHelper
{
public static Tuple<uint, uint> GetCurrentMipSize(uint width, uint height, uint blkHeight, uint blkWidth, uint bpp, int CurLevel)
{
uint offset = 0;
uint width_ = 0;
uint height_ = 0;
for (int mipLevel = 0; mipLevel < CurLevel; mipLevel++)
{
width_ = DIV_ROUND_UP(Math.Max(1, width >> mipLevel), blkWidth);
height_ = DIV_ROUND_UP(Math.Max(1, height >> mipLevel), blkHeight);
offset += width_ * height_ * bpp;
}
width_ = DIV_ROUND_UP(Math.Max(1, width >> CurLevel), blkWidth);
height_ = DIV_ROUND_UP(Math.Max(1, height >> CurLevel), blkHeight);
uint size = width_ * height_ * bpp;
return Tuple.Create(offset, size);
}
private static uint DIV_ROUND_UP(uint n, uint d)
{
return (n + d - 1) / d;
}
}
}

View file

@ -25,6 +25,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -140,6 +141,7 @@
<Compile Include="GUI\Viewport.Designer.cs">
<DependentUpon>Viewport.cs</DependentUpon>
</Compile>
<Compile Include="Helpers\TextureHelper.cs" />
<Compile Include="Interfaces\IMenuExtension.cs" />
<Compile Include="Plugin\GenericPluginLoader.cs" />
<Compile Include="GUI Custom\DockContentST.cs">

View file

@ -44,6 +44,11 @@ namespace Switch_Toolbox.Library
}
return rv;
}
public static byte[] SubArray(byte[] data, uint offset, uint length)
{
return data.Skip((int)offset).Take((int)length).ToArray();
}
static int i = 0;
public static string RenameDuplicateString(List<string> strings, string oldString)
{