Pārlūkot izejas kodu

Reference layer and filter fixes

Krzysztof Krysiński 7 mēneši atpakaļ
vecāks
revīzija
cd1a868b43

+ 1 - 1
src/Drawie

@@ -1 +1 @@
-Subproject commit 52a989906b7d9254fa9bab4acf172097d9d0dbef
+Subproject commit 89f1549a97d9696efda282ef865fb667930f1fc4

+ 0 - 1
src/PixiEditor.ChangeableDocument/ChangeInfos/Root/ReferenceLayerChangeInfos/SetReferenceLayer_ChangeInfo.cs

@@ -4,5 +4,4 @@ using Drawie.Numerics;
 
 namespace PixiEditor.ChangeableDocument.ChangeInfos.Structure;
 
-// TODO: Make sure Pbgra8888 is all right
 public record class SetReferenceLayer_ChangeInfo(ImmutableArray<byte> ImagePbgra8888Bytes, VecI ImageSize, ShapeCorners Shape) : IChangeInfo;

+ 1 - 1
src/PixiEditor/Models/IO/FileTypeDialogDataSet.cs

@@ -25,7 +25,7 @@ internal class FileTypeDialogDataSet
     public FileTypeDialogDataSet(SetKind kind, IEnumerable<IoFileType> fileTypes = null)
     {
         if (fileTypes == null)
-            fileTypes = SupportedFilesHelper.GetAllSupportedFileTypes(SetKind.Any);
+            fileTypes = SupportedFilesHelper.GetAllSupportedFileTypes(kind);
         var allSupportedExtensions = fileTypes;
         if (kind == SetKind.Any)
         {

+ 14 - 5
src/PixiEditor/ViewModels/SubViewModels/LayersViewModel.cs

@@ -9,6 +9,7 @@ using Avalonia.Media;
 using Avalonia.Media.Imaging;
 using Avalonia.Platform;
 using Avalonia.Platform.Storage;
+using Drawie.Backend.Core;
 using PixiEditor.ChangeableDocument;
 using PixiEditor.Helpers.Converters;
 using PixiEditor.Helpers.Extensions;
@@ -23,6 +24,7 @@ using PixiEditor.Models.Handlers;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.Layers;
 using Drawie.Numerics;
+using PixiEditor.Helpers;
 using PixiEditor.UI.Common.Fonts;
 using PixiEditor.ViewModels.Dock;
 using PixiEditor.ViewModels.Document;
@@ -394,23 +396,30 @@ internal class LayersViewModel : SubViewModel<ViewModelMain>
         if (path is null)
             return;
 
-        WriteableBitmap bitmap;
+        Surface bitmap;
         try
         {
-            bitmap = Importer.ImportWriteableBitmap(path);
+            bitmap = Surface.Load(path);
         }
         catch (RecoverableException e)
         {
             NoticeDialog.Show(title: "ERROR", message: e.DisplayMessage);
             return;
         }
+        catch(ArgumentException e)
+        {
+            NoticeDialog.Show(title: "ERROR", message: e.Message);
+            return;
+        }
 
-        byte[] pixels = bitmap.ExtractPixels();
+        byte[] bytes = bitmap.ToByteArray();
+        
+        bitmap.Dispose();
 
-        VecI size = new VecI(bitmap.PixelSize.Width, bitmap.PixelSize.Height);
+        VecI size = new VecI(bitmap.Size.X, bitmap.Size.Y);
 
         doc.Operations.ImportReferenceLayer(
-            pixels.ToImmutableArray(),
+            [..bytes],
             size);
     }
 

+ 3 - 1
src/PixiEditor/Views/Visuals/TextureControl.cs

@@ -46,10 +46,12 @@ public class TextureControl : DrawieTextureControl
         {
             args.NewValue.Value.Changed += TextureOnChanged;
         }
+        
+        QueueNextFrame();
     }
 
     private void TextureOnChanged(RectD? changedRect)
     {
-        Dispatcher.UIThread.Post(InvalidateVisual, DispatcherPriority.Render);
+        QueueNextFrame();
     }
 }