using System.Collections; using System.Collections.Generic; using Godot; using System; namespace Rokojori { public static class Textures { public static void Save( Texture2D texture, string path, float quality = 0.75f ) { var image = texture.GetImage(); Save( image, path ); } public static void Save( Image image, string path, float quality = 0.75f ) { var fp = FilePath.Absolute( path ); var output = ".png"; if ( fp.hasFileExtension( ".jpg" ) || fp.hasFileExtension( ".exr" ) || fp.hasFileExtension( ".webp" ) ) { output = fp.fileExtension; } switch ( output ) { case ".jpg": { image.SaveJpg( path, quality ); } break; case ".png": { image.SavePng( path ); } break; case ".webp": { image.SaveWebp( path, quality < 1, quality ); } break; case ".exr": { image.SaveExr( path ); } break; } } } }