移除不受支持的图像格式
This commit is contained in:
@@ -18,7 +18,23 @@ namespace Spine.Exporters
|
|||||||
public FrameExporter(uint width = 100, uint height = 100) : base(width, height) { }
|
public FrameExporter(uint width = 100, uint height = 100) : base(width, height) { }
|
||||||
public FrameExporter(Vector2u resolution) : base(resolution) { }
|
public FrameExporter(Vector2u resolution) : base(resolution) { }
|
||||||
|
|
||||||
public SKEncodedImageFormat Format { get => _format; set => _format = value; }
|
public SKEncodedImageFormat Format
|
||||||
|
{
|
||||||
|
get => _format;
|
||||||
|
set {
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case SKEncodedImageFormat.Jpeg:
|
||||||
|
case SKEncodedImageFormat.Png:
|
||||||
|
case SKEncodedImageFormat.Webp:
|
||||||
|
_format = value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_logger.Warn("Omit unsupported exporter format: {0}", value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
protected SKEncodedImageFormat _format = SKEncodedImageFormat.Png;
|
protected SKEncodedImageFormat _format = SKEncodedImageFormat.Png;
|
||||||
|
|
||||||
public int Quality { get => _quality; set => _quality = Math.Clamp(value, 0, 100); }
|
public int Quality { get => _quality; set => _quality = Math.Clamp(value, 0, 100); }
|
||||||
@@ -33,5 +49,16 @@ namespace Spine.Exporters
|
|||||||
using var stream = File.OpenWrite(output);
|
using var stream = File.OpenWrite(output);
|
||||||
data.SaveTo(stream);
|
data.SaveTo(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取画面数据, 正常像素, 非预乘
|
||||||
|
/// </summary>
|
||||||
|
public SKData Export(params SpineObject[] spines)
|
||||||
|
{
|
||||||
|
using var frame = GetFrame(spines);
|
||||||
|
var info = new SKImageInfo(frame.Width, frame.Height, SKColorType.Rgba8888, SKAlphaType.Premul);
|
||||||
|
using var skImage = SKImage.FromPixelCopy(info, frame.Image.Pixels);
|
||||||
|
return skImage.Encode(SKEncodedImageFormat.Png, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ namespace SpineViewer.ViewModels.Exporters
|
|||||||
{
|
{
|
||||||
public class FrameExporterViewModel(MainWindowViewModel vmMain) : BaseExporterViewModel(vmMain)
|
public class FrameExporterViewModel(MainWindowViewModel vmMain) : BaseExporterViewModel(vmMain)
|
||||||
{
|
{
|
||||||
public static ImmutableArray<SKEncodedImageFormat> FrameFormatOptions { get; } = Enum.GetValues<SKEncodedImageFormat>().ToImmutableArray();
|
public static ImmutableArray<SKEncodedImageFormat> FrameFormatOptions { get; } = [
|
||||||
|
SKEncodedImageFormat.Png,
|
||||||
|
SKEncodedImageFormat.Webp,
|
||||||
|
SKEncodedImageFormat.Jpeg,
|
||||||
|
];
|
||||||
|
|
||||||
public SKEncodedImageFormat Format { get => _format; set => SetProperty(ref _format, value); }
|
public SKEncodedImageFormat Format { get => _format; set => SetProperty(ref _format, value); }
|
||||||
protected SKEncodedImageFormat _format = SKEncodedImageFormat.Png;
|
protected SKEncodedImageFormat _format = SKEncodedImageFormat.Png;
|
||||||
|
|||||||
Reference in New Issue
Block a user