mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 20:39:29 +08:00
(DwqFormat): added 'IF PACKTYPE==' format variation.
This commit is contained in:
parent
2eea046139
commit
ce7cd94814
@ -84,6 +84,7 @@ namespace GameRes.Formats.BlackCyc
|
||||
0x20474E50, // PNG
|
||||
0x4B434150, // PACKBMP
|
||||
0x2B504D42, // BMP+MASK
|
||||
0x50204649, // IF PACKTYPE==0 CUT THIS 64 BYTETHEN REMAKE BMP
|
||||
};
|
||||
}
|
||||
|
||||
@ -92,6 +93,29 @@ namespace GameRes.Formats.BlackCyc
|
||||
var header = ResourceHeader.Read (stream);
|
||||
if (null == header)
|
||||
return null;
|
||||
if (Binary.AsciiEqual (header.Bytes, "IF PACKTYPE=="))
|
||||
{
|
||||
if (!Binary.AsciiEqual (header.Bytes, 0x0D, "0 ") ||
|
||||
!Binary.AsciiEqual (header.Bytes, 0x2C, "BMP ") ||
|
||||
header.PackType != 0)
|
||||
return null;
|
||||
using (var bmp = new StreamRegion (stream, 0x40, true))
|
||||
{
|
||||
var info = Bmp.ReadMetaData (bmp);
|
||||
if (null == info)
|
||||
return null;
|
||||
return new DwqMetaData
|
||||
{
|
||||
Width = info.Width,
|
||||
Height = info.Height,
|
||||
BPP = info.BPP,
|
||||
BaseType = "BMP",
|
||||
PackedSize = (int)(stream.Length-0x40),
|
||||
PackType = header.PackType,
|
||||
AType = header.AType,
|
||||
};
|
||||
}
|
||||
}
|
||||
int packed_size;
|
||||
switch (header.PackType)
|
||||
{
|
||||
@ -165,7 +189,9 @@ namespace GameRes.Formats.BlackCyc
|
||||
if (meta.AType)
|
||||
{
|
||||
int mask_offset = 0x40+meta.PackedSize;
|
||||
using (var mask = new StreamRegion (stream, mask_offset, stream.Length-mask_offset, true))
|
||||
if (mask_offset != stream.Length)
|
||||
{
|
||||
using (var mask = new StreamRegion (stream, mask_offset, true))
|
||||
{
|
||||
var reader = new DwqBmpReader (mask, meta);
|
||||
if (8 == reader.Format.BitsPerPixel) // mask should be represented as 8bpp bitmap
|
||||
@ -183,6 +209,7 @@ namespace GameRes.Formats.BlackCyc
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bitmap.Freeze();
|
||||
return new ImageData (bitmap, meta);
|
||||
}
|
||||
@ -281,7 +308,7 @@ namespace GameRes.Formats.BlackCyc
|
||||
throw new InvalidFormatException();
|
||||
int w = LittleEndian.ToInt32 (header, 0x12);
|
||||
int h = LittleEndian.ToInt32 (header, 0x16);
|
||||
if (w != m_width || h != m_height)
|
||||
if (w != m_width || Math.Abs (h) != m_height)
|
||||
throw new InvalidFormatException();
|
||||
|
||||
int bpp = LittleEndian.ToUInt16 (header, 0x1C);
|
||||
|
Loading…
x
Reference in New Issue
Block a user