mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 21:55:34 +08:00
(GPS): alterantive header.
This commit is contained in:
parent
ae7db58c11
commit
5e3981523b
@ -35,6 +35,7 @@ namespace GameRes.Formats.Abel
|
|||||||
internal class GpsMetaData : ImageMetaData
|
internal class GpsMetaData : ImageMetaData
|
||||||
{
|
{
|
||||||
public byte Compression;
|
public byte Compression;
|
||||||
|
public int HeaderSize;
|
||||||
public int PackedSize;
|
public int PackedSize;
|
||||||
public int UnpackedSize;
|
public int UnpackedSize;
|
||||||
}
|
}
|
||||||
@ -55,16 +56,24 @@ namespace GameRes.Formats.Abel
|
|||||||
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
||||||
{
|
{
|
||||||
var header = file.ReadHeader (0x29);
|
var header = file.ReadHeader (0x29);
|
||||||
if (header.Length != 0x29)
|
var gps = new GpsMetaData();
|
||||||
return null;
|
if (header.ToUInt32 (4) == 0xCCCCCCCC)
|
||||||
var gps = new GpsMetaData
|
|
||||||
{
|
{
|
||||||
Width = header.ToUInt32 (0x19),
|
gps.HeaderSize = 0x19;
|
||||||
Height = header.ToUInt32 (0x1D),
|
gps.Compression = 2;
|
||||||
Compression = header[0x10],
|
gps.UnpackedSize = header.ToInt32 (0x9);
|
||||||
UnpackedSize = header.ToInt32 (0x11),
|
gps.PackedSize = header.ToInt32 (0xD);
|
||||||
PackedSize = header.ToInt32 (0x15),
|
}
|
||||||
};
|
else
|
||||||
|
{
|
||||||
|
gps.HeaderSize = 0x29;
|
||||||
|
gps.Compression = header[0x10];
|
||||||
|
gps.UnpackedSize = header.ToInt32 (0x11);
|
||||||
|
gps.PackedSize = header.ToInt32 (0x15);
|
||||||
|
gps.Width = header.ToUInt32 (0x19);
|
||||||
|
gps.Height = header.ToUInt32 (0x1D);
|
||||||
|
}
|
||||||
|
file.Position = gps.HeaderSize;
|
||||||
// read BMP header
|
// read BMP header
|
||||||
using (var stream = OpenGpsStream (file, gps.Compression, 0x54))
|
using (var stream = OpenGpsStream (file, gps.Compression, 0x54))
|
||||||
using (var input = BinaryStream.FromStream (stream, file.Name))
|
using (var input = BinaryStream.FromStream (stream, file.Name))
|
||||||
@ -73,6 +82,8 @@ namespace GameRes.Formats.Abel
|
|||||||
if (null == bmp_info)
|
if (null == bmp_info)
|
||||||
return null;
|
return null;
|
||||||
gps.BPP = bmp_info.BPP;
|
gps.BPP = bmp_info.BPP;
|
||||||
|
gps.Width = bmp_info.Width;
|
||||||
|
gps.Height = bmp_info.Height;
|
||||||
return gps;
|
return gps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,7 +91,7 @@ namespace GameRes.Formats.Abel
|
|||||||
public override ImageData Read (IBinaryStream file, ImageMetaData info)
|
public override ImageData Read (IBinaryStream file, ImageMetaData info)
|
||||||
{
|
{
|
||||||
var gps = (GpsMetaData)info;
|
var gps = (GpsMetaData)info;
|
||||||
file.Position = 0x29;
|
file.Position = gps.HeaderSize;
|
||||||
using (var stream = OpenGpsStream (file, gps.Compression, gps.UnpackedSize))
|
using (var stream = OpenGpsStream (file, gps.Compression, gps.UnpackedSize))
|
||||||
using (var input = BinaryStream.FromStream (stream, file.Name))
|
using (var input = BinaryStream.FromStream (stream, file.Name))
|
||||||
return Bmp.Read (input, info);
|
return Bmp.Read (input, info);
|
||||||
|
Loading…
Reference in New Issue
Block a user