mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
(ImageFormat.ReadPalette): new static methods.
Generalized image palette deserializations.
This commit is contained in:
@@ -69,7 +69,7 @@ namespace GameRes.Formats.FC01
|
||||
BitmapPalette palette = null;
|
||||
if (8 == bpp)
|
||||
{
|
||||
palette = ReadPalette (file, index_offset);
|
||||
palette = ImageFormat.ReadPalette (file, index_offset);
|
||||
index_offset += 0x400;
|
||||
}
|
||||
string base_name = Path.GetFileNameWithoutExtension (file.Name);
|
||||
@@ -112,19 +112,6 @@ namespace GameRes.Formats.FC01
|
||||
}
|
||||
}
|
||||
|
||||
BitmapPalette ReadPalette (ArcView file, uint offset)
|
||||
{
|
||||
var palette = file.View.ReadBytes (offset, 0x400);
|
||||
int src = 0;
|
||||
var colors = new Color[0x100];
|
||||
for (int i = 0; i < 0x100; ++i)
|
||||
{
|
||||
colors[i] = Color.FromRgb (palette[src+2], palette[src+1], palette[src]);
|
||||
src += 4;
|
||||
}
|
||||
return new BitmapPalette (colors);
|
||||
}
|
||||
|
||||
public override ResourceOptions GetDefaultOptions ()
|
||||
{
|
||||
return new McgOptions { Key = Settings.Default.MCGLastKey };
|
||||
|
||||
@@ -92,20 +92,6 @@ namespace GameRes.Formats.FC01
|
||||
}
|
||||
}
|
||||
|
||||
BitmapPalette ReadPalette (Stream input)
|
||||
{
|
||||
var palette_data = new byte[0x400];
|
||||
if (palette_data.Length != input.Read (palette_data, 0, palette_data.Length))
|
||||
throw new InvalidFormatException();
|
||||
var palette = new Color[0x100];
|
||||
for (int i = 0; i < palette.Length; ++i)
|
||||
{
|
||||
int c = i * 4;
|
||||
palette[i] = Color.FromRgb (palette_data[c+2], palette_data[c+1], palette_data[c]);
|
||||
}
|
||||
return new BitmapPalette (palette);
|
||||
}
|
||||
|
||||
public override void Write (Stream file, ImageData image)
|
||||
{
|
||||
throw new System.NotImplementedException ("ClmFormat.Write not implemented");
|
||||
|
||||
Reference in New Issue
Block a user