public Read ( uint version, |
||
version | uint | |
io | ||
guessedSize | uint | |
Результат | void |
/// <summary> /// Reads a SPR chunk from a stream. /// </summary> /// <param name="iff">An Iff instance.</param> /// <param name="stream">A Stream object holding a SPR chunk.</param> public override void Read(IffFile iff, Stream stream) { using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)) { var version1 = io.ReadUInt16(); var version2 = io.ReadUInt16(); uint version = 0; if (version1 == 0) { io.ByteOrder = ByteOrder.BIG_ENDIAN; version = (uint)(((version2 | 0xFF00) >> 8) | ((version2 & 0xFF) << 8)); } else { version = version1; } ByteOrd = io.ByteOrder; var spriteCount = io.ReadUInt32(); PaletteID = (ushort)io.ReadUInt32(); Frames = new List <SPRFrame>(); if (version != 1001) { var offsetTable = new List <uint>(); for (var i = 0; i < spriteCount; i++) { offsetTable.Add(io.ReadUInt32()); } Offsets = offsetTable; for (var i = 0; i < spriteCount; i++) { var frame = new SPRFrame(this); io.Seek(SeekOrigin.Begin, offsetTable[i]); var guessedSize = ((i + 1 < offsetTable.Count) ? offsetTable[i + 1] : (uint)stream.Length) - offsetTable[i]; frame.Read(version, io, guessedSize); Frames.Add(frame); } } else { while (io.HasMore) { var frame = new SPRFrame(this); frame.Read(version, io, 0); Frames.Add(frame); } } } }
/// <summary> /// Reads a SPR chunk from a stream. /// </summary> /// <param name="iff">An Iff instance.</param> /// <param name="stream">A Stream object holding a SPR chunk.</param> public override void Read(IffFile iff, Stream stream) { using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)) { var version1 = io.ReadUInt16(); var version2 = io.ReadUInt16(); uint version = 0; if (version1 == 0) { io.ByteOrder = ByteOrder.BIG_ENDIAN; version = version2; } else { version = version1; } var spriteCount = io.ReadUInt32(); PaletteID = (ushort)io.ReadUInt32(); Frames = new List<SPRFrame>(); if (version != 1001) { var offsetTable = new List<uint>(); for (var i = 0; i < spriteCount; i++) { offsetTable.Add(io.ReadUInt32()); } for (var i = 0; i < spriteCount; i++) { var frame = new SPRFrame(this); frame.Read(version, io); Frames.Add(frame); } } else { while (io.HasMore) { var frame = new SPRFrame(this); frame.Read(version, io); Frames.Add(frame); } } } }
/// <summary> /// Reads a SPR chunk from a stream. /// </summary> /// <param name="iff">An Iff instance.</param> /// <param name="stream">A Stream object holding a SPR chunk.</param> public override void Read(IffFile iff, Stream stream) { using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)) { var version1 = io.ReadUInt16(); var version2 = io.ReadUInt16(); uint version = 0; if (version1 == 0) { io.ByteOrder = ByteOrder.BIG_ENDIAN; version = version2; } else { version = version1; } var spriteCount = io.ReadUInt32(); PaletteID = (ushort)io.ReadUInt32(); Frames = new List <SPRFrame>(); if (version != 1001) { var offsetTable = new List <uint>(); for (var i = 0; i < spriteCount; i++) { offsetTable.Add(io.ReadUInt32()); } for (var i = 0; i < spriteCount; i++) { var frame = new SPRFrame(this); frame.Read(version, io); Frames.Add(frame); } } else { while (io.HasMore) { var frame = new SPRFrame(this); frame.Read(version, io); Frames.Add(frame); } } } }
/// <summary> /// Reads a SPR chunk from a stream. /// </summary> /// <param name="iff">An Iff instance.</param> /// <param name="stream">A Stream object holding a SPR chunk.</param> public override void Read(IffFile iff, Stream stream) { using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)) { var version1 = io.ReadUInt16(); var version2 = io.ReadUInt16(); uint version = 0; if (version1 == 0) { io.ByteOrder = ByteOrder.BIG_ENDIAN; version = (uint)(((version2|0xFF00)>>8) | ((version2&0xFF)<<8)); } else { version = version1; } ByteOrd = io.ByteOrder; var spriteCount = io.ReadUInt32(); PaletteID = (ushort)io.ReadUInt32(); Frames = new List<SPRFrame>(); if (version != 1001) { var offsetTable = new List<uint>(); for (var i = 0; i < spriteCount; i++) { offsetTable.Add(io.ReadUInt32()); } Offsets = offsetTable; for (var i = 0; i < spriteCount; i++) { var frame = new SPRFrame(this); io.Seek(SeekOrigin.Begin, offsetTable[i]); var guessedSize = ((i + 1 < offsetTable.Count) ? offsetTable[i + 1] : (uint)stream.Length) - offsetTable[i]; frame.Read(version, io, guessedSize); Frames.Add(frame); } } else { while (io.HasMore) { var frame = new SPRFrame(this); frame.Read(version, io, 0); Frames.Add(frame); } } } }