public static Image Load(ByteArrayFileStream stream, ByteArrayStreamReader reader) { Image image = new Image(); image.Width = reader.ReadByte(); image.Height = reader.ReadByte(); image.Red = reader.ReadByte(); image.Green = reader.ReadByte(); image.Blue = reader.ReadByte(); int sprites = image.Width * image.Height; image.sprites = new List <Sprite>(sprites); for (int i = 0; i < sprites; i++) { int index = reader.ReadInt(); if (index > 0) { int returnIndex = stream.Position; stream.Seek(Origin.Begin, index); Sprite sprite = Sprite.Load(true, image.Red, image.Green, image.Blue, reader); image.sprites.Add(sprite); stream.Seek(Origin.Begin, returnIndex); } } return(image); }
public static SprFile Load(string path) { using (ByteArrayFileStream stream = new ByteArrayFileStream(path)) { ByteArrayStreamReader reader = new ByteArrayStreamReader(stream); SprFile file = new SprFile(); file.signature = reader.ReadUInt(); ushort sprites = reader.ReadUShort(); file.sprites = new List <Sprite>(sprites); for (ushort spriteId = 1; spriteId <= sprites; spriteId++) { int index = reader.ReadInt(); if (index > 0) { int returnIndex = stream.Position; stream.Seek(Origin.Begin, index); Sprite sprite = Sprite.Load(true, reader); sprite.Id = spriteId; file.sprites.Add(sprite); stream.Seek(Origin.Begin, returnIndex); } } return(file); } }