(ImageFormat.ReadPalette): new static methods.

Generalized image palette deserializations.
This commit is contained in:
morkt
2017-01-14 16:27:11 +04:00
parent 832a1a3ff0
commit 13cf289bae
25 changed files with 87 additions and 331 deletions

View File

@@ -82,25 +82,12 @@ namespace GameRes.Formats.Eushully
if (8 == info.SourceBPP)
{
reader.Read (header, 0, 0x18); // skip rest of the header
info.Palette = ReadPalette (reader.BaseStream);
info.Palette = ReadColorMap (reader.BaseStream);
}
return info;
}
}
static Color[] ReadPalette (Stream input)
{
var palette_data = new byte[0x400];
if (0x400 != input.Read (palette_data, 0, 0x400))
throw new EndOfStreamException();
var palette = new Color[0x100];
for (int i = 0; i < palette.Length; ++i)
{
palette[i] = Color.FromRgb (palette_data[i*4+2], palette_data[i*4+1], palette_data[i*4]);
}
return palette;
}
public override ImageData Read (IBinaryStream stream, ImageMetaData info)
{
using (var reader = new AgfReader (stream, (AgfMetaData)info))