Browse Source

Fix navigator window

Equbuxu 3 years ago
parent
commit
7712d09e2e

+ 2 - 0
PixiEditor/Models/Controllers/LayerStackRenderer.cs

@@ -31,6 +31,8 @@ namespace PixiEditor.Models.Controllers
             }
             }
         }
         }
 
 
+        public Surface FinalSurface { get => finalSurface; }
+
         public event PropertyChangedEventHandler PropertyChanged;
         public event PropertyChangedEventHandler PropertyChanged;
         public LayerStackRenderer(ObservableCollection<Layer> layers, LayerStructure structure, int width, int height)
         public LayerStackRenderer(ObservableCollection<Layer> layers, LayerStructure structure, int width, int height)
         {
         {

+ 3 - 4
PixiEditor/Models/DataHolders/Document/Document.Layers.cs

@@ -1,10 +1,10 @@
 using PixiEditor.Helpers;
 using PixiEditor.Helpers;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
-using PixiEditor.Models.ImageManipulation;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Undo;
 using PixiEditor.Models.Undo;
+using SkiaSharp;
 using System;
 using System;
 using System.Buffers;
 using System.Buffers;
 using System.Collections.Generic;
 using System.Collections.Generic;
@@ -12,7 +12,6 @@ using System.Collections.ObjectModel;
 using System.Linq;
 using System.Linq;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 using System.Windows;
 using System.Windows;
-using System.Windows.Media;
 
 
 namespace PixiEditor.Models.DataHolders
 namespace PixiEditor.Models.DataHolders
 {
 {
@@ -517,9 +516,9 @@ namespace PixiEditor.Models.DataHolders
             return layer;
             return layer;
         }
         }
 
 
-        public Color GetColorAtPoint(int x, int y)
+        public SKColor GetColorAtPoint(int x, int y)
         {
         {
-            return BitmapUtils.GetColorAtPointCombined(x, y, Layers.ToArray());
+            return Renderer.FinalSurface.GetSRGBPixel(x, y);
         }
         }
 
 
         private void BuildLayerStructureProcess(object[] parameters)
         private void BuildLayerStructureProcess(object[] parameters)

+ 0 - 15
PixiEditor/Models/ImageManipulation/BitmapUtils.cs

@@ -39,21 +39,6 @@ namespace PixiEditor.Models.ImageManipulation
             return finalSurface;
             return finalSurface;
         }
         }
 
 
-        public static Color GetColorAtPointCombined(int x, int y, params Layer[] layers)
-        {
-            Color prevColor = Color.FromArgb(0, 0, 0, 0);
-            /*
-            for (int i = 0; i < layers.Length; i++)
-            {
-                Color color = layers[i].GetPixelWithOffset(x, y);
-                float layerOpacity = layers[i].Opacity;
-
-                prevColor = BlendColor(prevColor, color, layerOpacity);
-            }*/
-
-            return prevColor;
-        }
-
         /// <summary>
         /// <summary>
         /// Generates simplified preview from Document, very fast, great for creating small previews. Creates uniform streched image.
         /// Generates simplified preview from Document, very fast, great for creating small previews. Creates uniform streched image.
         /// </summary>
         /// </summary>

+ 4 - 2
PixiEditor/Views/UserControls/PreviewWindow.xaml

@@ -26,7 +26,7 @@
               Visibility="{Binding Document, Converter={StaticResource NullToVisibilityConverter}, ElementName=uc}"
               Visibility="{Binding Document, Converter={StaticResource NullToVisibilityConverter}, ElementName=uc}"
               Height="{Binding Document.Height, ElementName=uc}" Width="{Binding Document.Width, ElementName=uc}"
               Height="{Binding Document.Height, ElementName=uc}" Width="{Binding Document.Width, ElementName=uc}"
               Background="{Binding ActiveItem.Value, ElementName=backgroundButton}" d:Width="8" d:Height="8">
               Background="{Binding ActiveItem.Value, ElementName=backgroundButton}" d:Width="8" d:Height="8">
-                <ItemsControl ItemsSource="{Binding Document.Layers, ElementName=uc}">
+                <!--<ItemsControl ItemsSource="{Binding Document.Layers, ElementName=uc}">
                     <ItemsControl.ItemsPanel>
                     <ItemsControl.ItemsPanel>
                         <ItemsPanelTemplate>
                         <ItemsPanelTemplate>
                             <Grid/>
                             <Grid/>
@@ -52,7 +52,9 @@
                             </Image>
                             </Image>
                         </DataTemplate>
                         </DataTemplate>
                     </ItemsControl.ItemTemplate>
                     </ItemsControl.ItemTemplate>
-                </ItemsControl>
+                </ItemsControl>-->
+                <Image VerticalAlignment="Top" HorizontalAlignment="Left" Source="{Binding Document.Renderer.FinalBitmap, ElementName=uc}"
+                                               RenderOptions.BitmapScalingMode="NearestNeighbor" Stretch="Uniform" />
                 <Border x:Name="colorCursor" Width="1" Height="1"
                 <Border x:Name="colorCursor" Width="1" Height="1"
                     Margin="{Binding ColorCursorPosition, ElementName=uc}"
                     Margin="{Binding ColorCursorPosition, ElementName=uc}"
                     HorizontalAlignment="Left" VerticalAlignment="Top"
                     HorizontalAlignment="Left" VerticalAlignment="Top"

+ 2 - 3
PixiEditor/Views/UserControls/PreviewWindow.xaml.cs

@@ -1,7 +1,5 @@
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.ImageManipulation;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels;
-using System.Linq;
 using System.Windows;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Input;
@@ -136,7 +134,8 @@ namespace PixiEditor.Views.UserControls
 
 
             ColorCursorPosition = newPos;
             ColorCursorPosition = newPos;
 
 
-            ColorCursorColor = BitmapUtils.GetColorAtPointCombined(x, y, Document.Layers.ToArray());
+            var color = Document.GetColorAtPoint(x, y);
+            ColorCursorColor = Color.FromArgb(color.Alpha, color.Red, color.Green, color.Blue);
         }
         }
     }
     }
 }
 }