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


C# Stream.ReadUInt32方法代码示例

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


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

示例1: PakFile

        public PakFile(FileSystem context, string filename)
        {
            Name = filename;
            index = new Dictionary<string, Entry>();

            stream = context.Open(filename);
            try
            {
                index = new Dictionary<string, Entry>();
                var offset = stream.ReadUInt32();
                while (offset != 0)
                {
                    var file = stream.ReadASCIIZ();
                    var next = stream.ReadUInt32();
                    var length = (next == 0 ? (uint)stream.Length : next) - offset;

                    // Ignore duplicate files
                    if (index.ContainsKey(file))
                        continue;

                    index.Add(file, new Entry { Offset = offset, Length = length, Filename = file });
                    offset = next;
                }
            }
            catch
            {
                Dispose();
                throw;
            }
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:30,代码来源:Pak.cs

示例2: HvaReader

        public HvaReader(Stream s)
        {
            // Index swaps for transposing a matrix
            var ids = new byte[] { 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14 };

            s.Seek(16, SeekOrigin.Begin);
            FrameCount = s.ReadUInt32();
            LimbCount = s.ReadUInt32();

            // Skip limb names
            s.Seek(16 * LimbCount, SeekOrigin.Current);
            Transforms = new float[16 * FrameCount * LimbCount];
            for (var j = 0; j < FrameCount; j++)
                for (var i = 0; i < LimbCount; i++)
                {
                    // Convert to column-major matrices and add the final matrix row
                    var c = 16 * (LimbCount * j + i);
                    Transforms[c + 3] = 0;
                    Transforms[c + 7] = 0;
                    Transforms[c + 11] = 0;
                    Transforms[c + 15] = 1;

                    for (var k = 0; k < 12; k++)
                        Transforms[c + ids[k]] = s.ReadFloat();
                }
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:26,代码来源:HvaReader.cs

示例3: IsTmpTD

		bool IsTmpTD(Stream s)
		{
			var start = s.Position;

			s.Position += 16;
			var a = s.ReadUInt32();
			var b = s.ReadUInt32();

			s.Position = start;
			return a == 0 && b == 0x0D1AFFFF;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:11,代码来源:TmpTDLoader.cs

示例4: IdxEntry

        public IdxEntry(Stream s)
        {
            var name = s.ReadASCII(16);
            var pos = name.IndexOf('\0');
            if (pos != 0)
                name = name.Substring(0, pos);

            Filename = string.Concat(name, ".wav");
            Offset = s.ReadUInt32();
            Length = s.ReadUInt32();
            SampleRate = s.ReadUInt32();
            Flags = s.ReadUInt32();
            ChunkSize = s.ReadUInt32();
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:14,代码来源:IdxEntry.cs

示例5: 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

示例6: 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

示例7: 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

示例8: IdxEntry

		public IdxEntry(Stream s)
		{
			var asciiname = s.ReadASCII(16);

			var pos = asciiname.IndexOf('\0');
			if (pos != 0)
				asciiname = asciiname.Substring(0, pos);

			Name = asciiname;
			Extension = DefaultExtension;
			Offset = s.ReadUInt32();
			Length = s.ReadUInt32();
			SampleRate = s.ReadUInt32();
			Flags = s.ReadUInt32();
			ChunkSize = s.ReadUInt32();
			Hash = HashFilename(string.Concat(Name, ".", Extension), PackageHashType.CRC32);
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:17,代码来源:IdxEntry.cs

示例9: Read

 public static ImaAdpcmChunk Read(Stream s)
 {
     ImaAdpcmChunk c;
     c.CompressedSize = s.ReadUInt16();
     c.OutputSize = s.ReadUInt16();
     if (s.ReadUInt32() != 0xdeaf)
         throw new InvalidDataException("Chunk header is bogus");
     return c;
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:9,代码来源:ImaAdpcmLoader.cs

示例10: VxlReader

        public VxlReader(Stream s)
        {
            if (!s.ReadASCII(16).StartsWith("Voxel Animation"))
                throw new InvalidDataException("Invalid vxl header");

            s.ReadUInt32();
            LimbCount = s.ReadUInt32();
            s.ReadUInt32();
            BodySize = s.ReadUInt32();
            s.Seek(770, SeekOrigin.Current);

            // Read Limb headers
            Limbs = new VxlLimb[LimbCount];
            for (var i = 0; i < LimbCount; i++)
            {
                Limbs[i] = new VxlLimb();
                Limbs[i].Name = s.ReadASCII(16);
                s.Seek(12, SeekOrigin.Current);
            }

            // Skip to the Limb footers
            s.Seek(802 + 28*LimbCount + BodySize, SeekOrigin.Begin);

            var LimbDataOffset = new uint[LimbCount];
            for (var i = 0; i < LimbCount; i++)
            {
                LimbDataOffset[i] = s.ReadUInt32();
                s.Seek(8, SeekOrigin.Current);
                Limbs[i].Scale = s.ReadFloat();
                s.Seek(48, SeekOrigin.Current);

                Limbs[i].Bounds = new float[6];
                for (var j = 0; j < 6; j++)
                    Limbs[i].Bounds[j] = s.ReadFloat();
                Limbs[i].Size = s.ReadBytes(3);
                Limbs[i].Type = (NormalType)s.ReadByte();
            }

            for (var i = 0; i < LimbCount; i++)
            {
                s.Seek(802 + 28*LimbCount + LimbDataOffset[i], SeekOrigin.Begin);
                ReadVoxelData(s, Limbs[i]);
            }
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:44,代码来源:VxlReader.cs

示例11: 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

示例12: 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

示例13: IsTmpRA

		bool IsTmpRA(Stream s)
		{
			var start = s.Position;

			s.Position += 20;
			var a = s.ReadUInt32();
			s.Position += 2;
			var b = s.ReadUInt16();

			s.Position = start;
			return a == 0 && b == 0x2c73;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:12,代码来源:TmpRALoader.cs

示例14: ShpTSFrame

			public ShpTSFrame(Stream s, Size frameSize)
			{
				var x = s.ReadUInt16();
				var y = s.ReadUInt16();
				var width = s.ReadUInt16();
				var height = s.ReadUInt16();

				// Pad the dimensions to an even number to avoid issues with half-integer offsets
				var dataWidth = width;
				var dataHeight = height;
				if (dataWidth % 2 == 1)
					dataWidth += 1;

				if (dataHeight % 2 == 1)
					dataHeight += 1;

				Offset = new int2(x + (dataWidth - frameSize.Width) / 2, y + (dataHeight - frameSize.Height) / 2);
				Size = new Size(dataWidth, dataHeight);
				FrameSize = frameSize;

				Format = s.ReadUInt8();
				s.Position += 11;
				FileOffset = s.ReadUInt32();

				if (FileOffset == 0)
					return;

				// Parse the frame data as we go (but remember to jump back to the header before returning!)
				var start = s.Position;
				s.Position = FileOffset;

				Data = new byte[dataWidth * dataHeight];

				if (Format == 3)
				{
					// Format 3 provides RLE-zero compressed scanlines
					for (var j = 0; j < height; j++)
					{
						var length = s.ReadUInt16() - 2;
						Format2.DecodeInto(s.ReadBytes(length), Data, dataWidth * j);
					}
				}
				else
				{
					// Format 2 provides uncompressed length-prefixed scanlines
					// Formats 1 and 0 provide an uncompressed full-width row
					var length = Format == 2 ? s.ReadUInt16() - 2 : width;
					for (var j = 0; j < height; j++)
						s.ReadBytes(Data, dataWidth * j, length);
				}

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

示例15: D2kSoundResources

        public D2kSoundResources(FileSystem context, string filename)
        {
            Name = filename;

            s = context.Open(filename);
            try
            {
                var headerLength = s.ReadUInt32();
                while (s.Position < headerLength + 4)
                {
                    var name = s.ReadASCIIZ();
                    var offset = s.ReadUInt32();
                    var length = s.ReadUInt32();
                    index.Add(name, new Entry(offset, length));
                }
            }
            catch
            {
                Dispose();
                throw;
            }
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:22,代码来源:D2kSoundResources.cs


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