Skip to content

Commit

Permalink
Update ImageSharp to 3.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DrSmugleaf committed Mar 7, 2024
1 parent 669e9f1 commit a7a18c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 7 additions & 13 deletions Editor/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
using SpaceWizards.RsiLib.DMI.Metadata;
using SpaceWizards.RsiLib.RSI;
using ReactiveUI;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
using Splat;
using Image = SixLabors.ImageSharp.Image;
Expand All @@ -32,8 +30,6 @@ public class MainWindowViewModel : ViewModelBase
{
private const string StatesClipboard = "RSIEdit_States";

private static readonly GifDecoder GifDecoder = new();
private static readonly PngDecoder PngDecoder = new();
private static readonly HttpClient Http = new();

private static readonly ImmutableArray<string> ValidDownloadHosts =
Expand Down Expand Up @@ -748,26 +744,24 @@ private async void SaveRsiAs(RsiItemViewModel rsi)
Rsi? rsi = null;
try
{
var image = Image.Load<Rgba32>(filePath);
rsi = new Rsi(x: image.Width, y: image.Height);
var state = new RsiState();

if (filePath.EndsWith(".gif"))
{
var image = Image.Load<Rgba32>(filePath, GifDecoder);
rsi = new Rsi(x: image.Width, y: image.Height);
var state = new RsiState();
state.LoadGif(image);
rsi.States.Add(state);
}
else if (filePath.EndsWith(".png"))
{
var image = Image.Load<Rgba32>(filePath, PngDecoder);
rsi = new Rsi(x: image.Width, y: image.Height);
var state = new RsiState();
state.LoadImage(image, rsi.Size);
rsi.States.Add(state);
}
else
{
throw new InvalidOperationException($"Invalid file type specified!");
}

rsi.States.Add(state);
}
catch (Exception e)
{
Expand Down Expand Up @@ -795,7 +789,7 @@ private async void SaveRsiAs(RsiItemViewModel rsi)
try
{
stream.Seek(0, SeekOrigin.Begin);
var dmi = Image.Load<Rgba32>(stream, PngDecoder);
var dmi = Image.Load<Rgba32>(stream);
return metadata.ToRsi(dmi);
}
catch (Exception e)
Expand Down
2 changes: 1 addition & 1 deletion RSI.NET

0 comments on commit a7a18c6

Please sign in to comment.