当前位置: 首页>>代码示例>>C#>>正文


C# Stream.ReadInt32方法代码示例

本文整理汇总了C#中System.IO.Stream.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ReadInt32方法的具体用法?C# Stream.ReadInt32怎么用?C# Stream.ReadInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.Stream的用法示例。


在下文中一共展示了Stream.ReadInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TmpTDReader

		public TmpTDReader(Stream s)
		{
			var width = s.ReadUInt16();
			var height = s.ReadUInt16();
			var size = new Size(width, height);

			s.Position += 8;
			var imgStart = s.ReadUInt32();
			s.Position += 8;
			var indexEnd = s.ReadInt32();
			var indexStart = s.ReadInt32();

			s.Position = indexStart;
			var count = indexEnd - indexStart;
			var tiles = new TmpTile[count];
			Frames = tiles.AsReadOnly();
			var tilesIndex = 0;
			foreach (var b in s.ReadBytes(count))
			{
				if (b != 255)
				{
					s.Position = imgStart + b * width * height;
					tiles[tilesIndex++] = new TmpTile(s.ReadBytes(width * height), size);
				}
				else
					tiles[tilesIndex++] = new TmpTile(null, size);
			}
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:28,代码来源:TmpTDReader.cs

示例2: ParseFrames

		TmpRAFrame[] ParseFrames(Stream s)
		{
			var start = s.Position;
			var width = s.ReadUInt16();
			var height = s.ReadUInt16();
			var size = new Size(width, height);

			s.Position += 12;
			var imgStart = s.ReadUInt32();
			s.Position += 8;
			var indexEnd = s.ReadInt32();
			s.Position += 4;
			var indexStart = s.ReadInt32();

			s.Position = indexStart;
			var count = indexEnd - indexStart;
			var tiles = new TmpRAFrame[count];

			var tilesIndex = 0;
			foreach (var b in s.ReadBytes(count))
			{
				if (b != 255)
				{
					s.Position = imgStart + b * width * height;
					tiles[tilesIndex++] = new TmpRAFrame(s.ReadBytes(width * height), size);
				}
				else
					tiles[tilesIndex++] = new TmpRAFrame(null, size);
			}

			s.Position = start;
			return tiles;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:33,代码来源:TmpRALoader.cs

示例3: TmpRAReader

        public TmpRAReader(Stream s)
        {
            var width = s.ReadUInt16();
            var height = s.ReadUInt16();
            var size = new Size(width, height);

            s.Position += 12;
            var imgStart = s.ReadUInt32();
            s.Position += 8;
            var indexEnd = s.ReadInt32();
            s.Position += 4;
            var indexStart = s.ReadInt32();

            s.Position = indexStart;
            foreach (byte b in s.ReadBytes(indexEnd - indexStart))
            {
                if (b != 255)
                {
                    s.Position = imgStart + b * width * height;
                    tiles.Add(new TmpTile(s.ReadBytes(width * height), size));
                }
                else
                    tiles.Add(new TmpTile(null, size));
            }
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:25,代码来源:TmpRAReader.cs

示例4: Read

        public void Read(Stream stream)
        {
            this.ChannelCount = stream.ReadInt32();
            this.BitsPerSample = stream.ReadInt32();
            this.SampleRate = stream.ReadInt32();
            this.FinalSampleCount = stream.ReadInt64();

            this.OutputFormat = stream.ReadString();
            this.CompressionLevel = stream.ReadInt32();
        }
开发者ID:karamanolev,项目名称:MusicDatabase,代码行数:10,代码来源:EncodingRequestMessage.cs

示例5: NpgsqlBackEndKeyData

        public NpgsqlBackEndKeyData(Stream stream)
        {
            // Read the BackendKeyData message contents. Two Int32 integers = 8 Bytes.
            // For protocol version 3.0 they are three integers. The first one is just the size of message
            // so, just read it.
            stream.EatStreamBytes(4);

            ProcessID = stream.ReadInt32();
            SecretKey = stream.ReadInt32();
        }
开发者ID:timoch,项目名称:Npgsql-fdb,代码行数:10,代码来源:NpgsqlBackEndKeyData.cs

示例6: Terrain

        public Terrain(Stream s)
        {
            // Try loading as a cnc .tem
            Width = s.ReadUInt16();
            Height = s.ReadUInt16();

            /*NumTiles = */s.ReadUInt16();
            /*Zero1 = */s.ReadUInt16();
            /*uint Size = */s.ReadUInt32();
            var imgStart = s.ReadUInt32();
            /*Zero2 = */s.ReadUInt32();

            int indexEnd, indexStart;

            // ID1 = FFFFh for cnc
            if (s.ReadUInt16() == 65535)
            {
                /*ID2 = */s.ReadUInt16();
                indexEnd = s.ReadInt32();
                indexStart = s.ReadInt32();
            }
            else
            {
                // Load as a ra .tem
                s.Position = 0;
                Width = s.ReadUInt16();
                Height = s.ReadUInt16();

                /*NumTiles = */s.ReadUInt16();
                s.ReadUInt16();
                /*XDim = */s.ReadUInt16();
                /*YDim = */s.ReadUInt16();
                /*uint FileSize = */s.ReadUInt32();
                imgStart = s.ReadUInt32();
                s.ReadUInt32();
                s.ReadUInt32();
                indexEnd = s.ReadInt32();
                s.ReadUInt32();
                indexStart = s.ReadInt32();
            }

            s.Position = indexStart;

            foreach (byte b in s.ReadBytes(indexEnd - indexStart))
            {
                if (b != 255)
                {
                    s.Position = imgStart + b * Width * Height;
                    TileBitmapBytes.Add(s.ReadBytes(Width * Height));
                }
                else
                    TileBitmapBytes.Add(null);
            }
        }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:54,代码来源:Terrain.cs

示例7: Read

        public int unknown2; // 4 bytes, 1

        #endregion Fields

        #region Methods

        internal static W2Save Read(Stream stream)
        {
            // ReSharper disable UseObjectOrCollectionInitializer
            var result = new W2Save();
            // ReSharper restore UseObjectOrCollectionInitializer
            result.header = stream.ReadUtf8String(4);
            result.unknown1 = stream.ReadInt32();
            result.unknown2 = stream.ReadInt32();
            result.section = Section.Read(stream).ToList();

            foreach (var sec in result.section)
                sec.ReadData(stream);
            return result;
        }
开发者ID:13xforever,项目名称:Witcher-2-Save-Editor,代码行数:20,代码来源:W2Save.cs

示例8: TmpTSReader

		public TmpTSReader(Stream s)
		{
			var templateWidth = s.ReadUInt32();
			var templateHeight = s.ReadUInt32();
			var tileWidth = s.ReadInt32();
			var tileHeight = s.ReadInt32();
			var size = new Size(tileWidth, tileHeight);
			var offsets = new uint[templateWidth * templateHeight];
			for (var i = 0; i < offsets.Length; i++)
				offsets[i] = s.ReadUInt32();

			var tiles = new List<TmpTSTile>();
			for (var i = 0; i < offsets.Length; i++)
			{
				s.Position = offsets[i];
				tiles.Add(new TmpTSTile(s, size));
			}

			Frames = tiles.ToArray().AsReadOnly();
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:20,代码来源:TmpTSReader.cs

示例9: IdxReader

        public IdxReader(Stream s)
        {
            s.Seek(0, SeekOrigin.Begin);

            var id = s.ReadASCII(4);

            if (id != "GABA")
                throw new InvalidDataException("Unable to load Idx file, did not find magic id, found {0} instead".F(id));

            var two = s.ReadInt32();

            if (two != 2)
                throw new InvalidDataException("Unable to load Idx file, did not find magic number 2, found {0} instead".F(two));

            SoundCount = s.ReadInt32();

            Entries = new List<IdxEntry>();

            for (var i = 0; i < SoundCount; i++)
                Entries.Add(new IdxEntry(s));
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:21,代码来源:IdxReader.cs

示例10: R8Image

        public R8Image(Stream s)
        {
            // Scan forward until we find some data
            var type = s.ReadUInt8();
            while (type == 0)
                type = s.ReadUInt8();

            var width = s.ReadInt32();
            var height = s.ReadInt32();
            var x = s.ReadInt32();
            var y = s.ReadInt32();

            Size = new Size(width, height);
            Offset = new int2(width/2 - x, height/2 - y);

            /*var imageOffset = */s.ReadInt32();
            var paletteOffset = s.ReadInt32();
            var bpp = s.ReadUInt8();
            if (bpp != 8)
                throw new InvalidDataException("Error: {0} bits per pixel are not supported.".F(bpp));

            var frameHeight = s.ReadUInt8();
            var frameWidth = s.ReadUInt8();
            FrameSize = new Size(frameWidth, frameHeight);

            // Skip alignment byte
            s.ReadUInt8();

            Data = s.ReadBytes(width*height);

            // Ignore palette
            if (type == 1 && paletteOffset != 0)
                s.Seek(520, SeekOrigin.Current);
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:34,代码来源:R8Reader.cs

示例11: Read

        internal static IEnumerable<Section> Read(Stream stream)
        {
            for (var i = 0; i < 32; i++)
            {
                // ReSharper disable UseObjectOrCollectionInitializer
                var result = new Section();
                // ReSharper restore UseObjectOrCollectionInitializer
                result.name = stream.ReadUtf8String(32).TrimEnd(char.MinValue);
                if (string.IsNullOrEmpty(result.name)) yield break;

                result.offset = stream.ReadInt32();
                yield return result;
            }
        }
开发者ID:13xforever,项目名称:Witcher-2-Save-Editor,代码行数:14,代码来源:Section.cs

示例12: Read

        public static Blck Read(Stream stream)
        {
            var result = new Blck();
            var b = (byte)stream.ReadByte();
            result.unknown = (b & 0x80) == 0x80;
            if (!result.unknown) throw new UnknownNodeFlagException();

            result.nameLength = (short)(b & 0x7f);
            result.name = stream.ReadUtf8String(result.nameLength);

            result.length = stream.ReadInt32();
            using (var memStream = new MemoryStream(stream.ReadBytes(result.length)))
                result.children = Aval.Read(memStream).ToList();

            return result;
        }
开发者ID:13xforever,项目名称:Witcher-2-Save-Editor,代码行数:16,代码来源:Blck.cs

示例13: XccGlobalDatabase

        public XccGlobalDatabase(Stream s)
        {
            var entries = new List<string>();
            while (s.Peek() > -1)
            {
                var count = s.ReadInt32();
                for (var i = 0; i < count; i++)
                {
                    var chars = new List<char>();
                    byte c;

                    // Read filename
                    while ((c = s.ReadUInt8()) != 0)
                        chars.Add((char)c);
                    entries.Add(new string(chars.ToArray()));

                    // Skip comment
                    while ((c = s.ReadUInt8()) != 0) { }
                }
            }

            Entries = entries.ToArray();
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:23,代码来源:XccGlobalDatabase.cs

示例14: ReadVoxelData

        void ReadVoxelData(Stream s, VxlLimb l)
        {
            var baseSize = l.Size[0]*l.Size[1];
            var colStart = new int[baseSize];
            for (var i = 0; i < baseSize; i++)
                colStart[i] = s.ReadInt32();
            s.Seek(4*baseSize, SeekOrigin.Current);
            var dataStart = s.Position;

            // Count the voxels in this limb
            l.VoxelCount = 0;
            for (var i = 0; i < baseSize; i++)
            {
                // Empty column
                if (colStart[i] == -1)
                    continue;

                s.Seek(dataStart + colStart[i], SeekOrigin.Begin);
                var z = 0;
                do
                {
                    z += s.ReadUInt8();
                    var count = s.ReadUInt8();
                    z += count;
                    l.VoxelCount += count;
                    s.Seek(2*count + 1, SeekOrigin.Current);
                } while (z < l.Size[2]);
            }

            // Read the data
            l.VoxelMap = new Dictionary<byte, VxlElement>[l.Size[0],l.Size[1]];
            for (var i = 0; i < baseSize; i++)
            {
                // Empty column
                if (colStart[i] == -1)
                    continue;

                s.Seek(dataStart + colStart[i], SeekOrigin.Begin);

                byte x = (byte)(i % l.Size[0]);
                byte y = (byte)(i / l.Size[0]);
                byte z = 0;
                l.VoxelMap[x,y] = new Dictionary<byte, VxlElement>();
                do
                {
                    z += s.ReadUInt8();
                    var count = s.ReadUInt8();
                    for (var j = 0; j < count; j++)
                    {
                        var v = new VxlElement();
                        v.Color = s.ReadUInt8();
                        v.Normal = s.ReadUInt8();

                        l.VoxelMap[x,y].Add(z, v);
                        z++;
                    }
                    // Skip duplicate count
                    s.ReadUInt8();
                } while (z < l.Size[2]);
            }
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:61,代码来源:VxlReader.cs

示例15: AuthenticateAsClient

        public bool AuthenticateAsClient(Stream stream, byte[] additionalChallenge = null)
        {
            if (additionalChallenge == null)
                additionalChallenge = new byte[] { };

            byte[] clientNonce = m_nonce.Next();
            stream.WriteWithLength(m_usernameBytes);
            stream.WriteWithLength(clientNonce);
            stream.Flush();

            HashMethod hashMethod = (HashMethod)stream.ReadByte();
            byte[] serverNonce = stream.ReadBytes();
            byte[] salt = stream.ReadBytes();
            int iterations = stream.ReadInt32();

            SetServerValues(hashMethod, salt, iterations);

            byte[] authMessage = Scram.ComputeAuthMessage(serverNonce, clientNonce, salt, m_usernameBytes, iterations, additionalChallenge);
            byte[] clientSignature = ComputeClientSignature(authMessage);
            byte[] clientProof = Scram.XOR(m_clientKey, clientSignature);
            stream.WriteWithLength(clientProof);
            stream.Flush();

            byte[] serverSignature = ComputeServerSignature(authMessage);
            byte[] serverSignatureVerify = stream.ReadBytes();
            return (serverSignature.SecureEquals(serverSignatureVerify));
        }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:27,代码来源:ScramClient.cs


注:本文中的System.IO.Stream.ReadInt32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。