Performance improvement

This commit is contained in:
Perfare
2021-12-06 13:36:22 +08:00
parent 88c5804586
commit 80653711cd
13 changed files with 369 additions and 888 deletions

View File

@ -17,12 +17,15 @@ namespace AssetStudioGUI
var type = Properties.Settings.Default.convertType;
if (!TryExportFile(exportPath, item, "." + type.ToString().ToLower(), out var exportFullPath))
return false;
var stream = m_Texture2D.ConvertToStream(type, true);
if (stream == null)
var image = m_Texture2D.ConvertToImage(true);
if (image == null)
return false;
using (stream)
using (image)
{
File.WriteAllBytes(exportFullPath, stream.ToArray());
using (var file = File.OpenWrite(exportFullPath))
{
image.WriteToStream(file, type);
}
return true;
}
}
@ -229,12 +232,15 @@ namespace AssetStudioGUI
var type = Properties.Settings.Default.convertType;
if (!TryExportFile(exportPath, item, "." + type.ToString().ToLower(), out var exportFullPath))
return false;
var stream = ((Sprite)item.Asset).GetImage(type);
if (stream != null)
var image = ((Sprite)item.Asset).GetImage();
if (image != null)
{
using (stream)
using (image)
{
File.WriteAllBytes(exportFullPath, stream.ToArray());
using (var file = File.OpenWrite(exportFullPath))
{
image.WriteToStream(file, type);
}
return true;
}
}