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


C# MemoryStream.ReadUInt8方法代码示例

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


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

示例1: HIRCSection

        public HIRCSection(byte[] data)
        {
            Data = data;

            using (MemoryStream s = new MemoryStream(data))
            {
                UInt32 objectCount = s.ReadUInt32();
                for (int i = 0; i < objectCount; i++)
                {
                    Console.Write("HIRC object at: {0:X}", s.Position);
                    HIRCType type = (HIRCType)s.ReadUInt8();
                    UInt32 length = s.ReadUInt32();
                    byte[] buffer = new byte[length];
                    s.Read(buffer, 0, (int)length);

                    Console.WriteLine(" Type {0} Length {1:X}", type, length);

                    IHIRCObject obj = HIRCObject.GetObject(type, buffer);
                    Objects.Add(obj);
                }
            }
        }
开发者ID:rodrigonh,项目名称:ThomasJepp.SaintsRow,代码行数:22,代码来源:HIRCSection.cs

示例2: LoadImaAdpcmSound

		public static byte[] LoadImaAdpcmSound(byte[] raw, ref int index, ref int currentSample)
		{
			var s = new MemoryStream(raw);
			var dataSize = raw.Length;
			var outputSize = raw.Length * 4;

			var output = new byte[outputSize];
			var offset = 0;

			while (dataSize-- > 0)
			{
				var b = s.ReadUInt8();

				var t = DecodeImaAdpcmSample(b, ref index, ref currentSample);
				output[offset++] = (byte)t;
				output[offset++] = (byte)(t >> 8);

				t = DecodeImaAdpcmSample((byte)(b >> 4), ref index, ref currentSample);
				output[offset++] = (byte)t;
				output[offset++] = (byte)(t >> 8);
			}

			return output;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:24,代码来源:ImaAdpcmLoader.cs

示例3: UnpackRAOverlayData

		void UnpackRAOverlayData(MemoryStream ms)
		{
			for (var j = 0; j < mapSize; j++)
			{
				for (var i = 0; i < mapSize; i++)
				{
					var o = ms.ReadUInt8();
					var res = Pair.New((byte)0, (byte)0);

					if (o != 255 && overlayResourceMapping.ContainsKey(redAlertOverlayNames[o]))
						res = overlayResourceMapping[redAlertOverlayNames[o]];

					var cell = new CPos(i, j);
					map.MapResources.Value[cell] = new ResourceTile(res.First, res.Second);

					if (o != 255 && overlayActorMapping.ContainsKey(redAlertOverlayNames[o]))
					{
						var ar = new ActorReference(overlayActorMapping[redAlertOverlayNames[o]])
						{
							new LocationInit(cell),
							new OwnerInit("Neutral")
						};

						map.ActorDefinitions.Add(new MiniYamlNode("Actor" + actorCount++, ar.Save()));
					}
				}
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:28,代码来源:LegacyMapImporter.cs

示例4: UnpackRATileData

		void UnpackRATileData(MemoryStream ms)
		{
			var types = new ushort[mapSize, mapSize];
			for (var j = 0; j < mapSize; j++)
			{
				for (var i = 0; i < mapSize; i++)
				{
					var tileID = ms.ReadUInt16();
					types[i, j] = tileID == (ushort)0 ? (ushort)255 : tileID; // RAED weirdness
				}
			}

			for (var j = 0; j < mapSize; j++)
				for (var i = 0; i < mapSize; i++)
					map.MapTiles.Value[new CPos(i, j)] = new TerrainTile(types[i, j], ms.ReadUInt8());
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:16,代码来源:LegacyMapImporter.cs

示例5: DecodeImaAdpcmData

        public byte[] DecodeImaAdpcmData()
        {
            var s = new MemoryStream(RawOutput);

            var numBlocks = DataSize / BlockAlign;
            var blockDataSize = BlockAlign - (Channels * 4);
            var outputSize = UncompressedSize * Channels * 2;

            var outOffset = 0;
            var output = new byte[outputSize];

            var predictor = new int[Channels];
            var index = new int[Channels];

            // Decode each block of IMA ADPCM data in RawOutput
            for (var block = 0; block < numBlocks; block++)
            {
                // Each block starts with a initial state per-channel
                for (var c = 0; c < Channels; c++)
                {
                    predictor[c] = s.ReadInt16();
                    index[c] = s.ReadUInt8();
                    /* unknown/reserved */ s.ReadUInt8();

                    // Output first sample from input
                    output[outOffset++] = (byte)predictor[c];
                    output[outOffset++] = (byte)(predictor[c] >> 8);

                    if (outOffset >= outputSize)
                        return output;
                }

                // Decode and output remaining data in this block
                var blockOffset = 0;
                while (blockOffset < blockDataSize)
                {
                    for (var c = 0; c < Channels; c++)
                    {
                        // Decode 4 bytes (to 16 bytes of output) per channel
                        var chunk = s.ReadBytes(4);
                        var decoded = ImaAdpcmReader.LoadImaAdpcmSound(chunk, ref index[c], ref predictor[c]);

                        // Interleave output, one sample per channel
                        var outOffsetChannel = outOffset + (2 * c);
                        for (var i = 0; i < decoded.Length; i += 2)
                        {
                            var outOffsetSample = outOffsetChannel + i;
                            if (outOffsetSample >= outputSize)
                                return output;

                            output[outOffsetSample] = decoded[i];
                            output[outOffsetSample + 1] = decoded[i + 1];
                            outOffsetChannel += 2 * (Channels - 1);
                        }

                        blockOffset += 4;
                    }

                    outOffset += 16 * Channels;
                }
            }

            return output;
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:64,代码来源:WavReader.cs

示例6: UnpackRATileData

        void UnpackRATileData(MemoryStream ms)
        {
            for (int i = 0; i < mapSize; i++)
                for (int j = 0; j < mapSize; j++)
                    map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();

            for (int j = 0; j < mapSize; j++)
                for (int i = 0; i < mapSize; i++)
                    map.MapTiles.Value[i, j].Type = ms.ReadUInt16();

            for (int j = 0; j < mapSize; j++)
                for (int i = 0; i < mapSize; i++)
                    map.MapTiles.Value[i, j].Index = ms.ReadUInt8();
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:14,代码来源:LegacyMapImporter.cs

示例7: UnpackRAOverlayData

        void UnpackRAOverlayData(MemoryStream ms)
        {
            for (int j = 0; j < mapSize; j++)
            {
                for (int i = 0; i < mapSize; i++)
                {
                    var o = ms.ReadUInt8();
                    var res = Pair.New((byte)0, (byte)0);

                    if (o != 255 && overlayResourceMapping.ContainsKey(redAlertOverlayNames[o]))
                        res = overlayResourceMapping[redAlertOverlayNames[o]];

                    map.MapResources.Value[i, j] = new TileReference<byte, byte>(res.First, res.Second);

                    if (o != 255 && overlayActorMapping.ContainsKey(redAlertOverlayNames[o]))
                    {
                        map.Actors.Value.Add("Actor" + actorCount++,
                            new ActorReference(overlayActorMapping[redAlertOverlayNames[o]])
                            {
                                new LocationInit(new CPos(i, j)),
                                new OwnerInit("Neutral")
                            });
                    }
                }
            }
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:26,代码来源:LegacyMapImporter.cs

示例8: ReadTiles

		static void ReadTiles(Map map, IniFile file, int2 fullSize)
		{
			var tileset = Game.ModData.DefaultTileSets[map.Tileset];
			var mapSection = file.GetSection("IsoMapPack5");

			var data = Convert.FromBase64String(mapSection.Aggregate(string.Empty, (a, b) => a + b.Value));
			int cells = (fullSize.X * 2 - 1) * fullSize.Y;
			int lzoPackSize = cells * 11 + 4; // last 4 bytes contains a lzo pack header saying no more data is left
			var isoMapPack = new byte[lzoPackSize];
			UnpackLZO(data, isoMapPack);

			var mf = new MemoryStream(isoMapPack);
			for (var i = 0; i < cells; i++)
			{
				var rx = mf.ReadUInt16();
				var ry = mf.ReadUInt16();
				var tilenum = mf.ReadUInt16();
				/*var zero1 = */mf.ReadInt16();
				var subtile = mf.ReadUInt8();
				var z = mf.ReadUInt8();
				/*var zero2 = */mf.ReadUInt8();

				int dx = rx - ry + fullSize.X - 1;
				int dy = rx + ry - fullSize.X - 1;
				var mapCell = new MPos(dx / 2, dy);
				var cell = mapCell.ToCPos(map);

				if (map.Tiles.Contains(cell))
				{
					if (!tileset.Templates.ContainsKey(tilenum))
						tilenum = subtile = 0;

					map.Tiles[cell] = new TerrainTile(tilenum, subtile);
					map.Height[cell] = z;
				}
			}
		}
开发者ID:GraionDilach,项目名称:OpenRA.Mods.AS,代码行数:37,代码来源:ImportASMapCommand.cs

示例9: UnpackRATileData

        void UnpackRATileData(MemoryStream ms)
        {
            for (int i = 0; i < mapSize; i++)
                for (int j = 0; j < mapSize; j++)
                    map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();

            for (int j = 0; j < mapSize; j++)
                for (int i = 0; i < mapSize; i++)
                {
                    var tileID = ms.ReadUInt16();
                    map.MapTiles.Value[i, j].Type = tileID == (ushort)0 ? (ushort)255 : tileID; // RAED weirdness
                }

            for (int j = 0; j < mapSize; j++)
                for (int i = 0; i < mapSize; i++)
                    map.MapTiles.Value[i, j].Index = ms.ReadUInt8();
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:17,代码来源:LegacyMapImporter.cs

示例10: SwitchContainerObject

        public SwitchContainerObject(byte[] data)
        {
            Data = data;

            using (MemoryStream s = new MemoryStream(data))
            {
                ID = s.ReadUInt32();
                bool overrideEffects = s.ReadBoolean();
                byte effectCount = s.ReadUInt8();
                if (effectCount > 0)
                {
                    s.ReadUInt8(); // effectmask
                }
                for (int i = 0; i < effectCount; i++)
                {
                    s.ReadUInt8(); // effect index
                    s.ReadUInt32(); // effect id
                    s.ReadUInt16(); // zeroes
                }
                OutputBus = s.ReadUInt32();
                ParentObjectId = s.ReadUInt32();
                s.ReadBoolean(); // overrideParentPlaybackPriority
                s.ReadBoolean(); // offset priority by ... at max distance activated
                
                byte additionalParameterCount = s.ReadUInt8();
                byte[] additionalParameterTypes = new byte[additionalParameterCount];
                for (int i = 0; i < additionalParameterCount; i++)
                {
                    additionalParameterTypes[i] = s.ReadUInt8();
                }
                for (int i = 0; i < additionalParameterCount; i++)
                {
                    s.ReadUInt32(); // most of these are floats but it doesn't actually matter. 4 bytes is 4 bytes
                }

                s.ReadUInt8(); // unknown

                bool positioningSection = s.ReadBoolean();
                if (positioningSection)
                {
                    byte positionType = s.ReadUInt8();
                    if (positionType == 0x00)
                    {
                        // 2D
                        s.ReadBoolean(); // panner enabled?
                    }
                    else if (positionType == 0x01)
                    {
                        // 3D
                        uint positionSource = s.ReadUInt32();
                        s.ReadUInt32(); // attenuation object
                        s.ReadBoolean(); // spatialization?
                        if (positionSource == 0x02)
                        {
                            // User defined
                            s.ReadUInt32(); // play type
                            s.ReadBoolean(); // loop? 
                            s.ReadUInt32(); // transition time
                            s.ReadBoolean(); // follow listener orientation?
                        }
                        else if (positionSource == 0x03)
                        {
                            // Game defined
                            s.ReadBoolean(); // update at each frame?
                        }
                    }
                }

                s.ReadBoolean(); // override parent settings for Game-Defined Auxiliary Sends?
                s.ReadBoolean(); // use Game-Defined Auxiliary Sends?
                s.ReadBoolean(); // override parent settings for User-Defined Auxiliary Sends?
                bool udasExist = s.ReadBoolean(); // User-Defined Auxiliary Sends exist?
                if (udasExist)
                {
                    uint auxBus0 = s.ReadUInt32(); // Auxiliary bus 0
                    uint auxBus1 = s.ReadUInt32(); // Auxiliary bus 1
                    uint auxBus2 = s.ReadUInt32(); // Auxiliary bus 2
                    uint auxBus3 = s.ReadUInt32(); // Auxiliary bus 3
                }
                
                bool unkPlaybackLimit = s.ReadBoolean(); // unknown param for playback limit
                if (unkPlaybackLimit)
                {
                    s.ReadUInt8(); // priority equal action
                    s.ReadUInt8(); // limit action
                    s.ReadUInt16(); // limit sound instances to ...
                }

                s.ReadUInt8(); // how to limit source instances
                s.ReadUInt8(); // virtual voice behaviour

                s.ReadBoolean(); // override parent settings for playback limit
                s.ReadBoolean(); // override parent settings for virtual voice

                uint stateGroupCount = s.ReadUInt32();
                for (int i = 0; i < stateGroupCount; i++)
                {
                    uint stateGroupId = s.ReadUInt32();
                    s.ReadUInt8(); // change occurs at
                    ushort statesDifferentFromDefault = s.ReadUInt16();
//.........这里部分代码省略.........
开发者ID:rodrigonh,项目名称:ThomasJepp.SaintsRow,代码行数:101,代码来源:SwitchContainerObject.cs


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