(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

@@ -179,17 +179,8 @@ namespace GameRes.Formats.Adobe
void ReadPalette (int palette_size)
{
var palette_data = m_input.ReadBytes (palette_size);
if (palette_data.Length != palette_size)
throw new EndOfStreamException();
int colors = Math.Min (256, palette_size/3);
var palette = new Color[colors];
for (int i = 0; i < colors; ++i)
{
int c = i * 3;
palette[i] = Color.FromRgb (palette_data[c], palette_data[c+1], palette_data[c+2]);
}
Palette = new BitmapPalette (palette);
int colors = Math.Min (0x100, palette_size/3);
Palette = ImageFormat.ReadPalette (m_input.AsStream, colors, PaletteFormat.Rgb);
}
byte[] UnpackRLE ()