- [Core] Fix bug where some buffers are unintentionally cached, causing undesired side effects.

This commit is contained in:
Razmoth
2024-01-25 11:20:14 +04:00
parent 5e35469435
commit 51a14820a8
9 changed files with 389 additions and 336 deletions

View File

@@ -1,6 +1,7 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using System.Buffers;
using System.IO;
namespace AssetStudio
@@ -17,7 +18,7 @@ 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(m_Texture2D.m_Width * m_Texture2D.m_Height * 4);
var buff = ArrayPool<byte>.Shared.Rent(m_Texture2D.m_Width * m_Texture2D.m_Height * 4);
try
{
if (converter.DecodeTexture2D(buff))
@@ -33,7 +34,7 @@ namespace AssetStudio
}
finally
{
BigArrayPool<byte>.Shared.Return(buff);
ArrayPool<byte>.Shared.Return(buff, true);
}
}