|
@@ -6,7 +6,6 @@ using System.Windows;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using ChunkyImageLib;
|
|
|
-using ChunkyImageLib.DataHolders;
|
|
|
using PixiEditor.ChangeableDocument.Enums;
|
|
|
using PixiEditor.DrawingApi.Core.Numerics;
|
|
|
using PixiEditor.DrawingApi.Core.Surface.ImageData;
|
|
@@ -14,6 +13,7 @@ using PixiEditor.Helpers;
|
|
|
using PixiEditor.Models.Dialogs;
|
|
|
using PixiEditor.Models.IO;
|
|
|
using PixiEditor.Parser;
|
|
|
+using PixiEditor.Parser.Deprecated;
|
|
|
using PixiEditor.ViewModels.SubViewModels.Document;
|
|
|
|
|
|
namespace PixiEditor.Models.Controllers;
|
|
@@ -138,7 +138,27 @@ internal static class ClipboardController
|
|
|
if (Path.GetExtension(path) == ".pixi")
|
|
|
{
|
|
|
using var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
|
|
|
- imported = Surface.Load(PixiParser.ReadPreview(stream));
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ imported = Surface.Load(PixiParser.Deserialize(path).PreviewImage);
|
|
|
+ }
|
|
|
+ catch (InvalidFileException e)
|
|
|
+ {
|
|
|
+ // Check if it could be a old file
|
|
|
+ if (!e.Message.StartsWith("Header"))
|
|
|
+ {
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+
|
|
|
+ stream.Position = 0;
|
|
|
+ using var bitmap = DepractedPixiParser.Deserialize(stream).RenderOldDocument();
|
|
|
+ var size = new VecI(bitmap.Width, bitmap.Height);
|
|
|
+ imported = new Surface(size);
|
|
|
+ imported.DrawBytes(size, bitmap.Bytes, ColorType.RgbaF32, AlphaType.Premul);
|
|
|
+
|
|
|
+ System.Diagnostics.Debug.Write(imported.ToString());
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|