BitmapUtilsTests.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using PixiEditor.Models.DataHolders;
  2. using PixiEditor.Models.ImageManipulation;
  3. using PixiEditor.Models.Layers;
  4. using PixiEditor.Models.Position;
  5. using SkiaSharp;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using Xunit;
  10. namespace PixiEditorTests.ModelsTests.ImageManipulationTests
  11. {
  12. public class BitmapUtilsTests
  13. {
  14. //[Fact]
  15. //public void TestThatCombineLayersReturnsCorrectBitmap()
  16. //{
  17. // Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };
  18. // Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
  19. // layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[0] }, SKColors.Lime));
  20. // layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[1] }, SKColors.Red));
  21. // Surface outputBitmap = BitmapUtils.CombineLayers(2, 2, layers);
  22. // Assert.Equal(SKColors.Lime, outputBitmap.GetSRGBPixel(0, 0));
  23. // Assert.Equal(SKColors.Red, outputBitmap.GetSRGBPixel(1, 1));
  24. //}
  25. //[Fact]
  26. //public void TestThatCombineLayersReturnsCorrectBitmapWithSamePixels()
  27. //{
  28. // Coordinates[] cords = { new Coordinates(0, 0) };
  29. // Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
  30. // layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Lime));
  31. // layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Red));
  32. // Surface outputBitmap = BitmapUtils.CombineLayers(2, 2, layers);
  33. // Assert.Equal(SKColors.Red, outputBitmap.GetSRGBPixel(0, 0));
  34. //}
  35. //[Fact]
  36. //public void TestThatGetPixelsForSelectionReturnsCorrectPixels()
  37. //{
  38. // Coordinates[] cords =
  39. // {
  40. // new Coordinates(0, 0),
  41. // new Coordinates(1, 1), new Coordinates(0, 1), new Coordinates(1, 0)
  42. // };
  43. // Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
  44. // layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[0] }, SKColors.Lime));
  45. // layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[1] }, SKColors.Red));
  46. // Dictionary<Guid, SKColor[]> output = BitmapUtils.GetPixelsForSelection(layers, cords);
  47. // List<SKColor> colors = new List<SKColor>();
  48. // foreach (KeyValuePair<Guid, SKColor[]> layerColor in output.ToArray())
  49. // {
  50. // foreach (SKColor color in layerColor.Value)
  51. // {
  52. // colors.Add(color);
  53. // }
  54. // }
  55. // Assert.Single(colors.Where(x => x == SKColors.Lime));
  56. // Assert.Single(colors.Where(x => x == SKColors.Red));
  57. // Assert.Equal(6, colors.Count(x => x.Alpha == 0)); // 6 because layer is 4 pixels,
  58. // // 2 * 4 = 8, 2 other color pixels, so 8 - 2 = 6
  59. //}
  60. }
  61. }