mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-18 03:24:15 -04:00
Add support for swizzled Switch textures
Co-Authored-By: nesrak1 <12544505+nesrak1@users.noreply.github.com>
This commit is contained in:
@ -10,19 +10,29 @@ namespace AssetStudio
|
||||
public static Image<Bgra32> ConvertToImage(this Texture2D m_Texture2D, bool flip)
|
||||
{
|
||||
var converter = new Texture2DConverter(m_Texture2D);
|
||||
var buff = BigArrayPool<byte>.Shared.Rent(converter.outPutSize);
|
||||
var uncroppedSize = converter.GetUncroppedSize();
|
||||
var buff = BigArrayPool<byte>.Shared.Rent(converter.OutputDataSize);
|
||||
try
|
||||
{
|
||||
if (converter.DecodeTexture2D(buff))
|
||||
if (!converter.DecodeTexture2D(buff))
|
||||
return null;
|
||||
|
||||
Image<Bgra32> image;
|
||||
if (converter.UsesSwitchSwizzle)
|
||||
{
|
||||
var image = Image.LoadPixelData<Bgra32>(buff, m_Texture2D.m_Width, m_Texture2D.m_Height);
|
||||
if (flip)
|
||||
{
|
||||
image.Mutate(x => x.Flip(FlipMode.Vertical));
|
||||
}
|
||||
return image;
|
||||
image = Image.LoadPixelData<Bgra32>(buff, uncroppedSize.Width, uncroppedSize.Height);
|
||||
image.Mutate(x => x.Crop(m_Texture2D.m_Width, m_Texture2D.m_Height));
|
||||
}
|
||||
return null;
|
||||
else
|
||||
{
|
||||
image = Image.LoadPixelData<Bgra32>(buff, m_Texture2D.m_Width, m_Texture2D.m_Height);
|
||||
}
|
||||
|
||||
if (flip)
|
||||
{
|
||||
image.Mutate(x => x.Flip(FlipMode.Vertical));
|
||||
}
|
||||
return image;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
Reference in New Issue
Block a user