调整文件夹结构
This commit is contained in:
42
SpineViewer/ExportHelper/ExportHelper.cs
Normal file
42
SpineViewer/ExportHelper/ExportHelper.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using FFMpegCore.Pipes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SpineViewer.ExportHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 为帧导出创建的辅助类
|
||||||
|
/// </summary>
|
||||||
|
public static class ExportHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 从纹理对象获取 Winforms Bitmap 对象
|
||||||
|
/// </summary>
|
||||||
|
public static Bitmap CopyToBitmap(this SFML.Graphics.Texture tex)
|
||||||
|
{
|
||||||
|
using var img = tex.CopyToImage();
|
||||||
|
img.SaveToMemory(out var imgBuffer, "bmp");
|
||||||
|
using var stream = new MemoryStream(imgBuffer);
|
||||||
|
return new Bitmap(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从纹理获取适合 FFMpegCore 的帧对象
|
||||||
|
/// </summary>
|
||||||
|
public static SFMLImageVideoFrame CopyToFrame(this SFML.Graphics.Texture tex) => new(tex.CopyToImage());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据文件格式获取合适的文件后缀
|
||||||
|
/// </summary>
|
||||||
|
public static string GetSuffix(this ImageFormat imageFormat)
|
||||||
|
{
|
||||||
|
if (imageFormat == ImageFormat.Icon) return ".ico";
|
||||||
|
else if (imageFormat == ImageFormat.Exif) return ".jpg";
|
||||||
|
else return $".{imageFormat.ToString().ToLower()}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
using FFMpegCore.Pipes;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing.Imaging;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
using FFMpegCore.Pipes;
|
||||||
|
|
||||||
namespace SpineViewer
|
namespace SpineViewer.ExportHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SFML.Graphics.Image 帧对象包装类
|
/// SFML.Graphics.Image 帧对象包装类
|
||||||
@@ -38,27 +36,4 @@ namespace SpineViewer
|
|||||||
/// <returns>True if saving was successful</returns>
|
/// <returns>True if saving was successful</returns>
|
||||||
public bool SaveToMemory(out byte[] output, string format) => image.SaveToMemory(out output, format);
|
public bool SaveToMemory(out byte[] output, string format) => image.SaveToMemory(out output, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 为帧导出创建的辅助类
|
|
||||||
/// </summary>
|
|
||||||
public static class ExportHelper
|
|
||||||
{
|
|
||||||
public static Bitmap CopyToBitmap(this SFML.Graphics.Texture tex)
|
|
||||||
{
|
|
||||||
using var img = tex.CopyToImage();
|
|
||||||
img.SaveToMemory(out var imgBuffer, "bmp");
|
|
||||||
using var stream = new MemoryStream(imgBuffer);
|
|
||||||
return new Bitmap(stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SFMLImageVideoFrame CopyToFrame(this SFML.Graphics.Texture tex) => new(tex.CopyToImage());
|
|
||||||
|
|
||||||
public static string GetSuffix(this ImageFormat imageFormat)
|
|
||||||
{
|
|
||||||
if (imageFormat == ImageFormat.Icon) return ".ico";
|
|
||||||
else if (imageFormat == ImageFormat.Exif) return ".jpg";
|
|
||||||
else return $".{imageFormat.ToString().ToLower()}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user