From af970a274cc43538b75072c3cdbceeded9914e0c Mon Sep 17 00:00:00 2001 From: morkt Date: Mon, 30 Mar 2020 17:35:55 +0400 Subject: [PATCH] (CG): tweak image stride. --- ArcFormats/Software House Parsley/ArcCG.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ArcFormats/Software House Parsley/ArcCG.cs b/ArcFormats/Software House Parsley/ArcCG.cs index eb8864ee..7ad1f5b9 100644 --- a/ArcFormats/Software House Parsley/ArcCG.cs +++ b/ArcFormats/Software House Parsley/ArcCG.cs @@ -36,8 +36,8 @@ namespace GameRes.Formats.Parsley [Export(typeof(ArchiveFormat))] public class CgOpener : ArchiveFormat { - public override string Tag { get { return "CG/PARSLEY/2"; } } - public override string Description { get { return "Software House Parsley CG archive"; } } + public override string Tag { get { return "DAT/yanepack"; } } + public override string Description { get { return "YaneSDK resouce archive"; } } public override uint Signature { get { return 0; } } public override bool IsHierarchic { get { return false; } } public override bool CanWrite { get { return false; } } @@ -50,6 +50,11 @@ namespace GameRes.Formats.Parsley public override ArcFile TryOpen (ArcView file) { + if (file.View.AsciiEqual (0, "yane")) + { + if (!file.View.AsciiEqual (4, "pack")) + return null; + } int count = file.View.ReadInt32 (8); if (!IsSaneCount (count)) return null; @@ -64,7 +69,7 @@ namespace GameRes.Formats.Parsley var name = file.View.ReadString (index_offset, 0x20); if (string.IsNullOrWhiteSpace (name)) return null; - var entry = FormatCatalog.Instance.Create (name); + var entry = Create (name); entry.Offset = file.View.ReadUInt32 (index_offset+0x20); entry.Size = file.View.ReadUInt32 (index_offset+0x24); if (!entry.CheckPlacement (file.MaxOffset)) @@ -108,7 +113,7 @@ namespace GameRes.Formats.Parsley var name = index.ReadCString(); if (string.IsNullOrWhiteSpace (name) || name.Length > 0x100) return null; - var entry = FormatCatalog.Instance.Create (name); + var entry = Create (name); entry.Offset = index.ReadUInt32(); if (entry.Offset >= file.MaxOffset) return null; @@ -221,10 +226,19 @@ namespace GameRes.Formats.Parsley m_input.Position = 0x10; using (var lz = new LzssStream (m_input.AsStream, LzssMode.Decompress, true)) { + /* int stride = (int)Info.Width * 2; var pixels = new byte[stride * (int)Info.Height]; if (pixels.Length != lz.Read (pixels, 0, pixels.Length)) throw new InvalidFormatException(); + */ + int w2x = (int)Info.Width * 2; + int stride = (w2x + 3) & ~3; + var pixels = new byte[stride * (int)Info.Height]; + for (int dst = 0; dst < pixels.Length; dst += stride) + { + lz.Read (pixels, dst, w2x); + } return ImageData.Create (Info, PixelFormats.Bgr565, null, pixels, stride); } }