Browse Source

Fixed recently opened preview bitmap and upgraded skia+avalonia

Krzysztof Krysiński 1 year ago
parent
commit
258922cdc9

+ 1 - 1
src/Directory.Build.props

@@ -1,7 +1,7 @@
 <Project>
     <PropertyGroup>
         <CodeAnalysisRuleSet>../Custom.ruleset</CodeAnalysisRuleSet>
-		<AvaloniaVersion>11.0.5</AvaloniaVersion>
+		<AvaloniaVersion>11.0.6</AvaloniaVersion>
     </PropertyGroup>
     <ItemGroup>
         <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />

+ 7 - 3
src/PixiEditor.AvaloniaUI/Models/IO/Importer.cs

@@ -43,12 +43,11 @@ internal class Importer : ObservableObject
         return resized;
     }
 
-    public static WriteableBitmap ImportWriteableBitmap(string path)
+    public static Bitmap ImportBitmap(string path)
     {
         try
         {
-            Uri uri = new Uri(path, UriKind.RelativeOrAbsolute);
-            return new Bitmap(path).ToWriteableBitmap();
+            return new Bitmap(path);
         }
         catch (NotSupportedException e)
         {
@@ -64,6 +63,11 @@ internal class Importer : ObservableObject
         }
     }
 
+    public static WriteableBitmap ImportWriteableBitmap(string path)
+    {
+        return ImportBitmap(path).ToWriteableBitmap();
+    }
+
     public static DocumentViewModel ImportDocument(string path, bool associatePath = true)
     {
         try

+ 7 - 7
src/PixiEditor.AvaloniaUI/Models/UserData/RecentlyOpenedDocument.cs

@@ -6,6 +6,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
 using PixiEditor.AvaloniaUI.Exceptions;
 using PixiEditor.AvaloniaUI.Helpers;
 using PixiEditor.AvaloniaUI.Helpers.Extensions;
+using PixiEditor.AvaloniaUI.Models.IO;
 using PixiEditor.Parser;
 using PixiEditor.Parser.Deprecated;
 
@@ -18,7 +19,7 @@ internal class RecentlyOpenedDocument : ObservableObject
 
     private string filePath;
 
-    private WriteableBitmap previewBitmap;
+    private Bitmap previewBitmap;
 
     public string FilePath
     {
@@ -59,7 +60,7 @@ internal class RecentlyOpenedDocument : ObservableObject
         }
     }
 
-    public WriteableBitmap PreviewBitmap
+    public Bitmap PreviewBitmap
     {
         get
         {
@@ -78,7 +79,7 @@ internal class RecentlyOpenedDocument : ObservableObject
         FilePath = path;
     }
 
-    private WriteableBitmap LoadPreviewBitmap()
+    private Bitmap LoadPreviewBitmap()
     {
         if (!File.Exists(FilePath))
         {
@@ -128,12 +129,11 @@ internal class RecentlyOpenedDocument : ObservableObject
 
         if (SupportedFilesHelper.IsExtensionSupported(FileExtension))
         {
-            WriteableBitmap bitmap = null;
+            Bitmap bitmap = null;
 
             try
             {
-                //TODO: Fix this
-                //bitmap = Importer.ImportWriteableBitmap(FilePath);
+                bitmap = Importer.ImportBitmap(FilePath);
             }
             catch (RecoverableException)
             {
@@ -150,7 +150,7 @@ internal class RecentlyOpenedDocument : ObservableObject
         return null;
     }
 
-    private WriteableBitmap DownscaleToMaxSize(WriteableBitmap bitmap)
+    private Bitmap DownscaleToMaxSize(Bitmap bitmap)
     {
         if (bitmap.PixelSize.Width > Constants.MaxPreviewWidth || bitmap.PixelSize.Height > Constants.MaxPreviewHeight)
         {

+ 1 - 1
src/PixiEditor.DrawingApi.Skia/PixiEditor.DrawingApi.Skia.csproj

@@ -61,7 +61,7 @@
     </PropertyGroup>
 
     <ItemGroup>
-      <PackageReference Include="SkiaSharp" Version="2.80.3" />
+      <PackageReference Include="SkiaSharp" Version="2.88.6" />
     </ItemGroup>
 
     <ItemGroup>