diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj
index 95207d12..b5869108 100644
--- a/ArcFormats/ArcFormats.csproj
+++ b/ArcFormats/ArcFormats.csproj
@@ -72,6 +72,7 @@
WidgetMCG.xaml
+
diff --git a/ArcFormats/Kaguya/ImageAO.cs b/ArcFormats/Kaguya/ImageAO.cs
new file mode 100644
index 00000000..637061ba
--- /dev/null
+++ b/ArcFormats/Kaguya/ImageAO.cs
@@ -0,0 +1,88 @@
+//! \file ImageAO.cs
+//! \date Tue Nov 24 15:42:43 2015
+//! \brief KaGuYa script engine image format.
+//
+// Copyright (C) 2015 by morkt
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//
+
+using System.ComponentModel.Composition;
+using System.IO;
+using System.Text;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+
+namespace GameRes.Formats.Kaguya
+{
+ [Export(typeof(ImageFormat))]
+ public class AoFormat : ApFormat
+ {
+ public override string Tag { get { return "AO/KAGUYA"; } }
+ public override string Description { get { return "KaGuYa script engine image format"; } }
+ public override uint Signature { get { return 0; } }
+
+ public AoFormat ()
+ {
+ Extensions = new string[] { "sp_" };
+ }
+
+ public override ImageMetaData ReadMetaData (Stream stream)
+ {
+ int A = stream.ReadByte();
+ int O = stream.ReadByte();
+ if ('A' != A || 'O' != O)
+ return null;
+ using (var file = new ArcView.Reader (stream))
+ {
+ var info = new ImageMetaData();
+ info.Width = file.ReadUInt32();
+ info.Height = file.ReadUInt32();
+ info.BPP = file.ReadInt16();
+ info.OffsetX = file.ReadInt32();
+ info.OffsetY = file.ReadInt32();
+ if (info.Width > 0x8000 || info.Height > 0x8000 || !(32 == info.BPP || 24 == info.BPP))
+ return null;
+ return info;
+ }
+ }
+
+ public override ImageData Read (Stream stream, ImageMetaData info)
+ {
+ stream.Position = 0x14;
+ return ReadBitmapData (stream, info);
+ }
+
+ public override void Write (Stream file, ImageData image)
+ {
+ using (var output = new BinaryWriter (file, Encoding.ASCII, true))
+ {
+ output.Write ((byte)'A');
+ output.Write ((byte)'O');
+ output.Write (image.Width);
+ output.Write (image.Height);
+ output.Write ((short)24);
+ output.Write (image.OffsetX);
+ output.Write (image.OffsetY);
+ WriteBitmapData (file, image);
+ }
+ }
+ }
+}
diff --git a/ArcFormats/Kaguya/ImageAP.cs b/ArcFormats/Kaguya/ImageAP.cs
index 897a7f17..736f55c8 100644
--- a/ArcFormats/Kaguya/ImageAP.cs
+++ b/ArcFormats/Kaguya/ImageAP.cs
@@ -29,7 +29,6 @@ using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
-using GameRes.Utility;
namespace GameRes.Formats.Kaguya
{
@@ -66,6 +65,11 @@ namespace GameRes.Formats.Kaguya
public override ImageData Read (Stream stream, ImageMetaData info)
{
stream.Position = 12;
+ return ReadBitmapData (stream, info);
+ }
+
+ protected ImageData ReadBitmapData (Stream stream, ImageMetaData info)
+ {
int stride = (int)info.Width*4;
var pixels = new byte[stride*info.Height];
for (int row = (int)info.Height-1; row >= 0; --row)
@@ -86,21 +90,25 @@ namespace GameRes.Formats.Kaguya
output.Write (image.Width);
output.Write (image.Height);
output.Write ((short)24);
+ WriteBitmapData (file, image);
+ }
+ }
- var bitmap = image.Bitmap;
- if (bitmap.Format != PixelFormats.Bgra32)
- {
- bitmap = new FormatConvertedBitmap (bitmap, PixelFormats.Bgra32, null, 0);
- }
- int stride = (int)image.Width * 4;
- byte[] row_data = new byte[stride];
- Int32Rect rect = new Int32Rect (0, (int)image.Height, (int)image.Width, 1);
- for (uint row = 0; row < image.Height; ++row)
- {
- --rect.Y;
- bitmap.CopyPixels (rect, row_data, stride, 0);
- output.Write (row_data);
- }
+ protected void WriteBitmapData (Stream file, ImageData image)
+ {
+ var bitmap = image.Bitmap;
+ if (bitmap.Format != PixelFormats.Bgra32)
+ {
+ bitmap = new FormatConvertedBitmap (bitmap, PixelFormats.Bgra32, null, 0);
+ }
+ int stride = (int)image.Width * 4;
+ byte[] row_data = new byte[stride];
+ Int32Rect rect = new Int32Rect (0, (int)image.Height, (int)image.Width, 1);
+ for (uint row = 0; row < image.Height; ++row)
+ {
+ --rect.Y;
+ bitmap.CopyPixels (rect, row_data, stride, 0);
+ file.Write (row_data, 0, row_data.Length);
}
}
}
diff --git a/supported.html b/supported.html
index d4f874d0..82c5bafb 100644
--- a/supported.html
+++ b/supported.html
@@ -308,12 +308,13 @@ Yatohime Zankikou
*.eri *.mio | Entis\x1a | No |
*.saf | - | No | Lune | Rinkan Gakuen |
*.arc+*.ari | WFL1 | No | KaGuYa |
+Dungeon Crusaderz 2 ~Eigou no Rakudo~
Onna Kyoushi
Medorei ~Okasareta Houkago~
Serina
Ura Nyuugaku ~Ineki ni Nureta Kyoukasho~
|
-*.bg_ *.cg_ | AP | Yes |
+*.bg_ *.cg_ *.sp_ | AP AO | Yes |
*.dpk | DPK | No | DAC | Yumemiru Tsuki no Lunalutia |
*.dgc | DGC | No |
*.pck | - | No | Crowd |
|