mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
(gpd, msk): recognize earlier format versions.
This commit is contained in:
@@ -30,6 +30,11 @@ using GameRes.Compression;
|
|||||||
|
|
||||||
namespace GameRes.Formats.Ankh
|
namespace GameRes.Formats.Ankh
|
||||||
{
|
{
|
||||||
|
internal class GpdMetaData : ImageMetaData
|
||||||
|
{
|
||||||
|
public int HeaderSize;
|
||||||
|
}
|
||||||
|
|
||||||
[Export(typeof(ImageFormat))]
|
[Export(typeof(ImageFormat))]
|
||||||
public class GpdFormat : ImageFormat
|
public class GpdFormat : ImageFormat
|
||||||
{
|
{
|
||||||
@@ -40,19 +45,19 @@ namespace GameRes.Formats.Ankh
|
|||||||
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
||||||
{
|
{
|
||||||
var header = file.ReadHeader (0x10);
|
var header = file.ReadHeader (0x10);
|
||||||
if (header.ToInt32 (12) != 0)
|
return new GpdMetaData {
|
||||||
return null;
|
|
||||||
return new ImageMetaData {
|
|
||||||
Width = header.ToUInt32 (4),
|
Width = header.ToUInt32 (4),
|
||||||
Height = header.ToUInt32 (8),
|
Height = header.ToUInt32 (8),
|
||||||
BPP = 24,
|
BPP = 24,
|
||||||
|
HeaderSize = header.ToInt32 (12) != 0 ? 12 : 16,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ImageData Read (IBinaryStream file, ImageMetaData info)
|
public override ImageData Read (IBinaryStream file, ImageMetaData info)
|
||||||
{
|
{
|
||||||
|
var meta = (GpdMetaData)info;
|
||||||
int stride = (int)info.Width * 3;
|
int stride = (int)info.Width * 3;
|
||||||
file.Position = 0x10;
|
file.Position = meta.HeaderSize;
|
||||||
using (var lzss = new LzssStream (file.AsStream, LzssMode.Decompress, true))
|
using (var lzss = new LzssStream (file.AsStream, LzssMode.Decompress, true))
|
||||||
{
|
{
|
||||||
var pixels = new byte[stride * (int)info.Height];
|
var pixels = new byte[stride * (int)info.Height];
|
||||||
|
|||||||
@@ -40,18 +40,18 @@ namespace GameRes.Formats.Ankh
|
|||||||
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
||||||
{
|
{
|
||||||
var header = file.ReadHeader (0x10);
|
var header = file.ReadHeader (0x10);
|
||||||
if (header.ToInt32 (12) != 0)
|
return new GpdMetaData {
|
||||||
return null;
|
|
||||||
return new ImageMetaData {
|
|
||||||
Width = header.ToUInt32 (4),
|
Width = header.ToUInt32 (4),
|
||||||
Height = header.ToUInt32 (8),
|
Height = header.ToUInt32 (8),
|
||||||
BPP = 8,
|
BPP = 8,
|
||||||
|
HeaderSize = header.ToInt32 (12) != 0 ? 12 : 16,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ImageData Read (IBinaryStream file, ImageMetaData info)
|
public override ImageData Read (IBinaryStream file, ImageMetaData info)
|
||||||
{
|
{
|
||||||
file.Position = 0x10;
|
var meta = (GpdMetaData)info;
|
||||||
|
file.Position = meta.HeaderSize;
|
||||||
using (var lzss = new LzssStream (file.AsStream, LzssMode.Decompress, true))
|
using (var lzss = new LzssStream (file.AsStream, LzssMode.Decompress, true))
|
||||||
{
|
{
|
||||||
var pixels = new byte[info.Width * info.Height];
|
var pixels = new byte[info.Width * info.Height];
|
||||||
|
|||||||
Reference in New Issue
Block a user