namespace Brutal.TextureApi;
public static partial class TextureWriter
{
///
/// Saves an ITexture to a file.
///
/// The ITexture to save.
/// The path to the file.
/// Thrown if the extension of filePath is not supported.
public static void SaveToFile(ITexture texture, string filePath)
{
var extension = Path.GetExtension(filePath);
if (Ktx.Loader.SupportedExtensions.Contains(extension))
{
Ktx.Writer.SaveToFile(texture, filePath);
return;
}
if (Stb.Writer.SupportedExtensions.Contains(extension))
{
Stb.Writer.SaveToFile(texture, filePath);
return;
}
if (Gli.Loader.SupportedExtensions.Contains(extension))
{
Gli.Writer.SaveToFile(texture, filePath);
return;
}
throw new NotSupportedException($"No loader found that supports file {extension}");
}
}