freeso/TSOClient/FSO.Server/Utils/CoreImageLoader.cs
riperiperi b57ebbd141 Cleanup: Remove most unused usings and MPL per-file licenses
MPL per-file was used in older project files, but should apply to the whole project, so having it there was redundant.
2023-11-25 03:45:29 +00:00

35 lines
869 B
C#

using FSO.Content.Model;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using System;
using System.IO;
namespace FSO.Server.Utils
{
public class CoreImageLoader
{
public static TexBitmap SoftImageFetch(Stream stream, AbstractTextureRef texRef)
{
Image<Rgba32> result = null;
try
{
result = Image.Load(stream);
}
catch (Exception)
{
return new TexBitmap() { Data = new byte[0] };
}
stream.Close();
if (result == null) return null;
return new TexBitmap
{
Data = result.SavePixelData(),
Width = result.Width,
Height = result.Height,
PixelSize = 4
};
}
}
}