(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

@@ -118,17 +118,5 @@ namespace GameRes.Formats.Gs
{
throw new NotImplementedException ("PicFormat.Write not implemented");
}
private static BitmapPalette ReadPalette (Stream input)
{
var colors = new byte[0x400];
if (colors.Length != input.Read (colors, 0, colors.Length))
throw new InvalidFormatException();
var color_data = new Color[0x100];
int n = 0;
for (int i = 0; i < 0x400; i += 4)
color_data[n++] = Color.FromRgb (colors[i+2], colors[i+1], colors[i]);
return new BitmapPalette (color_data);
}
}
}