From e3dc84b2d88b24f664876a15bcbb58ffac1e3373 Mon Sep 17 00:00:00 2001 From: morkt Date: Tue, 17 Jan 2017 02:42:09 +0400 Subject: [PATCH] (MCG): some images have size field set to zero. --- ArcFormats/FC01/ImageMCG.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ArcFormats/FC01/ImageMCG.cs b/ArcFormats/FC01/ImageMCG.cs index 9b4a120d..1b6f7a75 100644 --- a/ArcFormats/FC01/ImageMCG.cs +++ b/ArcFormats/FC01/ImageMCG.cs @@ -82,6 +82,7 @@ namespace GameRes.Formats.FC01 int bpp = header.ToInt32 (0x24); if (24 != bpp && 8 != bpp) throw new NotSupportedException ("Not supported MCG image bitdepth"); + int packed_size = header.ToInt32 (0x38); return new McgMetaData { Width = header.ToUInt32 (0x1c), @@ -90,7 +91,7 @@ namespace GameRes.Formats.FC01 OffsetY = header.ToInt32 (0x18), BPP = bpp, DataOffset = header_size, - PackedSize = header.ToInt32 (0x38) - header_size, + PackedSize = packed_size, Version = version, }; } @@ -187,6 +188,9 @@ namespace GameRes.Formats.FC01 { m_file.Position = m_info.DataOffset; int input_size = m_info.PackedSize; + if (0 == input_size) + input_size = (int)m_file.Length; + input_size -= m_info.DataOffset; if (8 == m_info.BPP) { Palette = ImageFormat.ReadPalette (m_file.AsStream);