Browse Source

Fixed some tests

flabbet 3 years ago
parent
commit
15c1d168c2

+ 1 - 1
PixiEditor/Models/DataHolders/RecentlyOpenedDocument.cs

@@ -54,7 +54,7 @@ namespace PixiEditor.Models.DataHolders
         {
         {
             get
             get
             {
             {
-                if (previewBitmap == null)
+                if (previewBitmap == null && !Corrupt)
                 {
                 {
                     PreviewBitmap = LoadPreviewBitmap();
                     PreviewBitmap = LoadPreviewBitmap();
                 }
                 }

+ 2 - 1
PixiEditor/Models/ImageManipulation/BitmapUtils.cs

@@ -76,7 +76,8 @@ namespace PixiEditor.Models.ImageManipulation
 
 
         public static WriteableBitmap GeneratePreviewBitmap(IEnumerable<SerializableLayer> layers, int width, int height, int maxPreviewWidth, int maxPreviewHeight)
         public static WriteableBitmap GeneratePreviewBitmap(IEnumerable<SerializableLayer> layers, int width, int height, int maxPreviewWidth, int maxPreviewHeight)
         {
         {
-            var opacityLayers = layers.Where(x => x.IsVisible && x.Opacity > 0.8f);
+            var opacityLayers = layers.Where(x => x.IsVisible && x.Opacity > 0.8f 
+            && x.Height > 0 && x.Width > 0);
 
 
             return GeneratePreviewBitmap(
             return GeneratePreviewBitmap(
                 opacityLayers.Select(x => new Surface(x.Width, x.Height, x.BitmapBytes)),
                 opacityLayers.Select(x => new Surface(x.Width, x.Height, x.BitmapBytes)),

+ 19 - 9
PixiEditorTests/ModelsTests/ColorsTests/ExtendedColorTests.cs

@@ -1,26 +1,36 @@
 using System;
 using System;
 using System.Windows.Media;
 using System.Windows.Media;
 using PixiEditor.Models.Colors;
 using PixiEditor.Models.Colors;
+using SkiaSharp;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.ColorsTests
 namespace PixiEditorTests.ModelsTests.ColorsTests
 {
 {
     public class ExtendedColorTests
     public class ExtendedColorTests
     {
     {
-        private const int AcceptableMaringOfError = 1;
+
+        public static readonly SKColor white = new SKColor(255, 255, 255);
+        public static readonly SKColor black = new SKColor(0, 0, 0);
+        public static readonly SKColor transparent = new SKColor(0, 0, 0, 0);
+        public static readonly SKColor red = new SKColor(255, 0, 0);
+        public static readonly SKColor green = new SKColor(0, 255, 0);
+        public static readonly SKColor blue = new SKColor(0, 0, 255);
+
+        private const int AcceptableMaringOfError = 1;
+
 
 
         [Fact]
         [Fact]
         public void ChangeColorBrightnessIsNotTheSameTest()
         public void ChangeColorBrightnessIsNotTheSameTest()
         {
         {
-            Color newColor = ExColor.ChangeColorBrightness(Colors.White, -1);
-            Assert.NotEqual(Colors.White, newColor);
+            SKColor newColor = ExColor.ChangeColorBrightness(white, -1);
+            Assert.NotEqual(white, newColor);
         }
         }
 
 
         [Fact]
         [Fact]
         public void ChangeColorBrightnessNewValueTest()
         public void ChangeColorBrightnessNewValueTest()
         {
         {
-            Color newColor = ExColor.ChangeColorBrightness(Colors.White, -100);
-            Assert.Equal(Colors.Black, newColor);
+            SKColor newColor = ExColor.ChangeColorBrightness(white, -100);
+            Assert.Equal(black, newColor);
         }
         }
 
 
         // Acceptable margin of error is 1
         // Acceptable margin of error is 1
@@ -49,10 +59,10 @@ namespace PixiEditorTests.ModelsTests.ColorsTests
         [InlineData(271, 75.9f, 52.7f, 137, 43, 226)]
         [InlineData(271, 75.9f, 52.7f, 137, 43, 226)]
         public void HslToRgbTest(int h, float s, float l, int r, int g, int b)
         public void HslToRgbTest(int h, float s, float l, int r, int g, int b)
         {
         {
-            Color rgb = ExColor.HslToRgb(h, s, l);
-            int marginOfErrorR = Math.Abs(rgb.R - r);
-            int marginOfErrorG = Math.Abs(rgb.G - g);
-            int marginOfErrorB = Math.Abs(rgb.B - b);
+            SKColor rgb = ExColor.HslToRgb(h, s, l);
+            int marginOfErrorR = Math.Abs(rgb.Red - r);
+            int marginOfErrorG = Math.Abs(rgb.Green - g);
+            int marginOfErrorB = Math.Abs(rgb.Blue - b);
             Assert.True(marginOfErrorR <= AcceptableMaringOfError);
             Assert.True(marginOfErrorR <= AcceptableMaringOfError);
             Assert.True(marginOfErrorG <= AcceptableMaringOfError);
             Assert.True(marginOfErrorG <= AcceptableMaringOfError);
             Assert.True(marginOfErrorB <= AcceptableMaringOfError);
             Assert.True(marginOfErrorB <= AcceptableMaringOfError);

+ 3 - 2
PixiEditorTests/ModelsTests/ControllersTests/BitmapManagerTests.cs

@@ -4,6 +4,7 @@ using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Undo;
 using PixiEditor.Models.Undo;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.ControllersTests
 namespace PixiEditorTests.ModelsTests.ControllersTests
@@ -83,7 +84,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
 
             bitmapManager.ActiveDocument.AddNewLayer("Layer");
             bitmapManager.ActiveDocument.AddNewLayer("Layer");
             bitmapManager.SetActiveTool(new MockedSinglePixelPenTool());
             bitmapManager.SetActiveTool(new MockedSinglePixelPenTool());
-            bitmapManager.PrimaryColor = Colors.Green;
+            bitmapManager.PrimaryColor = ExtendedColorTests.black;
 
 
             bitmapManager.MouseController.StartRecordingMouseMovementChanges(true);
             bitmapManager.MouseController.StartRecordingMouseMovementChanges(true);
             bitmapManager.MouseController.RecordMouseMovementChange(new Coordinates(1, 1));
             bitmapManager.MouseController.RecordMouseMovementChange(new Coordinates(1, 1));
@@ -91,7 +92,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
 
             bitmapManager.ExecuteTool(new Coordinates(1, 1), true);
             bitmapManager.ExecuteTool(new Coordinates(1, 1), true);
 
 
-            Assert.Equal(Colors.Green, bitmapManager.ActiveLayer.GetPixelWithOffset(1, 1));
+            Assert.Equal(ExtendedColorTests.black, bitmapManager.ActiveLayer.GetPixelWithOffset(1, 1));
         }
         }
     }
     }
 }
 }

+ 6 - 5
PixiEditorTests/ModelsTests/ControllersTests/BitmapOperationsUtilityTests.cs

@@ -4,6 +4,7 @@ using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.ControllersTests
 namespace PixiEditorTests.ModelsTests.ControllersTests
@@ -18,13 +19,13 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
 
             Layer testLayer = new Layer("test layer", 10, 10);
             Layer testLayer = new Layer("test layer", 10, 10);
             Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };
             Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };
-            BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(cords, Colors.Black);
+            BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.black);
             testLayer.SetPixels(pixels);
             testLayer.SetPixels(pixels);
 
 
             util.DeletePixels(new[] { testLayer }, cords);
             util.DeletePixels(new[] { testLayer }, cords);
 
 
-            Assert.Equal(0, testLayer.GetPixel(0, 0).A);
-            Assert.Equal(0, testLayer.GetPixel(1, 1).A);
+            Assert.Equal(0, testLayer.GetPixel(0, 0).Alpha);
+            Assert.Equal(0, testLayer.GetPixel(1, 1).Alpha);
         }
         }
 
 
         [StaFact]
         [StaFact]
@@ -33,7 +34,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
             BitmapManager manager = new BitmapManager
             BitmapManager manager = new BitmapManager
             {
             {
                 ActiveDocument = new Document(10, 10),
                 ActiveDocument = new Document(10, 10),
-                PrimaryColor = Colors.Black
+                PrimaryColor = ExtendedColorTests.black
             };
             };
             manager.ActiveDocument.AddNewLayer("Test layer", 10, 10);
             manager.ActiveDocument.AddNewLayer("Test layer", 10, 10);
 
 
@@ -42,7 +43,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
             List<Coordinates> mouseMove = new List<Coordinates>(new[] { new Coordinates(0, 0) });
             List<Coordinates> mouseMove = new List<Coordinates>(new[] { new Coordinates(0, 0) });
 
 
             util.ExecuteTool(new Coordinates(0, 0), mouseMove, new MockedSinglePixelPenTool());
             util.ExecuteTool(new Coordinates(0, 0), mouseMove, new MockedSinglePixelPenTool());
-            Assert.Equal(manager.ActiveLayer.GetPixel(0, 0), Colors.Black);
+            Assert.Equal(manager.ActiveLayer.GetPixel(0, 0), ExtendedColorTests.black);
         }
         }
     }
     }
 }
 }

+ 22 - 20
PixiEditorTests/ModelsTests/ControllersTests/ClipboardControllerTests.cs

@@ -4,8 +4,10 @@ using System.Windows;
 using System.Windows.Media;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.Controllers;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
+using SkiaSharp;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.ControllersTests
 namespace PixiEditorTests.ModelsTests.ControllersTests
@@ -13,14 +15,14 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
     public class ClipboardControllerTests
     public class ClipboardControllerTests
     {
     {
         private const string Text = "Text data";
         private const string Text = "Text data";
-        private readonly Color testColor = Colors.Coral;
+        private readonly SKColor testColor = new SKColor(223, 20, 52);
 
 
         [StaFact]
         [StaFact]
         public void TestThatClipboardControllerIgnoresNonImageDataInClipboard()
         public void TestThatClipboardControllerIgnoresNonImageDataInClipboard()
         {
         {
             Clipboard.Clear();
             Clipboard.Clear();
             Clipboard.SetText(Text);
             Clipboard.SetText(Text);
-            WriteableBitmap img = ClipboardController.GetImageFromClipboard();
+            Surface img = ClipboardController.GetImageFromClipboard();
             Assert.Null(img);
             Assert.Null(img);
         }
         }
 
 
@@ -60,26 +62,26 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
 
             Assert.True(ClipboardController.IsImageInClipboard());
             Assert.True(ClipboardController.IsImageInClipboard());
             Assert.NotNull(img);
             Assert.NotNull(img);
-            Assert.Equal(2, img.PixelWidth);
-            Assert.Equal(2, img.PixelHeight);
+            Assert.Equal(2, img.Width);
+            Assert.Equal(2, img.Height);
 
 
-            WriteableBitmap bmp = new WriteableBitmap(img);
-            Assert.Equal(testColor, bmp.GetPixel(0, 0));
-            Assert.Equal(testColor, bmp.GetPixel(1, 1));
+            Surface bmp = new Surface(img);
+            Assert.Equal(testColor, bmp.GetSRGBPixel(0, 0));
+            Assert.Equal(testColor, bmp.GetSRGBPixel(1, 1));
         }
         }
 
 
         [StaFact]
         [StaFact]
         public void TestThatClipboardControllerGetsCorrectImageInDibFormatFromClipboard()
         public void TestThatClipboardControllerGetsCorrectImageInDibFormatFromClipboard()
         {
         {
             Clipboard.Clear();
             Clipboard.Clear();
-            WriteableBitmap bmp = BitmapFactory.New(10, 10);
-            bmp.SetPixel(4, 4, testColor);
+            using Surface bmp = new Surface(10, 10);
+            bmp.SetSRGBPixel(4, 4, testColor);
             Clipboard.SetImage(bmp);
             Clipboard.SetImage(bmp);
 
 
-            WriteableBitmap img = ClipboardController.GetImageFromClipboard();
+            Surface img = ClipboardController.GetImageFromClipboard();
             Assert.NotNull(img);
             Assert.NotNull(img);
-            Assert.Equal(10, img.PixelWidth);
-            Assert.Equal(10, img.PixelHeight);
+            Assert.Equal(10, img.Width);
+            Assert.Equal(10, img.Height);
             Assert.Equal(testColor, bmp.GetPixel(4, 4));
             Assert.Equal(testColor, bmp.GetPixel(4, 4));
         }
         }
 
 
@@ -87,7 +89,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
         public void TestThatClipboardControllerGetsCorrectImageInPngFormatFromClipboard()
         public void TestThatClipboardControllerGetsCorrectImageInPngFormatFromClipboard()
         {
         {
             Clipboard.Clear();
             Clipboard.Clear();
-            WriteableBitmap bmp = BitmapFactory.New(10, 10);
+            Surface bmp = BitmapFactory.New(10, 10);
             bmp.SetPixel(4, 4, testColor);
             bmp.SetPixel(4, 4, testColor);
             using (MemoryStream pngStream = new MemoryStream())
             using (MemoryStream pngStream = new MemoryStream())
             {
             {
@@ -100,10 +102,10 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
                 Clipboard.SetDataObject(data, true);
                 Clipboard.SetDataObject(data, true);
             }
             }
 
 
-            WriteableBitmap img = ClipboardController.GetImageFromClipboard();
+            Surface img = ClipboardController.GetImageFromClipboard();
             Assert.NotNull(img);
             Assert.NotNull(img);
-            Assert.Equal(10, img.PixelWidth);
-            Assert.Equal(10, img.PixelHeight);
+            Assert.Equal(10, img.Width);
+            Assert.Equal(10, img.Height);
             Assert.Equal(testColor, bmp.GetPixel(4, 4));
             Assert.Equal(testColor, bmp.GetPixel(4, 4));
         }
         }
 
 
@@ -111,17 +113,17 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
         public void TestThatClipboardControllerGetsCorrectImageInBitmapFormatFromClipboard()
         public void TestThatClipboardControllerGetsCorrectImageInBitmapFormatFromClipboard()
         {
         {
             Clipboard.Clear();
             Clipboard.Clear();
-            WriteableBitmap bmp = BitmapFactory.New(10, 10);
+            Surface bmp = BitmapFactory.New(10, 10);
             bmp.SetPixel(4, 4, testColor);
             bmp.SetPixel(4, 4, testColor);
 
 
             DataObject data = new DataObject();
             DataObject data = new DataObject();
             data.SetData(DataFormats.Bitmap, bmp, false); // PNG, supports transparency
             data.SetData(DataFormats.Bitmap, bmp, false); // PNG, supports transparency
             Clipboard.SetDataObject(data, true);
             Clipboard.SetDataObject(data, true);
 
 
-            WriteableBitmap img = ClipboardController.GetImageFromClipboard();
+            Surface img = ClipboardController.GetImageFromClipboard();
             Assert.NotNull(img);
             Assert.NotNull(img);
-            Assert.Equal(10, img.PixelWidth);
-            Assert.Equal(10, img.PixelHeight);
+            Assert.Equal(10, img.Width);
+            Assert.Equal(10, img.Height);
             Assert.Equal(testColor, bmp.GetPixel(4, 4));
             Assert.Equal(testColor, bmp.GetPixel(4, 4));
         }
         }
     }
     }

+ 3 - 2
PixiEditorTests/ModelsTests/ControllersTests/MockedSinglePixelPenTool.cs

@@ -4,14 +4,15 @@ using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools;
+using SkiaSharp;
 
 
 namespace PixiEditorTests.ModelsTests.ControllersTests
 namespace PixiEditorTests.ModelsTests.ControllersTests
 {
 {
     public class MockedSinglePixelPenTool : BitmapOperationTool
     public class MockedSinglePixelPenTool : BitmapOperationTool
     {
     {
         public override string Tooltip => "";
         public override string Tooltip => "";
-    
-        public override LayerChange[] Use(Layer layer, List<Coordinates> mouseMove, Color color)
+
+        public override LayerChange[] Use(Layer layer, List<Coordinates> mouseMove, SKColor color)
         {
         {
             return Only(BitmapPixelChanges.FromSingleColoredArray(new[] { mouseMove[0] }, color), layer.LayerGuid);
             return Only(BitmapPixelChanges.FromSingleColoredArray(new[] { mouseMove[0] }, color), layer.LayerGuid);
         }
         }

+ 7 - 6
PixiEditorTests/ModelsTests/ControllersTests/PixelChangesControllerTests.cs

@@ -3,6 +3,7 @@ using System.Windows.Media;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.ControllersTests
 namespace PixiEditorTests.ModelsTests.ControllersTests
@@ -29,8 +30,8 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
 
             controller.AddChanges(
             controller.AddChanges(
                 new LayerChange(
                 new LayerChange(
-                    BitmapPixelChanges.FromSingleColoredArray(cords, Colors.Black), guid),
-                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords, Colors.Transparent), guid));
+                    BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.black), guid),
+                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.transparent), guid));
 
 
             System.Tuple<LayerChange, LayerChange>[] changes = controller.PopChanges();
             System.Tuple<LayerChange, LayerChange>[] changes = controller.PopChanges();
             Assert.Equal(2, changes.Length);
             Assert.Equal(2, changes.Length);
@@ -45,8 +46,8 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
 
             controller.AddChanges(
             controller.AddChanges(
                 new LayerChange(
                 new LayerChange(
-                    BitmapPixelChanges.FromSingleColoredArray(cords2, Colors.Black), data.Item1),
-                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords2, Colors.Transparent), data.Item1));
+                    BitmapPixelChanges.FromSingleColoredArray(cords2, ExtendedColorTests.black), data.Item1),
+                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords2, ExtendedColorTests.transparent), data.Item1));
 
 
             Tuple<LayerChange, LayerChange>[] changes = controller.PopChanges();
             Tuple<LayerChange, LayerChange>[] changes = controller.PopChanges();
             Assert.Single(changes);
             Assert.Single(changes);
@@ -63,8 +64,8 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
 
             controller.AddChanges(
             controller.AddChanges(
                 new LayerChange(
                 new LayerChange(
-                    BitmapPixelChanges.FromSingleColoredArray(cords, Colors.Black), guid),
-                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords, Colors.Transparent), guid));
+                    BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.black), guid),
+                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.transparent), guid));
             return new Tuple<Guid, PixelChangesController>(guid, controller);
             return new Tuple<Guid, PixelChangesController>(guid, controller);
         }
         }
     }
     }

+ 11 - 10
PixiEditorTests/ModelsTests/DataHoldersTests/BitmapPixelChangesTests.cs

@@ -2,6 +2,8 @@
 using PixiEditor.Exceptions;
 using PixiEditor.Exceptions;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
+using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.DataHoldersTests
 namespace PixiEditorTests.ModelsTests.DataHoldersTests
@@ -11,11 +13,10 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
         [Fact]
         [Fact]
         public void TestThatFromSingleColoredArrayCreatesCorrectArray()
         public void TestThatFromSingleColoredArrayCreatesCorrectArray()
         {
         {
-            Color color = Colors.Chocolate;
             Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 0), new Coordinates(3, 2) };
             Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 0), new Coordinates(3, 2) };
-            BitmapPixelChanges bmpChanges = BitmapPixelChanges.FromSingleColoredArray(cords, color);
+            BitmapPixelChanges bmpChanges = BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.green);
 
 
-            Assert.All(bmpChanges.ChangedPixels.Values, changeColor => Assert.Equal(color, changeColor));
+            Assert.All(bmpChanges.ChangedPixels.Values, changeColor => Assert.Equal(ExtendedColorTests.green, changeColor));
             Assert.True(bmpChanges.WasBuiltAsSingleColored);
             Assert.True(bmpChanges.WasBuiltAsSingleColored);
         }
         }
 
 
@@ -24,28 +25,28 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
         {
         {
             Coordinates[] cords1 = { new Coordinates(0, 0), new Coordinates(1, 0), new Coordinates(3, 2) };
             Coordinates[] cords1 = { new Coordinates(0, 0), new Coordinates(1, 0), new Coordinates(3, 2) };
             Coordinates[] cords2 = { new Coordinates(3, 2), new Coordinates(0, 0), new Coordinates(5, 5) };
             Coordinates[] cords2 = { new Coordinates(3, 2), new Coordinates(0, 0), new Coordinates(5, 5) };
-            BitmapPixelChanges changes = BitmapPixelChanges.FromSingleColoredArray(cords1, Colors.Green);
-            BitmapPixelChanges changes2 = BitmapPixelChanges.FromSingleColoredArray(cords2, Colors.Red);
+            BitmapPixelChanges changes = BitmapPixelChanges.FromSingleColoredArray(cords1, ExtendedColorTests.green);
+            BitmapPixelChanges changes2 = BitmapPixelChanges.FromSingleColoredArray(cords2, ExtendedColorTests.red);
 
 
             BitmapPixelChanges output = BitmapPixelChanges.CombineOverride(new[] { changes, changes2 });
             BitmapPixelChanges output = BitmapPixelChanges.CombineOverride(new[] { changes, changes2 });
             Assert.Equal(4, output.ChangedPixels.Count);
             Assert.Equal(4, output.ChangedPixels.Count);
-            Assert.Equal(Colors.Red, output.ChangedPixels[new Coordinates(3, 2)]);
-            Assert.Equal(Colors.Red, output.ChangedPixels[new Coordinates(0, 0)]);
-            Assert.Equal(Colors.Green, output.ChangedPixels[new Coordinates(1, 0)]);
+            Assert.Equal(ExtendedColorTests.red, output.ChangedPixels[new Coordinates(3, 2)]);
+            Assert.Equal(ExtendedColorTests.black, output.ChangedPixels[new Coordinates(0, 0)]);
+            Assert.Equal(ExtendedColorTests.green, output.ChangedPixels[new Coordinates(1, 0)]);
         }
         }
 
 
         [Fact]
         [Fact]
         public void TestThatFromArraysThrowsError()
         public void TestThatFromArraysThrowsError()
         {
         {
             Assert.Throws<ArrayLengthMismatchException>(
             Assert.Throws<ArrayLengthMismatchException>(
-                () => BitmapPixelChanges.FromArrays(new[] { new Coordinates(0, 0) }, new[] { Colors.Red, Colors.Green }));
+                () => BitmapPixelChanges.FromArrays(new[] { new Coordinates(0, 0) }, new[] { ExtendedColorTests.red, ExtendedColorTests.green }));
         }
         }
 
 
         [Fact]
         [Fact]
         public void TestThatFormArraysWorks()
         public void TestThatFormArraysWorks()
         {
         {
             Coordinates[] coordinatesArray = { new Coordinates(0, 0), new Coordinates(2, 3), new Coordinates(5, 5) };
             Coordinates[] coordinatesArray = { new Coordinates(0, 0), new Coordinates(2, 3), new Coordinates(5, 5) };
-            Color[] colorsArray = { Colors.Red, Colors.Green, Colors.Blue };
+            SKColor[] colorsArray = { ExtendedColorTests.red, ExtendedColorTests.green, ExtendedColorTests.blue };
             BitmapPixelChanges result = BitmapPixelChanges.FromArrays(coordinatesArray, colorsArray);
             BitmapPixelChanges result = BitmapPixelChanges.FromArrays(coordinatesArray, colorsArray);
             for (int i = 0; i < coordinatesArray.Length; i++)
             for (int i = 0; i < coordinatesArray.Length; i++)
             {
             {

+ 8 - 7
PixiEditorTests/ModelsTests/DataHoldersTests/DocumentTests.cs

@@ -7,6 +7,7 @@ using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels;
 using PixiEditorTests.HelpersTests;
 using PixiEditorTests.HelpersTests;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.DataHoldersTests
 namespace PixiEditorTests.ModelsTests.DataHoldersTests
@@ -54,9 +55,9 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
             manager.ActiveLayer.SetPixel(
             manager.ActiveLayer.SetPixel(
                 new Coordinates(
                 new Coordinates(
                 (int)Math.Ceiling(initialWidth / 2f),
                 (int)Math.Ceiling(initialWidth / 2f),
-                (int)Math.Ceiling(initialHeight / 2f)), Colors.Black);
+                (int)Math.Ceiling(initialHeight / 2f)), ExtendedColorTests.black);
 
 
-            manager.ActiveLayer.SetPixel(new Coordinates(additionalPixelX, additionalPixelY), Colors.Black);
+            manager.ActiveLayer.SetPixel(new Coordinates(additionalPixelX, additionalPixelY), ExtendedColorTests.black);
 
 
             document.ClipCanvas();
             document.ClipCanvas();
 
 
@@ -80,11 +81,11 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
             manager.ActiveLayer.SetPixel(
             manager.ActiveLayer.SetPixel(
                 new Coordinates(
                 new Coordinates(
                 (int)Math.Ceiling(initialWidth / 2f),
                 (int)Math.Ceiling(initialWidth / 2f),
-                (int)Math.Ceiling(initialHeight / 2f)), Colors.Black); // Set pixel in center
+                (int)Math.Ceiling(initialHeight / 2f)), ExtendedColorTests.black); // Set pixel in center
 
 
             manager.ActiveDocument.AddNewLayer("test2");
             manager.ActiveDocument.AddNewLayer("test2");
 
 
-            manager.ActiveLayer.SetPixel(new Coordinates(secondLayerPixelX, secondLayerPixelY), Colors.Black);
+            manager.ActiveLayer.SetPixel(new Coordinates(secondLayerPixelX, secondLayerPixelY), ExtendedColorTests.black);
 
 
             document.ClipCanvas();
             document.ClipCanvas();
 
 
@@ -113,7 +114,7 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
             };
             };
             manager.ActiveDocument.AddNewLayer("test");
             manager.ActiveDocument.AddNewLayer("test");
 
 
-            manager.ActiveLayer.SetPixel(new Coordinates(0, 0), Colors.Green);
+            manager.ActiveLayer.SetPixel(new Coordinates(0, 0), ExtendedColorTests.green);
 
 
             doc.CenterContent();
             doc.CenterContent();
 
 
@@ -133,10 +134,10 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
                 ActiveDocument = doc
                 ActiveDocument = doc
             };
             };
             manager.ActiveDocument.AddNewLayer("test");
             manager.ActiveDocument.AddNewLayer("test");
-            manager.ActiveLayer.SetPixel(new Coordinates(0, 0), Colors.Green);
+            manager.ActiveLayer.SetPixel(new Coordinates(0, 0), ExtendedColorTests.green);
 
 
             manager.ActiveDocument.AddNewLayer("test2");
             manager.ActiveDocument.AddNewLayer("test2");
-            manager.ActiveLayer.SetPixel(new Coordinates(1, 1), Colors.Green);
+            manager.ActiveLayer.SetPixel(new Coordinates(1, 1), ExtendedColorTests.green);
 
 
             foreach (var layer in manager.ActiveDocument.Layers)
             foreach (var layer in manager.ActiveDocument.Layers)
             {
             {

+ 3 - 3
PixiEditorTests/ModelsTests/DataHoldersTests/SurfaceTests.cs

@@ -27,7 +27,7 @@ namespace PixiEditorSkiaRewrite
         public void TestSurfaceSRGBPixelManipulation()
         public void TestSurfaceSRGBPixelManipulation()
         {
         {
             using Surface surface = new Surface(128, 200);
             using Surface surface = new Surface(128, 200);
-            surface.SkiaSurface.Canvas.Clear(SKColors.Red);
+            surface.SkiaSurface.Canvas.Clear(SKExtendedColorTests.red);
             surface.SkiaSurface.Canvas.DrawRect(new SKRect(10, 10, 70, 70), redPaint);
             surface.SkiaSurface.Canvas.DrawRect(new SKRect(10, 10, 70, 70), redPaint);
             surface.SetSRGBPixel(73, 21, greenColor);
             surface.SetSRGBPixel(73, 21, greenColor);
             Assert.Equal(redColor, surface.GetSRGBPixel(14, 14));
             Assert.Equal(redColor, surface.GetSRGBPixel(14, 14));
@@ -79,12 +79,12 @@ namespace PixiEditorSkiaRewrite
         }
         }
 
 
         [Fact]
         [Fact]
-        public void TestSurfaceToWriteableBitmap()
+        public void TestSurfaceToSurface()
         {
         {
             using Surface original = new Surface(30, 40);
             using Surface original = new Surface(30, 40);
             original.SkiaSurface.Canvas.Clear(redColor);
             original.SkiaSurface.Canvas.Clear(redColor);
             original.SkiaSurface.Canvas.DrawRect(5, 5, 20, 20, greenPaint);
             original.SkiaSurface.Canvas.DrawRect(5, 5, 20, 20, greenPaint);
-            var bitmap = original.ToWriteableBitmap();
+            var bitmap = original.ToSurface();
             byte[] pixels = new byte[30 * 40 * 4];
             byte[] pixels = new byte[30 * 40 * 4];
             bitmap.CopyPixels(pixels, 30 * 4, 0);
             bitmap.CopyPixels(pixels, 30 * 4, 0);
             Assert.Equal(redColor, new SKColor(pixels[2], pixels[1], pixels[0], pixels[3]));
             Assert.Equal(redColor, new SKColor(pixels[2], pixels[1], pixels[0], pixels[3]));

+ 3 - 2
PixiEditorTests/ModelsTests/IO/ExporterTests.cs

@@ -5,6 +5,7 @@ using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.IO
 namespace PixiEditorTests.ModelsTests.IO
@@ -30,9 +31,9 @@ namespace PixiEditorTests.ModelsTests.IO
             string filePath = "testFile.pixi";
             string filePath = "testFile.pixi";
 
 
             document.Layers.Add(new Layer("layer1"));
             document.Layers.Add(new Layer("layer1"));
-            document.Layers[0].SetPixel(new Coordinates(1, 1), Colors.White);
+            document.Layers[0].SetPixel(new Coordinates(1, 1), ExtendedColorTests.white);
 
 
-            document.Swatches.Add(Colors.White);
+            document.Swatches.Add(ExtendedColorTests.white);
 
 
             Exporter.SaveAsEditableFile(document, filePath);
             Exporter.SaveAsEditableFile(document, filePath);
 
 

+ 14 - 13
PixiEditorTests/ModelsTests/IO/ImporterTests.cs

@@ -1,6 +1,7 @@
 using PixiEditor.Exceptions;
 using PixiEditor.Exceptions;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.IO;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using SkiaSharp;
 using SkiaSharp;
 using System;
 using System;
 using System.IO;
 using System.IO;
@@ -36,17 +37,17 @@ namespace PixiEditorTests.ModelsTests.IO
         [Fact]
         [Fact]
         public void TestThatImportImageImportsImage()
         public void TestThatImportImageImportsImage()
         {
         {
-            Color color = Color.FromArgb(255, 255, 0, 0);
-            WriteableBitmap image = Importer.ImportSurface(testImagePath);
+            SKColor color = new SKColor(255, 255, 0, 0);
+            Surface image = Importer.ImportSurface(testImagePath);
 
 
             Assert.NotNull(image);
             Assert.NotNull(image);
-            Assert.Equal(5, image.PixelWidth);
-            Assert.Equal(5, image.PixelHeight);
-            Assert.Equal(color, image.GetPixel(0, 0)); // Top left
-            Assert.Equal(color, image.GetPixel(4, 4)); // Bottom right
-            Assert.Equal(color, image.GetPixel(0, 4)); // Bottom left
-            Assert.Equal(color, image.GetPixel(4, 0)); // Top right
-            Assert.Equal(color, image.GetPixel(2, 2)); // Middle center
+            Assert.Equal(5, image.Width);
+            Assert.Equal(5, image.Height);
+            Assert.Equal(color, image.GetSRGBPixel(0, 0)); // Top left
+            Assert.Equal(color, image.GetSRGBPixel(4, 4)); // Bottom right
+            Assert.Equal(color, image.GetSRGBPixel(0, 4)); // Bottom left
+            Assert.Equal(color, image.GetSRGBPixel(4, 0)); // Top right
+            Assert.Equal(color, image.GetSRGBPixel(2, 2)); // Middle center
         }
         }
 
 
         [Fact]
         [Fact]
@@ -68,17 +69,17 @@ namespace PixiEditorTests.ModelsTests.IO
         [Fact]
         [Fact]
         public void TestThatImportImageResizes()
         public void TestThatImportImageResizes()
         {
         {
-            WriteableBitmap image = Importer.ImportImage(testImagePath, 10, 10);
+            Surface image = Importer.ImportImage(testImagePath, 10, 10);
 
 
-            Assert.Equal(10, image.PixelWidth);
-            Assert.Equal(10, image.PixelHeight);
+            Assert.Equal(10, image.Width);
+            Assert.Equal(10, image.Height);
         }
         }
 
 
         [Fact]
         [Fact]
         public void TestSaveAndLoadGZippedBytes()
         public void TestSaveAndLoadGZippedBytes()
         {
         {
             using Surface original = new Surface(123, 456);
             using Surface original = new Surface(123, 456);
-            original.SkiaSurface.Canvas.Clear(SKColors.Red);
+            original.SkiaSurface.Canvas.Clear(ExtendedColorTests.red);
             using SKPaint paint = new SKPaint();
             using SKPaint paint = new SKPaint();
             paint.BlendMode = SKBlendMode.Src;
             paint.BlendMode = SKBlendMode.Src;
             paint.Color = new SKColor(128, 64, 32, 16);
             paint.Color = new SKColor(128, 64, 32, 16);

+ 19 - 18
PixiEditorTests/ModelsTests/ImageManipulationTests/BitmapUtilsTests.cs

@@ -7,6 +7,7 @@ using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.ImageManipulation;
 using PixiEditor.Models.ImageManipulation;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.ImageManipulationTests
 namespace PixiEditorTests.ModelsTests.ImageManipulationTests
@@ -14,24 +15,24 @@ namespace PixiEditorTests.ModelsTests.ImageManipulationTests
     public class BitmapUtilsTests
     public class BitmapUtilsTests
     {
     {
         [Fact]
         [Fact]
-        public void TestBytesToWriteableBitmap()
+        public void TestBytesToSurface()
         {
         {
             int width = 10;
             int width = 10;
             int height = 10;
             int height = 10;
             Coordinates[] coloredPoints = { new Coordinates(0, 0), new Coordinates(3, 6), new Coordinates(9, 9) };
             Coordinates[] coloredPoints = { new Coordinates(0, 0), new Coordinates(3, 6), new Coordinates(9, 9) };
-            WriteableBitmap bmp = BitmapFactory.New(width, height);
+            Surface bmp = BitmapFactory.New(width, height);
             for (int i = 0; i < coloredPoints.Length; i++)
             for (int i = 0; i < coloredPoints.Length; i++)
             {
             {
-                bmp.SetPixel(coloredPoints[i].X, coloredPoints[i].Y, Colors.Green);
+                bmp.SetPixel(coloredPoints[i].X, coloredPoints[i].Y, ExtendedColorTests.green);
             }
             }
 
 
             byte[] byteArray = bmp.ToByteArray();
             byte[] byteArray = bmp.ToByteArray();
 
 
-            WriteableBitmap convertedBitmap = BitmapUtils.BytesToWriteableBitmap(width, height, byteArray);
+            Surface convertedBitmap = BitmapUtils.BytesToSurface(width, height, byteArray);
 
 
             for (int i = 0; i < coloredPoints.Length; i++)
             for (int i = 0; i < coloredPoints.Length; i++)
             {
             {
-                Assert.Equal(Colors.Green, convertedBitmap.GetPixel(coloredPoints[i].X, coloredPoints[i].Y));
+                Assert.Equal(ExtendedColorTests.green, convertedBitmap.GetPixel(coloredPoints[i].X, coloredPoints[i].Y));
             }
             }
         }
         }
 
 
@@ -41,14 +42,14 @@ namespace PixiEditorTests.ModelsTests.ImageManipulationTests
             Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };
             Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };
             Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
             Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
 
 
-            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[0] }, Colors.Green));
+            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[0] }, ExtendedColorTests.green));
 
 
-            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[1] }, Colors.Red));
+            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[1] }, ExtendedColorTests.red));
 
 
-            WriteableBitmap outputBitmap = BitmapUtils.CombineLayers(2, 2, layers);
+            Surface outputBitmap = BitmapUtils.CombineLayers(2, 2, layers);
 
 
-            Assert.Equal(Colors.Green, outputBitmap.GetPixel(0, 0));
-            Assert.Equal(Colors.Red, outputBitmap.GetPixel(1, 1));
+            Assert.Equal(ExtendedColorTests.green, outputBitmap.GetPixel(0, 0));
+            Assert.Equal(ExtendedColorTests.red, outputBitmap.GetPixel(1, 1));
         }
         }
 
 
         [Fact]
         [Fact]
@@ -57,13 +58,13 @@ namespace PixiEditorTests.ModelsTests.ImageManipulationTests
             Coordinates[] cords = { new Coordinates(0, 0) };
             Coordinates[] cords = { new Coordinates(0, 0) };
             Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
             Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
 
 
-            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(cords, Colors.Green));
+            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.green));
 
 
-            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(cords, Colors.Red));
+            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.red));
 
 
-            WriteableBitmap outputBitmap = BitmapUtils.CombineLayers(2, 2, layers);
+            Surface outputBitmap = BitmapUtils.CombineLayers(2, 2, layers);
 
 
-            Assert.Equal(Colors.Red, outputBitmap.GetPixel(0, 0));
+            Assert.Equal(ExtendedColorTests.red, outputBitmap.GetSRGBPixel(0, 0));
         }
         }
 
 
         [Fact]
         [Fact]
@@ -76,8 +77,8 @@ namespace PixiEditorTests.ModelsTests.ImageManipulationTests
             };
             };
             Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
             Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
 
 
-            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[0] }, Colors.Green));
-            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[1] }, Colors.Red));
+            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[0] }, ExtendedColorTests.green));
+            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[1] }, ExtendedColorTests.red));
 
 
             Dictionary<Guid, Color[]> output = BitmapUtils.GetPixelsForSelection(layers, cords);
             Dictionary<Guid, Color[]> output = BitmapUtils.GetPixelsForSelection(layers, cords);
 
 
@@ -91,8 +92,8 @@ namespace PixiEditorTests.ModelsTests.ImageManipulationTests
                 }
                 }
             }
             }
 
 
-            Assert.Single(colors.Where(x => x == Colors.Green));
-            Assert.Single(colors.Where(x => x == Colors.Red));
+            Assert.Single(colors.Where(x => x == ExtendedColorTests.green));
+            Assert.Single(colors.Where(x => x == ExtendedColorTests.red));
             Assert.Equal(6, colors.Count(x => x.A == 0)); // 6 because layer is 4 pixels,
             Assert.Equal(6, colors.Count(x => x.A == 0)); // 6 because layer is 4 pixels,
 
 
             // 2 * 4 = 8, 2 other color pixels, so 8 - 2 = 6
             // 2 * 4 = 8, 2 other color pixels, so 8 - 2 = 6

+ 17 - 16
PixiEditorTests/ModelsTests/LayersTests/LayerTests.cs

@@ -3,6 +3,7 @@ using System.Windows.Media.Imaging;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.LayersTests
 namespace PixiEditorTests.ModelsTests.LayersTests
@@ -17,8 +18,8 @@ namespace PixiEditorTests.ModelsTests.LayersTests
             Assert.Equal("layer", layer.Name);
             Assert.Equal("layer", layer.Name);
             Assert.Equal(0, layer.Width);
             Assert.Equal(0, layer.Width);
             Assert.Equal(0, layer.Height);
             Assert.Equal(0, layer.Height);
-            Assert.Equal(1, layer.LayerBitmap.PixelWidth);
-            Assert.Equal(1, layer.LayerBitmap.PixelHeight);
+            Assert.Equal(1, layer.LayerBitmap.Width);
+            Assert.Equal(1, layer.LayerBitmap.Height);
         }
         }
 
 
         [Fact]
         [Fact]
@@ -29,22 +30,22 @@ namespace PixiEditorTests.ModelsTests.LayersTests
             Assert.Equal("layer", layer.Name);
             Assert.Equal("layer", layer.Name);
             Assert.Equal(10, layer.Width);
             Assert.Equal(10, layer.Width);
             Assert.Equal(10, layer.Height);
             Assert.Equal(10, layer.Height);
-            Assert.Equal(10, layer.LayerBitmap.PixelWidth);
-            Assert.Equal(10, layer.LayerBitmap.PixelHeight);
+            Assert.Equal(10, layer.LayerBitmap.Width);
+            Assert.Equal(10, layer.LayerBitmap.Height);
         }
         }
 
 
         [Fact]
         [Fact]
         public void TestThatLayerFromBitmapGeneratesCorrectly()
         public void TestThatLayerFromBitmapGeneratesCorrectly()
         {
         {
-            WriteableBitmap bmp = BitmapFactory.New(10, 10);
+            using Surface bmp = new Surface(10, 10);
 
 
             Layer layer = new Layer("layer", bmp);
             Layer layer = new Layer("layer", bmp);
 
 
             Assert.Equal("layer", layer.Name);
             Assert.Equal("layer", layer.Name);
             Assert.Equal(10, layer.Width);
             Assert.Equal(10, layer.Width);
             Assert.Equal(10, layer.Height);
             Assert.Equal(10, layer.Height);
-            Assert.Equal(10, layer.LayerBitmap.PixelWidth);
-            Assert.Equal(10, layer.LayerBitmap.PixelHeight);
+            Assert.Equal(10, layer.LayerBitmap.Width);
+            Assert.Equal(10, layer.LayerBitmap.Height);
         }
         }
 
 
         [Fact]
         [Fact]
@@ -64,9 +65,9 @@ namespace PixiEditorTests.ModelsTests.LayersTests
 
 
             Layer clone = layer.Clone();
             Layer clone = layer.Clone();
 
 
-            clone.LayerBitmap.SetPixel(0, 0, Colors.Green); // Actually we are checking if modifying clone bitmap does not affect original
+            clone.LayerBitmap.SetSRGBPixel(0, 0, ExtendedColorTests.green); // Actually we are checking if modifying clone bitmap does not affect original
 
 
-            Assert.NotEqual(Colors.Green, layer.GetPixel(0, 0));
+            Assert.NotEqual(ExtendedColorTests.green, layer.GetPixel(0, 0));
         }
         }
 
 
         [Fact]
         [Fact]
@@ -74,7 +75,7 @@ namespace PixiEditorTests.ModelsTests.LayersTests
         {
         {
             Layer layer = new Layer("layer", 1, 1);
             Layer layer = new Layer("layer", 1, 1);
 
 
-            layer.SetPixel(new Coordinates(0, 0), Colors.Black);
+            layer.SetPixel(new Coordinates(0, 0), ExtendedColorTests.black);
 
 
             layer.Resize(2, 2, 2, 2);
             layer.Resize(2, 2, 2, 2);
 
 
@@ -88,7 +89,7 @@ namespace PixiEditorTests.ModelsTests.LayersTests
             {
             {
                 for (int x = 0; x < layer.Width; x++)
                 for (int x = 0; x < layer.Width; x++)
                 {
                 {
-                    Assert.Equal(Colors.Black, layer.GetPixel(x, y));
+                    Assert.Equal(ExtendedColorTests.black, layer.GetPixel(x, y));
                 }
                 }
             }
             }
         }
         }
@@ -98,7 +99,7 @@ namespace PixiEditorTests.ModelsTests.LayersTests
         {
         {
             Layer layer = new Layer("layer");
             Layer layer = new Layer("layer");
 
 
-            Assert.Equal(0, layer.GetPixel(-1, 999).A);
+            Assert.Equal(0, layer.GetPixel(-1, 999).Alpha);
         }
         }
 
 
         [Fact]
         [Fact]
@@ -108,11 +109,11 @@ namespace PixiEditorTests.ModelsTests.LayersTests
 
 
             Layer layer = new Layer("layer");
             Layer layer = new Layer("layer");
 
 
-            layer.SetPixels(BitmapPixelChanges.FromSingleColoredArray(pixels, Colors.Green));
+            layer.SetPixels(BitmapPixelChanges.FromSingleColoredArray(pixels, ExtendedColorTests.green));
 
 
             for (int i = 0; i < pixels.Length; i++)
             for (int i = 0; i < pixels.Length; i++)
             {
             {
-                Assert.Equal(Colors.Green, layer.GetPixelWithOffset(pixels[i].X, pixels[i].Y));
+                Assert.Equal(ExtendedColorTests.green, layer.GetPixelWithOffset(pixels[i].X, pixels[i].Y));
             }
             }
         }
         }
 
 
@@ -120,13 +121,13 @@ namespace PixiEditorTests.ModelsTests.LayersTests
         public void TestThatClipCanvasResizesBitmapCorrectly()
         public void TestThatClipCanvasResizesBitmapCorrectly()
         {
         {
             Layer layer = new Layer("layer", 10, 10);
             Layer layer = new Layer("layer", 10, 10);
-            layer.SetPixel(new Coordinates(4, 4), Colors.Blue);
+            layer.SetPixel(new Coordinates(4, 4), ExtendedColorTests.blue);
 
 
             layer.ClipCanvas();
             layer.ClipCanvas();
 
 
             Assert.Equal(1, layer.Width);
             Assert.Equal(1, layer.Width);
             Assert.Equal(1, layer.Height);
             Assert.Equal(1, layer.Height);
-            Assert.Equal(Colors.Blue, layer.GetPixel(0, 0));
+            Assert.Equal(ExtendedColorTests.blue, layer.GetPixel(0, 0));
         }
         }
     }
     }
 }
 }

+ 2 - 1
PixiEditorTests/ModelsTests/ToolsTests/BrightnessToolTests.cs

@@ -2,6 +2,7 @@
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditor.Models.Tools.Tools;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.ToolsTests
 namespace PixiEditorTests.ModelsTests.ToolsTests
@@ -21,7 +22,7 @@ namespace PixiEditorTests.ModelsTests.ToolsTests
             BrightnessTool tool = new BrightnessTool();
             BrightnessTool tool = new BrightnessTool();
 
 
             Layer layer = new Layer("test", 1, 1);
             Layer layer = new Layer("test", 1, 1);
-            layer.SetPixel(new Coordinates(0, 0), correctionFactor < 0 ? Colors.White : Colors.Black);
+            layer.SetPixel(new Coordinates(0, 0), correctionFactor < 0 ? ExtendedColorTests.white : ExtendedColorTests.black);
 
 
             PixiEditor.Models.DataHolders.BitmapPixelChanges changes = tool.ChangeBrightness(layer, new Coordinates(0, 0), 1, correctionFactor);
             PixiEditor.Models.DataHolders.BitmapPixelChanges changes = tool.ChangeBrightness(layer, new Coordinates(0, 0), 1, correctionFactor);
             layer.SetPixels(changes);
             layer.SetPixels(changes);

+ 5 - 4
PixiEditorTests/ModelsTests/ToolsTests/PenToolTests.cs

@@ -1,6 +1,7 @@
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditorTests.HelpersTests;
 using PixiEditorTests.HelpersTests;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using Xunit;
 using Xunit;
 
 
 namespace PixiEditorTests.ModelsTests.ToolsTests
 namespace PixiEditorTests.ModelsTests.ToolsTests
@@ -18,11 +19,11 @@ namespace PixiEditorTests.ModelsTests.ToolsTests
             Coordinates end2 = new Coordinates(1, 0);
             Coordinates end2 = new Coordinates(1, 0);
             Coordinates start2 = new Coordinates(1, 1);
             Coordinates start2 = new Coordinates(1, 1);
 
 
-            pen.Draw(start, end, System.Windows.Media.Colors.Black, 1, true);
-            pen.Draw(end, end2, System.Windows.Media.Colors.Black, 1, true);
-            var points = pen.Draw(end2, start2, System.Windows.Media.Colors.Black, 1, true);
+            pen.Draw(start, end, ExtendedColorTests.black, 1, true);
+            pen.Draw(end, end2, ExtendedColorTests.black, 1, true);
+            var points = pen.Draw(end2, start2, ExtendedColorTests.black, 1, true);
 
 
-            Assert.Contains(points.ChangedPixels, x => x.Value.A == 0);
+            Assert.Contains(points.ChangedPixels, x => x.Value.Alpha == 0);
         }
         }
     }
     }
 }
 }

+ 5 - 4
PixiEditorTests/ModelsTests/UndoTests/StorageBasedChangeTests.cs

@@ -11,6 +11,7 @@ using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Undo;
 using PixiEditor.Models.Undo;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using PixiEditorTests.ModelsTests.LayersTests;
 using PixiEditorTests.ModelsTests.LayersTests;
 using Xunit;
 using Xunit;
 
 
@@ -31,10 +32,10 @@ namespace PixiEditorTests.ModelsTests.UndoTests
         public Document GenerateTestDocument()
         public Document GenerateTestDocument()
         {
         {
             Document testDocument = new Document(10, 10);
             Document testDocument = new Document(10, 10);
-            WriteableBitmap testBitmap = BitmapFactory.New(10, 10);
-            WriteableBitmap testBitmap2 = BitmapFactory.New(5, 8);
-            testBitmap.SetPixel(0, 0, Colors.Black);
-            testBitmap2.SetPixel(4, 4, Colors.Beige);
+            using Surface testBitmap = new Surface(10, 10);
+            using Surface testBitmap2 = new Surface(5, 8);
+            testBitmap.SetSRGBPixel(0, 0, ExtendedColorTests.black);
+            testBitmap2.SetSRGBPixel(4, 4, ExtendedColorTests.blue);
             Random random = new Random();
             Random random = new Random();
             testDocument.Layers = new ObservableCollection<Layer>()
             testDocument.Layers = new ObservableCollection<Layer>()
             {
             {

+ 8 - 7
PixiEditorTests/ViewModelsTests/ViewModelMainTests.cs

@@ -3,6 +3,7 @@ using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels;
 using PixiEditorTests.HelpersTests;
 using PixiEditorTests.HelpersTests;
+using PixiEditorTests.ModelsTests.ColorsTests;
 using System.IO;
 using System.IO;
 using System.Windows.Input;
 using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media;
@@ -30,13 +31,13 @@ namespace PixiEditorTests.ViewModelsTests
         {
         {
             ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain();
             ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain();
 
 
-            viewModel.ColorsSubViewModel.PrimaryColor = Colors.Black;
-            viewModel.ColorsSubViewModel.SecondaryColor = Colors.White;
+            viewModel.ColorsSubViewModel.PrimaryColor = ExtendedColorTests.black;
+            viewModel.ColorsSubViewModel.SecondaryColor = ExtendedColorTests.white;
 
 
             viewModel.ColorsSubViewModel.SwapColorsCommand.Execute(null);
             viewModel.ColorsSubViewModel.SwapColorsCommand.Execute(null);
 
 
-            Assert.Equal(Colors.White, viewModel.ColorsSubViewModel.PrimaryColor);
-            Assert.Equal(Colors.Black, viewModel.ColorsSubViewModel.SecondaryColor);
+            Assert.Equal(ExtendedColorTests.white, viewModel.ColorsSubViewModel.PrimaryColor);
+            Assert.Equal(ExtendedColorTests.black, viewModel.ColorsSubViewModel.SecondaryColor);
         }
         }
 
 
         [StaFact]
         [StaFact]
@@ -130,11 +131,11 @@ namespace PixiEditorTests.ViewModelsTests
             ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain();
             ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain();
             viewModel.BitmapManager.ActiveDocument = new Document(1, 1);
             viewModel.BitmapManager.ActiveDocument = new Document(1, 1);
 
 
-            viewModel.ColorsSubViewModel.AddSwatch(Colors.Green);
-            viewModel.ColorsSubViewModel.AddSwatch(Colors.Green);
+            viewModel.ColorsSubViewModel.AddSwatch(ExtendedColorTests.green);
+            viewModel.ColorsSubViewModel.AddSwatch(ExtendedColorTests.green);
 
 
             Assert.Single(viewModel.BitmapManager.ActiveDocument.Swatches);
             Assert.Single(viewModel.BitmapManager.ActiveDocument.Swatches);
-            Assert.Equal(Colors.Green, viewModel.BitmapManager.ActiveDocument.Swatches[0]);
+            Assert.Equal(ExtendedColorTests.green, viewModel.BitmapManager.ActiveDocument.Swatches[0]);
         }
         }
 
 
         [StaTheory]
         [StaTheory]