mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 04:58:24 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
1 changed files with 784842 additions and 0 deletions
34
Brutal.Texture/TextureWriter.cs
Normal file
34
Brutal.Texture/TextureWriter.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
namespace Brutal.TextureApi;
|
||||
|
||||
public static partial class TextureWriter
|
||||
{
|
||||
/// <summary>
|
||||
/// Saves an ITexture to a file.
|
||||
/// </summary>
|
||||
/// <param name="texture">The ITexture to save.</param>
|
||||
/// <param name="filePath">The path to the file.</param>
|
||||
/// <exception cref="NotSupportedException">Thrown if the extension of filePath is not supported.</exception>
|
||||
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}");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue