FSO.Files.Formats.IFF.Chunks.SPRFrame.Read C# (CSharp) Method

Read() public method

Reads a SPRFrame from a stream.
public Read ( uint version, IoBuffer io, uint guessedSize ) : void
version uint
io FSO.Files.Utils.IoBuffer
guessedSize uint
return void
        public void Read(uint version, IoBuffer io, uint guessedSize)
        {
            if (version == 1001)
            {
                var spriteFersion = io.ReadUInt32();

                var size = io.ReadUInt32();
                this.Version = spriteFersion;

                if (IffFile.RETAIN_CHUNK_DATA) ReadDeferred(1001, io);
                else ToDecode = io.ReadBytes(size);
            }
            else
            {
                this.Version = version;
                if (IffFile.RETAIN_CHUNK_DATA) ReadDeferred(1000, io);
                else ToDecode = io.ReadBytes(guessedSize);
            }
        }

Usage Example

示例#1
0
文件: SPR.cs 项目: jwofles/ForkSO
        /// <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);
                    }
                }
            }
        }
All Usage Examples Of FSO.Files.Formats.IFF.Chunks.SPRFrame::Read