mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 20:04:13 +08:00
(BMP): support ancient header format.
This commit is contained in:
parent
fd4563c812
commit
2c7b82535e
@ -114,19 +114,30 @@ namespace GameRes
|
|||||||
if ('B' != c1 || 'M' != c2)
|
if ('B' != c1 || 'M' != c2)
|
||||||
return null;
|
return null;
|
||||||
uint size = file.ReadUInt32();
|
uint size = file.ReadUInt32();
|
||||||
if (size < 14+40)
|
SkipBytes (file, 8);
|
||||||
|
uint header_size = file.ReadUInt32();
|
||||||
|
if (size < 14+header_size)
|
||||||
{
|
{
|
||||||
// some otherwise valid bitmaps have size field set to zero
|
// some otherwise valid bitmaps have size field set to zero
|
||||||
if (size != 0 || !file.AsStream.CanSeek)
|
if (size != 0 || !file.AsStream.CanSeek)
|
||||||
return null;
|
return null;
|
||||||
size = (uint)file.Length;
|
size = (uint)file.Length;
|
||||||
}
|
}
|
||||||
SkipBytes (file, 8);
|
uint width, height;
|
||||||
uint header_size = file.ReadUInt32();
|
if (0xC == header_size)
|
||||||
if (header_size < 40 || size-14 < header_size)
|
{
|
||||||
|
width = file.ReadUInt16();
|
||||||
|
height = file.ReadUInt16();
|
||||||
|
}
|
||||||
|
else if (header_size < 40 || size-14 < header_size)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
uint width = file.ReadUInt32();
|
}
|
||||||
uint height = file.ReadUInt32();
|
else
|
||||||
|
{
|
||||||
|
width = file.ReadUInt32();
|
||||||
|
height = file.ReadUInt32();
|
||||||
|
}
|
||||||
file.ReadInt16();
|
file.ReadInt16();
|
||||||
int bpp = file.ReadInt16();
|
int bpp = file.ReadInt16();
|
||||||
return new BmpMetaData {
|
return new BmpMetaData {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user