diff --git a/src/SerialLoops.Lib/Items/BackgroundItem.cs b/src/SerialLoops.Lib/Items/BackgroundItem.cs index 8f81e40d..6a43f53e 100644 --- a/src/SerialLoops.Lib/Items/BackgroundItem.cs +++ b/src/SerialLoops.Lib/Items/BackgroundItem.cs @@ -55,7 +55,7 @@ public SKBitmap GetBackground() return bitmap; } - else if (BackgroundType == BgType.KINETIC_VECTOR) + else if (BackgroundType == BgType.KINETIC_SCREEN) { return Graphic2.GetScreenImage(Graphic1); } diff --git a/src/SerialLoops.Lib/SerialLoops.Lib.csproj b/src/SerialLoops.Lib/SerialLoops.Lib.csproj index a1e7bd3e..44d99a03 100644 --- a/src/SerialLoops.Lib/SerialLoops.Lib.csproj +++ b/src/SerialLoops.Lib/SerialLoops.Lib.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/SerialLoops/Editors/BackgroundEditor.cs b/src/SerialLoops/Editors/BackgroundEditor.cs index ee94af65..402aeb9d 100644 --- a/src/SerialLoops/Editors/BackgroundEditor.cs +++ b/src/SerialLoops/Editors/BackgroundEditor.cs @@ -22,7 +22,7 @@ public override Panel GetEditorPanel() Orientation = Orientation.Vertical, Items = { - new ImageView() { Image = new SKImage(((BackgroundItem)Description).GetBackground()) }, + new ImageView() { Image = new SKGuiImage(((BackgroundItem)Description).GetBackground()) }, } }; } diff --git a/src/SerialLoops/SKGuiImage.cs b/src/SerialLoops/SKGuiImage.cs new file mode 100644 index 00000000..13a23a06 --- /dev/null +++ b/src/SerialLoops/SKGuiImage.cs @@ -0,0 +1,14 @@ +using Eto.Drawing; +using SkiaSharp; + +namespace SerialLoops +{ + public class SKGuiImage : Bitmap + { + public SKBitmap skBitmap { get; set; } + + public SKGuiImage(SKBitmap skBitmap) : base(skBitmap.Encode(SKEncodedImageFormat.Png, 1).AsStream()) + { + } + } +} diff --git a/src/SerialLoops/SKImage.cs b/src/SerialLoops/SKImage.cs deleted file mode 100644 index 76b82254..00000000 --- a/src/SerialLoops/SKImage.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Eto.Drawing; -using SkiaSharp; -using System.IO; - -namespace SerialLoops -{ - public class SKImage : Bitmap - { - public SKBitmap skBitmap { get; set; } - - public SKImage(SKBitmap skBitmap) : base(skBitmap.Encode(SKEncodedImageFormat.Png, 1).AsStream()) - { - } - } -} diff --git a/src/SerialLoops/SerialLoops.csproj b/src/SerialLoops/SerialLoops.csproj index 4a6d5a99..417a720b 100644 --- a/src/SerialLoops/SerialLoops.csproj +++ b/src/SerialLoops/SerialLoops.csproj @@ -13,7 +13,6 @@ - diff --git a/test/SerialLoops.Tests/ItemTests.cs b/test/SerialLoops.Tests/ItemTests.cs index a54eb0f1..4129e40a 100644 --- a/test/SerialLoops.Tests/ItemTests.cs +++ b/test/SerialLoops.Tests/ItemTests.cs @@ -1,5 +1,6 @@ using HaruhiChokuretsuLib.Archive.Data; using HaruhiChokuretsuLib.Archive.Event; +using HaruhiChokuretsuLib.Archive.Graphics; using HaruhiChokuretsuLib.Util; using NUnit.Framework; using SerialLoops.Lib.Items; @@ -37,5 +38,18 @@ public void EventItemCreationTest(string evtFile) Assert.That(evt.Name[0..^1], Is.EqualTo(eventItem.Name)); } + + [Test] + public void BackgroundItemCreationTest() + { + GraphicsFile grp1 = new(); + GraphicsFile grp2 = new(); + grp1.Name = "KBG00_128DNX"; + grp2.Name = "KBG00BNS"; + grp1.Initialize(File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "inputs", "graphics", "KBG00_128.bin")), 0, _log); + grp2.Initialize(File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "inputs", "graphics", "KBG00.bin")), 0, _log); + BackgroundItem item = new($"BG_{grp2.Name}") { Graphic1 = grp1, Graphic2 = grp2, BackgroundType = BgType.KINETIC_SCREEN }; + item.GetBackground(); + } } } diff --git a/test/SerialLoops.Tests/SerialLoops.Tests.csproj b/test/SerialLoops.Tests/SerialLoops.Tests.csproj index 250988ae..9d2f7e6c 100644 --- a/test/SerialLoops.Tests/SerialLoops.Tests.csproj +++ b/test/SerialLoops.Tests/SerialLoops.Tests.csproj @@ -25,8 +25,4 @@ - - - - diff --git a/test/SerialLoops.Tests/inputs/graphics/KBG00.bin b/test/SerialLoops.Tests/inputs/graphics/KBG00.bin new file mode 100644 index 00000000..774efc4e Binary files /dev/null and b/test/SerialLoops.Tests/inputs/graphics/KBG00.bin differ diff --git a/test/SerialLoops.Tests/inputs/graphics/KBG00_128.bin b/test/SerialLoops.Tests/inputs/graphics/KBG00_128.bin new file mode 100644 index 00000000..ecc67b61 Binary files /dev/null and b/test/SerialLoops.Tests/inputs/graphics/KBG00_128.bin differ