(DwqBmpReader): fixed indexed images reading.

This commit is contained in:
morkt 2015-11-17 21:21:23 +04:00
parent 2b19069f7c
commit 3f900739f9

View File

@ -124,9 +124,7 @@ namespace GameRes.Formats.BlackCyc
public override ImageData Read (Stream stream, ImageMetaData info) public override ImageData Read (Stream stream, ImageMetaData info)
{ {
var meta = info as DwqMetaData; var meta = (DwqMetaData)info;
if (null == meta)
throw new ArgumentException ("DwqFormat.Read should be supplied with DwqMetaData", "info");
BitmapSource bitmap = null; BitmapSource bitmap = null;
using (var input = new StreamRegion (stream, 0x40, meta.PackedSize, true)) using (var input = new StreamRegion (stream, 0x40, meta.PackedSize, true))
@ -298,6 +296,8 @@ namespace GameRes.Formats.BlackCyc
if (8 == bpp) if (8 == bpp)
{ {
int colors = Math.Min (LittleEndian.ToInt32 (header, 0x2E), 0x100); int colors = Math.Min (LittleEndian.ToInt32 (header, 0x2E), 0x100);
if (0 == colors)
colors = 0x100;
Palette = ReadPalette (m_input, colors); Palette = ReadPalette (m_input, colors);
} }
uint data_position = LittleEndian.ToUInt32 (header, 0xA); uint data_position = LittleEndian.ToUInt32 (header, 0xA);