mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 20:43:09 +00:00
NUTEXB : Automatically pad smaller image sizes if restrictions are used
This commit is contained in:
parent
1cf45c4f5a
commit
4ff5e83ba3
1 changed files with 16 additions and 7 deletions
|
@ -277,14 +277,17 @@ namespace FirstPlugin
|
|||
|
||||
if (LimitFileSize)
|
||||
{
|
||||
if (surfaces[0].mipmaps[0].Length != surfacesNew[0].mipmaps[0].Length)
|
||||
throw new Exception($"Image must be the same size! {surfaces[0].mipmaps[0].Length}");
|
||||
if (surfaces[0].mipmaps[0].Length > surfacesNew[0].mipmaps[0].Length)
|
||||
{
|
||||
if (surfaces[0].mipmaps[0].Length != surfacesNew[0].mipmaps[0].Length)
|
||||
throw new Exception($"Image must be the same size! {surfaces[0].mipmaps[0].Length}");
|
||||
|
||||
if (mipSizes[0].Length != surfacesNew[0].mipmaps.Count)
|
||||
throw new Exception($"Mip map count must be the same! {mipSizes[0].Length}");
|
||||
if (mipSizes[0].Length != surfacesNew[0].mipmaps.Count)
|
||||
throw new Exception($"Mip map count must be the same! {mipSizes[0].Length}");
|
||||
|
||||
if (Width != tex.Texture.Width || Height != tex.Texture.Height)
|
||||
throw new Exception("Image size must be the same!");
|
||||
if (Width != tex.Texture.Width || Height != tex.Texture.Height)
|
||||
throw new Exception("Image size must be the same!");
|
||||
}
|
||||
|
||||
Width = tex.Texture.Width;
|
||||
Height = tex.Texture.Height;
|
||||
|
@ -308,7 +311,13 @@ namespace FirstPlugin
|
|||
foreach (var array in tex.Texture.TextureData)
|
||||
data.Add(array[0]);
|
||||
|
||||
ImageData = Utils.CombineByteArray(data.ToArray());
|
||||
var output = Utils.CombineByteArray(data.ToArray());
|
||||
if (output.Length < ImageData.Length) {
|
||||
var paddingSize = ImageData.Length - output.Length;
|
||||
output = Utils.CombineByteArray(ImageData, new byte[paddingSize]);
|
||||
}
|
||||
|
||||
ImageData = output;
|
||||
|
||||
data.Clear();
|
||||
surfacesNew.Clear();
|
||||
|
|
Loading…
Reference in a new issue