(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

@@ -126,7 +126,7 @@ namespace GameRes.Formats.Vitamin
int input_size = m_info.InputSize - 0x20;
if (m_info.HasPalette)
{
ReadPalette();
Palette = ImageFormat.ReadPalette (m_input.AsStream, 0x100, PaletteFormat.Rgb);
input_size -= 0x300;
}
int x = 0;
@@ -188,20 +188,6 @@ namespace GameRes.Formats.Vitamin
}
}
void ReadPalette ()
{
var palette_data = m_input.ReadBytes (0x300);
if (palette_data.Length != 0x300)
throw new EndOfStreamException();
var palette = new Color[0x100];
for (int i = 0; i < 0x100; ++i)
{
int c = i * 3;
palette[i] = Color.FromRgb (palette_data[c], palette_data[c+1], palette_data[c+2]);
}
Palette = new BitmapPalette (palette);
}
#region IDisposable Members
public void Dispose ()
{