void Load(BinaryReader reader, int width, int height, PaletteAsset palette, byte format, int[] aux = null, int auxOffset = 0)
{
int[] indices = new int[width * height];
ushort dataSize;
switch (format) {
case 4: // Uncompressed
dataSize = reader.ReadUInt16();
if (width * height != dataSize)
throw new InvalidDataException();
reader.ReadBytesAsInt32(indices, 0, width * height);
break;
case 6: // 5-bit RLE
dataSize = reader.ReadUInt16();
LoadRLE(indices, reader, width, height, 5, aux, auxOffset);
break;
case 8: // 4-bit RLE
if (aux == null)
throw new NotImplementedException("Need to load auxiliary palette.");
dataSize = reader.ReadUInt16();
LoadRLE(indices, reader, width, height, 4, aux, auxOffset);
break;
case 10: // 4-bit aux palette indices.
throw new NotImplementedException("Need to load auxiliary palette.");
default:
throw new NotImplementedException("Unknown graphic format " + format + ".");
}
Setup(palette, width, height, indices);
}