timelapsenow/TimelapseApi/ClassExtensions.cs

31 lines
761 B
C#
Raw Permalink Normal View History

2022-05-20 02:06:35 +00:00
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
namespace TimelapseApi.ClassExtensions;
public static class Extensions
{
public static async Task AddAsync(this VideoFileCreator video, Image<Rgb24> img)
{
using(var ms = new MemoryStream())
{
img.SaveAsPng(ms);
byte[] data =ms.ToArray();
await video.AddAsync(data);
}
}
public static void Add(this VideoFileCreator video,Image<Rgb24> img)
{
using(var ms = new MemoryStream())
{
img.SaveAsPng(ms);
byte[] data =ms.ToArray();
video.Add(data);
}
}
}