Files
AssetStudio/AssetStudioUtility/Texture2DExtensions.cs
T
VaDiM 61d9bc8f15 Add option to export images in "assetName@hash" name format
- Redesigned spriteHelper & texture2DConverter
- Improved speed of texture2D preview a bit
2026-03-13 13:27:47 +03:00

27 lines
815 B
C#

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using System.IO;
namespace AssetStudio
{
public static class Texture2DExtensions
{
public static bool TryConvertToImage(this Texture2D m_Texture2D, bool flip, out Image<Bgra32> image)
{
return new Texture2DConverter(m_Texture2D).TryConvertToBgra32Image(flip, out image);
}
public static MemoryStream ConvertToStream(this Texture2D m_Texture2D, ImageFormat imageFormat, bool flip)
{
var converter = new Texture2DConverter(m_Texture2D);
if (!converter.TryConvertToBgra32Image(flip, out var image))
return null;
using (image)
{
return image.ConvertToStream(imageFormat);
}
}
}
}