diff --git a/ArcFormats/ShiinaRio/ImageMI4.cs b/ArcFormats/ShiinaRio/ImageMI4.cs index 32e0bbbb..d52b5ece 100644 --- a/ArcFormats/ShiinaRio/ImageMI4.cs +++ b/ArcFormats/ShiinaRio/ImageMI4.cs @@ -53,7 +53,14 @@ namespace GameRes.Formats.ShiinaRio public override ImageData Read (IBinaryStream stream, ImageMetaData info) { var reader = new Reader (stream, (int)info.Width, (int)info.Height); - reader.Unpack(); + try + { + reader.Unpack (MaiVersion.First); + } + catch + { + reader.Unpack (MaiVersion.Second); + } return ImageData.Create (info, PixelFormats.Bgr24, null, reader.Data, reader.Stride); } @@ -62,6 +69,11 @@ namespace GameRes.Formats.ShiinaRio throw new System.NotImplementedException ("Mi4Format.Write not implemented"); } + internal enum MaiVersion + { + First, Second + } + internal sealed class Reader { IBinaryStream m_input; @@ -78,12 +90,15 @@ namespace GameRes.Formats.ShiinaRio m_output = new byte[m_stride*height]; } - public void Unpack () + public void Unpack (MaiVersion version = MaiVersion.First) { m_input.Position = 0x10; m_bit_count = 0; LoadBits(); - UnpackV2(); + if (MaiVersion.First == version) + UnpackV1(); + else + UnpackV2(); } int m_bit_count;