FSO.Files.Formats.IFF.Chunks.DGRPImage.Read C# (CSharp) Méthode

Read() public méthode

Reads a DGRPImage from a stream.
public Read ( uint version, IoBuffer io ) : void
version uint
io FSO.Files.Utils.IoBuffer
Résultat void
        public void Read(uint version, IoBuffer io)
        {
            uint spriteCount = 0;
            if (version < 20003){
                spriteCount = io.ReadUInt16();
                Direction = io.ReadByte();
                Zoom = io.ReadByte();
            }else{
                Direction = io.ReadUInt32();
                Zoom = io.ReadUInt32();
                spriteCount = io.ReadUInt32();
            }

            this.Sprites = new DGRPSprite[spriteCount];
            for (var i = 0; i < spriteCount; i++){
                var sprite = new DGRPSprite(Parent);
                sprite.Read(version, io);
                this.Sprites[i] = sprite;
            }
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Reads a DGRP from a stream instance.
        /// </summary>
        /// <param name="iff">An Iff instance.</param>
        /// <param name="stream">A Stream instance holding a DGRP chunk.</param>
        public override void Read(IffFile iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                var  version    = io.ReadUInt16();
                uint imageCount = version < 20003 ? io.ReadUInt16() : io.ReadUInt32();
                Images = new DGRPImage[imageCount];

                for (var i = 0; i < imageCount; i++)
                {
                    var image = new DGRPImage(this);
                    image.Read(version, io);
                    Images[i] = image;
                }
            }
        }
All Usage Examples Of FSO.Files.Formats.IFF.Chunks.DGRPImage::Read