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


C# BinaryReaderEx.ReadByte方法代码示例

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


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

示例1: LoadSection

        public override void LoadSection(BinaryReaderEx reader)
        {
            base.LoadSection(reader);

            this.CibtData = new List<CibtData>();
            int numCibtBlocks = (this.SectionLength - 4) / bytesPerBlock;
            for (var i = 0; i < numCibtBlocks; i++)
            {
                var cibt = new CibtData();
                cibt.Name = reader.ReadFixedLengthString(16).Trim();
                cibt.Unk1 = reader.ReadByte();
                cibt.Unk2 = reader.ReadByte();
                cibt.Unk3 = reader.ReadByte();
                cibt.Unk4 = reader.ReadByte();
                this.CibtData.Add(cibt);
            }
        }
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:17,代码来源:CibtSection.cs

示例2: LoadData

        public override void LoadData(BinaryReaderEx reader)
        {
            base.LoadData(reader);

            this.DisplayName = "Header";

            this.Unknown0 = reader.ReadByte();
            this.PgrpCount = reader.ReadByte();
            this.StmsCount = reader.ReadByte();
            this.EnvdCount = reader.ReadByte();
            this.Unknown1 = reader.ReadInt32(Endianness.BigEndian);
            this.Unknown2 = reader.ReadByte();
            this.Unknown3 = reader.ReadByte();
            this.Unknown4 = reader.ReadByte();
            this.Unknown5 = reader.ReadByte();
            this.ShapCount = reader.ReadByte();
            this.MimsCount = reader.ReadByte();
            this.Unknown6 = reader.ReadByte();
            this.Unknown7 = reader.ReadByte();
        }
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:20,代码来源:MeshHeaderChunk.cs

示例3: Load

        public override Endogine.ColorEx.Palette Load(string filename)
        {
            Serialization.BinaryReaderEx reader = new BinaryReaderEx(new System.IO.FileStream(filename, System.IO.FileMode.Open));
            int numColors = (int)(reader.BaseStream.Length / 3);
            Endogine.ColorEx.Palette palette = new Endogine.ColorEx.Palette();

            for (int i = 0; i < numColors; i++)
            {
                Vector4 v = new Vector4(0, 0, 0, 1);
                for (int channelNum = 0; channelNum < 3; channelNum++)
                    v[channelNum] = (float)reader.ReadByte() / 255;

                string name = i.ToString();
                ColorEx.ColorRgb rgb = new Endogine.ColorEx.ColorRgb();
                rgb.Vector = v;
                palette.Add(name, rgb);
            }
            return palette;
        }
开发者ID:timdetering,项目名称:Endogine,代码行数:19,代码来源:Act.cs

示例4: LoadFile

        public void LoadFile(BinaryReaderEx reader)
        {
            reader.BaseStream.Position = 4;
            this.Unknown = reader.ReadInt32();
            this.ContentLength = reader.ReadInt32();
            this.IsEncoded = (reader.ReadByte() == 0xFF);

            byte[] data = new byte[this.ContentLength];

            reader.Read(data, 0, this.ContentLength);

            if (this.IsEncoded)
            {
                for (var i = 0; i < data.Length; i++)
                {
                    data[i] ^= 0x73;
                }
            }

            this.Data = data;
            this.DataAsString = Encoding.UTF8.GetString(data);
        }
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:22,代码来源:LuaFile.cs

示例5: ReadHeaderField

        private bool ReadHeaderField(BinaryReaderEx brSource)
        {
            Debug.Assert(brSource != null);
            if(brSource == null) throw new ArgumentNullException("brSource");

            byte btFieldID = brSource.ReadByte();
            ushort uSize = MemUtil.BytesToUInt16(brSource.ReadBytes(2));

            byte[] pbData = null;
            if(uSize > 0)
            {
                string strPrevExcpText = brSource.ReadExceptionText;
                brSource.ReadExceptionText = KLRes.FileHeaderEndEarly;

                pbData = brSource.ReadBytes(uSize);

                brSource.ReadExceptionText = strPrevExcpText;
            }

            bool bResult = true;
            KdbxHeaderFieldID kdbID = (KdbxHeaderFieldID)btFieldID;
            switch(kdbID)
            {
                case KdbxHeaderFieldID.EndOfHeader:
                    bResult = false; // Returning false indicates end of header
                    break;

                case KdbxHeaderFieldID.CipherID:
                    SetCipher(pbData);
                    break;

                case KdbxHeaderFieldID.CompressionFlags:
                    SetCompressionFlags(pbData);
                    break;

                case KdbxHeaderFieldID.MasterSeed:
                    m_pbMasterSeed = pbData;
                    CryptoRandom.Instance.AddEntropy(pbData);
                    break;

                case KdbxHeaderFieldID.TransformSeed:
                    m_pbTransformSeed = pbData;
                    CryptoRandom.Instance.AddEntropy(pbData);
                    break;

                case KdbxHeaderFieldID.TransformRounds:
                    m_pwDatabase.KeyEncryptionRounds = MemUtil.BytesToUInt64(pbData);
                    break;

                case KdbxHeaderFieldID.EncryptionIV:
                    m_pbEncryptionIV = pbData;
                    break;

                case KdbxHeaderFieldID.ProtectedStreamKey:
                    m_pbProtectedStreamKey = pbData;
                    CryptoRandom.Instance.AddEntropy(pbData);
                    break;

                case KdbxHeaderFieldID.StreamStartBytes:
                    m_pbStreamStartBytes = pbData;
                    break;

                case KdbxHeaderFieldID.InnerRandomStreamID:
                    SetInnerRandomStreamID(pbData);
                    break;

                default:
                    Debug.Assert(false);
                    if(m_slLogger != null)
                        m_slLogger.SetText(KLRes.UnknownHeaderId + @": " +
                            kdbID.ToString() + "!", LogStatusType.Warning);
                    break;
            }

            return bResult;
        }
开发者ID:Stoom,项目名称:KeePass,代码行数:76,代码来源:KdbxFile.Read.cs

示例6: LoadSection

        public override void LoadSection(BinaryReaderEx reader)
        {
            base.LoadSection(reader);

            this.NumEntries = reader.ReadInt16(Endianness.BigEndian);
            this.EntryLength = reader.ReadInt16(Endianness.BigEndian);
            this.ValuesPerEntry = reader.ReadInt16(Endianness.BigEndian);

            this.EquipParams = new List<EquipParam>(this.NumEntries);
            this.ValueLengths = new byte[this.ValuesPerEntry];

            for (var i = 0; i < this.ValuesPerEntry; i++)
            {
                this.ValueLengths[i] = reader.ReadByte();
            }

            for (var p = 0; p < this.NumEntries; p++)
            {
                var param = new EquipParam();
                param.ID = p + 1;
                var paramData = reader.ReadBytes(this.EntryLength);
                int offset = 0;
                byte thisByte = paramData[offset];
                int bitCnt = 8;
                for (var v = 0; v < this.ValuesPerEntry; v++)
                {
                    int thisLen = this.ValueLengths[v];
                    int val = 0;
                    do
                    {
                        val <<= 1;
                        if ((thisByte & 0x80) != 0)
                        {
                            val |= 1;
                        }
                        thisByte <<= 1;
                        bitCnt--;
                        if (bitCnt == 0)
                        {
                            offset++;
                            thisByte = paramData[offset];
                            bitCnt = 8;
                        }
                        thisLen--;
                    } while (thisLen != 0);
                    param.Values[v] = val;
                }
                this.EquipParams.Add(param);
            }
        }
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:50,代码来源:EquipParamSection.cs

示例7: CreateCompressedLinearCurve

        private static Curves.LinearCurve CreateCompressedLinearCurve(BinaryReaderEx reader, AnimatedComponent component, short count)
        {
            var result = new Curves.LinearCurve(component);

            bool flag = (count & 0x8000) != 0;
            int numValues = count & 0x7FFF;
            float offset = reader.ReadSingle(Endianness.BigEndian);
            float scale = reader.ReadSingle(Endianness.BigEndian);
            var lengths = reader.ReadBytes(numValues);
            for (var i = 0; i < numValues; i++)
            {
                var length = lengths[i];
                if (length == 0) { length = 1; }
                var indices = reader.ReadBytes(length);
                if (flag)
                {
                    for (var j = 0; j < length; j++)
                    {
                        ushort sval = reader.ReadUInt16(Endianness.BigEndian);
                        bool isNeg = (sval & 0x8000) != 0;
                        float val = (sval & 0x7FFF) / 32767.0f;
                        if (isNeg) { val = -val; }
                        val = val * scale + offset;

                        Curves.LinearCurveValue curveVal = new Curves.LinearCurveValue()
                        {
                            Time = (float)(indices[j] + 256*i),
                            Value = val
                        };
                        result.Values.Add(curveVal);
                    }
                }
                else
                {
                    for (var j = 0; j < length; j++)
                    {
                        byte sval = reader.ReadByte();
                        bool isNeg = (sval & 0x80) != 0;
                        float val = (sval & 0x7F) / 127.0f;
                        if (isNeg) { val = -val; }
                        val = val * scale + offset;
                        Curves.LinearCurveValue curveVal = new Curves.LinearCurveValue()
                        {
                            Time = (float)(indices[j] + 256 * i),
                            Value = val
                        };
                        result.Values.Add(curveVal);
                    }
                }
            }

            // Align reader position to 4-byte boundary
            reader.BaseStream.Position = (reader.BaseStream.Position + 3) & 0x7FFFFFFFFFFFFFFC;

            return result;
        }
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:56,代码来源:SpuCurveLoader.cs

示例8: LoadSection

        public void LoadSection(BinaryReaderEx reader)
        {
            this.Header = new GtexHeader();
            this.Header.Magic = reader.ReadInt32();
            this.Header.Unknown1 = reader.ReadByte();
            this.Header.Unknown2 = reader.ReadByte();
            this.Header.Format = reader.ReadByte();
            this.Header.MipMapCount = reader.ReadByte();
            this.Header.Unknown3 = reader.ReadByte();
            this.Header.IsCubeMap = reader.ReadByte() == 0x1;
            this.Header.Width = reader.ReadUInt16(Endianness.BigEndian);
            this.Header.Height = reader.ReadUInt16(Endianness.BigEndian);
            this.Header.Depth = reader.ReadInt16(Endianness.BigEndian);
            this.Header.Unknown5 = reader.ReadInt32(Endianness.BigEndian);
            this.Header.DataOffset = reader.ReadUInt32(Endianness.BigEndian);

            if (this.Header.IsCubeMap) { this.NumLayers = 6; }
            else { this.NumLayers = this.Header.MipMapCount; }

            this.LoadMipMapData(reader);
            this.GetDataOffset();
            this.LoadTextureData(reader);
        }
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:23,代码来源:GtexData.cs

示例9: Load

        public override void Load(BinaryReaderEx reader)
        {
            base.Load(reader);

            Float1 = reader.ReadSingle();
            AnimationLength = reader.ReadSingle();
            Bones = reader.ReadInt16();
            NumIndices = reader.ReadInt16();
            Flags = reader.ReadByte();
            reader.BaseStream.Seek(3, System.IO.SeekOrigin.Current);
            for (var i = 0; i < NumIndices; i++)
            {
                int val = reader.ReadInt32();
                ChunkIndex idx = new ChunkIndex();
                idx.Index = val & 0x7FFFFFFF;
                idx.Flag = (val & 0x80000000) == 0x80000000;
                this.Offsets.Add(idx);
            }
        }
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:19,代码来源:MtbSection.cs

示例10: ReadInnerHeaderField

		private bool ReadInnerHeaderField(BinaryReaderEx br)
		{
			Debug.Assert(br != null);
			if(br == null) throw new ArgumentNullException("br");

			byte btFieldID = br.ReadByte();

			int cbSize = MemUtil.BytesToInt32(br.ReadBytes(4));
			if(cbSize < 0) throw new FormatException(KLRes.FileCorrupted);

			byte[] pbData = MemUtil.EmptyByteArray;
			if(cbSize > 0) pbData = br.ReadBytes(cbSize);

			bool bResult = true;
			KdbxInnerHeaderFieldID kdbID = (KdbxInnerHeaderFieldID)btFieldID;
			switch(kdbID)
			{
				case KdbxInnerHeaderFieldID.EndOfHeader:
					bResult = false; // Returning false indicates end of header
					break;

				case KdbxInnerHeaderFieldID.InnerRandomStreamID:
					SetInnerRandomStreamID(pbData);
					break;

				case KdbxInnerHeaderFieldID.InnerRandomStreamKey:
					Debug.Assert(m_pbInnerRandomStreamKey == null);
					m_pbInnerRandomStreamKey = pbData;
					CryptoRandom.Instance.AddEntropy(pbData);
					break;

				case KdbxInnerHeaderFieldID.Binary:
					if(pbData.Length < 1) throw new FormatException();
					KdbxBinaryFlags f = (KdbxBinaryFlags)pbData[0];
					bool bProt = ((f & KdbxBinaryFlags.Protected) != KdbxBinaryFlags.None);

					ProtectedBinary pb = new ProtectedBinary(bProt, pbData,
						1, pbData.Length - 1);
					m_pbsBinaries.Add(pb);

					if(bProt) MemUtil.ZeroByteArray(pbData);
					break;

				default:
					Debug.Assert(false);
					break;
			}

			return bResult;
		}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:50,代码来源:KdbxFile.Read.cs

示例11: ReadHeaderField

		private bool ReadHeaderField(BinaryReaderEx brSource)
		{
			Debug.Assert(brSource != null);
			if(brSource == null) throw new ArgumentNullException("brSource");

			byte btFieldID = brSource.ReadByte();

			int cbSize;
			Debug.Assert(m_uFileVersion > 0);
			if(m_uFileVersion < FileVersion32_4)
				cbSize = (int)MemUtil.BytesToUInt16(brSource.ReadBytes(2));
			else cbSize = MemUtil.BytesToInt32(brSource.ReadBytes(4));
			if(cbSize < 0) throw new FormatException(KLRes.FileCorrupted);

			byte[] pbData = MemUtil.EmptyByteArray;
			if(cbSize > 0) pbData = brSource.ReadBytes(cbSize);

			bool bResult = true;
			KdbxHeaderFieldID kdbID = (KdbxHeaderFieldID)btFieldID;
			switch(kdbID)
			{
				case KdbxHeaderFieldID.EndOfHeader:
					bResult = false; // Returning false indicates end of header
					break;

				case KdbxHeaderFieldID.CipherID:
					SetCipher(pbData);
					break;

				case KdbxHeaderFieldID.CompressionFlags:
					SetCompressionFlags(pbData);
					break;

				case KdbxHeaderFieldID.MasterSeed:
					m_pbMasterSeed = pbData;
					CryptoRandom.Instance.AddEntropy(pbData);
					break;

				// Obsolete; for backward compatibility only
				case KdbxHeaderFieldID.TransformSeed:
					Debug.Assert(m_uFileVersion < FileVersion32_4);

					AesKdf kdfS = new AesKdf();
					if(!m_pwDatabase.KdfParameters.KdfUuid.Equals(kdfS.Uuid))
						m_pwDatabase.KdfParameters = kdfS.GetDefaultParameters();

					// m_pbTransformSeed = pbData;
					m_pwDatabase.KdfParameters.SetByteArray(AesKdf.ParamSeed, pbData);

					CryptoRandom.Instance.AddEntropy(pbData);
					break;

				// Obsolete; for backward compatibility only
				case KdbxHeaderFieldID.TransformRounds:
					Debug.Assert(m_uFileVersion < FileVersion32_4);

					AesKdf kdfR = new AesKdf();
					if(!m_pwDatabase.KdfParameters.KdfUuid.Equals(kdfR.Uuid))
						m_pwDatabase.KdfParameters = kdfR.GetDefaultParameters();

					// m_pwDatabase.KeyEncryptionRounds = MemUtil.BytesToUInt64(pbData);
					m_pwDatabase.KdfParameters.SetUInt64(AesKdf.ParamRounds,
						MemUtil.BytesToUInt64(pbData));
					break;

				case KdbxHeaderFieldID.EncryptionIV:
					m_pbEncryptionIV = pbData;
					break;

				case KdbxHeaderFieldID.InnerRandomStreamKey:
					Debug.Assert(m_uFileVersion < FileVersion32_4);
					Debug.Assert(m_pbInnerRandomStreamKey == null);
					m_pbInnerRandomStreamKey = pbData;
					CryptoRandom.Instance.AddEntropy(pbData);
					break;

				case KdbxHeaderFieldID.StreamStartBytes:
					Debug.Assert(m_uFileVersion < FileVersion32_4);
					m_pbStreamStartBytes = pbData;
					break;

				case KdbxHeaderFieldID.InnerRandomStreamID:
					Debug.Assert(m_uFileVersion < FileVersion32_4);
					SetInnerRandomStreamID(pbData);
					break;

				case KdbxHeaderFieldID.KdfParameters:
					m_pwDatabase.KdfParameters = KdfParameters.DeserializeExt(pbData);
					break;

				case KdbxHeaderFieldID.PublicCustomData:
					Debug.Assert(m_pwDatabase.PublicCustomData.Count == 0);
					m_pwDatabase.PublicCustomData = VariantDictionary.Deserialize(pbData);
					break;

				default:
					Debug.Assert(false);
					if(m_slLogger != null)
						m_slLogger.SetText(KLRes.UnknownHeaderId + @": " +
							kdbID.ToString() + "!", LogStatusType.Warning);
//.........这里部分代码省略.........
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:101,代码来源:KdbxFile.Read.cs

示例12: ByteToFloat

 private static float ByteToFloat(BinaryReaderEx src)
 {
     byte val = src.ReadByte();
     return val / 255f;
 }
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:5,代码来源:StreamDecompressors.cs


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