mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
(MAI4): try default decompression method, fall back to the second one on failure.
This commit is contained in:
@@ -53,7 +53,14 @@ namespace GameRes.Formats.ShiinaRio
|
|||||||
public override ImageData Read (IBinaryStream stream, ImageMetaData info)
|
public override ImageData Read (IBinaryStream stream, ImageMetaData info)
|
||||||
{
|
{
|
||||||
var reader = new Reader (stream, (int)info.Width, (int)info.Height);
|
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);
|
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");
|
throw new System.NotImplementedException ("Mi4Format.Write not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal enum MaiVersion
|
||||||
|
{
|
||||||
|
First, Second
|
||||||
|
}
|
||||||
|
|
||||||
internal sealed class Reader
|
internal sealed class Reader
|
||||||
{
|
{
|
||||||
IBinaryStream m_input;
|
IBinaryStream m_input;
|
||||||
@@ -78,12 +90,15 @@ namespace GameRes.Formats.ShiinaRio
|
|||||||
m_output = new byte[m_stride*height];
|
m_output = new byte[m_stride*height];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unpack ()
|
public void Unpack (MaiVersion version = MaiVersion.First)
|
||||||
{
|
{
|
||||||
m_input.Position = 0x10;
|
m_input.Position = 0x10;
|
||||||
m_bit_count = 0;
|
m_bit_count = 0;
|
||||||
LoadBits();
|
LoadBits();
|
||||||
UnpackV2();
|
if (MaiVersion.First == version)
|
||||||
|
UnpackV1();
|
||||||
|
else
|
||||||
|
UnpackV2();
|
||||||
}
|
}
|
||||||
|
|
||||||
int m_bit_count;
|
int m_bit_count;
|
||||||
|
|||||||
Reference in New Issue
Block a user