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


C# EndianBinaryReader类代码示例

本文整理汇总了C#中EndianBinaryReader的典型用法代码示例。如果您正苦于以下问题:C# EndianBinaryReader类的具体用法?C# EndianBinaryReader怎么用?C# EndianBinaryReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: TEX0

 public TEX0(EndianBinaryReader er)
 {
     long basepos = er.BaseStream.Position;
     Signature = er.ReadString(Encoding.ASCII, 4);
     if (Signature != "TEX0") throw new SignatureNotCorrectException(Signature, "TEX0", er.BaseStream.Position - 4);
     SectionSize = er.ReadUInt32();
     TexInfo = new texInfo(er);
     Tex4x4Info = new tex4x4Info(er);
     PlttInfo = new plttInfo(er);
     dictTex = new Dictionary<DictTexData>(er);
     for (int i = 0; i < dictTex.numEntry; i++)
     {
         dictTex[i].Value.ReadData(er, TexInfo.ofsTex, Tex4x4Info.ofsTex, Tex4x4Info.ofsTexPlttIdx, basepos);
     }
     dictPltt = new Dictionary<DictPlttData>(er);
     List<UInt32> Offset = new List<uint>();
     for (int i = 0; i < dictPltt.numEntry; i++)
     {
         Offset.Add(dictPltt[i].Value.offset);
     }
     Offset = Offset.Distinct().ToList();
     Offset.Sort();
     for (int i = 0; i < dictPltt.numEntry; i++)
     {
         int idx = Offset.IndexOf(dictPltt[i].Value.offset);
         if (idx == Offset.Count - 1)
         {
             dictPltt[i].Value.ReadData(er, PlttInfo.ofsPlttData, (uint)er.BaseStream.Length - (Offset[idx] + PlttInfo.ofsPlttData + (uint)basepos), basepos);
         }
         else
         {
             dictPltt[i].Value.ReadData(er, PlttInfo.ofsPlttData, Offset[idx + 1] - Offset[idx], basepos);
         }
     }
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:35,代码来源:TEX0.cs

示例2: ConvertOgg

        public static Stream ConvertOgg(string inputFile)
        {
            if (needsConversion(inputFile))
            {
                var platform = getPlatform(inputFile);
                EndianBitConverter bitConverter = platform.GetBitConverter();

                using (var outputFileStream = new MemoryStream())
                using (var inputFileStream = File.Open(inputFile, FileMode.Open))
                using (var writer = new EndianBinaryWriter(bitConverter, outputFileStream))
                using (var reader = new EndianBinaryReader(bitConverter, inputFileStream))
                {
                    writer.Write(reader.ReadBytes(4));
                    UInt32 fileSize = reader.ReadUInt32();
                    fileSize -= 8; // We're removing data, so update the size in the header
                    writer.Write(fileSize);
                    writer.Write(reader.ReadBytes(8));
                    writer.Write(66); reader.ReadUInt32(); // New fmt size is 66
                    writer.Write(reader.ReadBytes(16));
                    writer.Write((ushort)48); reader.ReadUInt16(); // New cbSize is 48
                    writer.Write(reader.ReadBytes(6));
                    reader.BaseStream.Seek(8, SeekOrigin.Current); // Skip ahead 8 bytes, we don't want the vorb chunk
                    writer.Write(reader.ReadBytes((int)reader.BaseStream.Length - (int)reader.BaseStream.Position));

                    return new MemoryStream(outputFileStream.GetBuffer(), 0, (int)outputFileStream.Length);
                }
            }

            return File.OpenRead(inputFile);
        }
开发者ID:joshsten,项目名称:rocksmith-custom-song-toolkit,代码行数:30,代码来源:OggFile.cs

示例3: ReadChunk

        public static McaChunk ReadChunk(byte[] buffer, int dx, int dz)
        {
            //from mca file header
            int i = 4 * (dx + dz * 32);
            int offset = (buffer [i] << 16) | (buffer [i + 1] << 8) | (buffer [i + 2]);
            int sectors = buffer [i + 3];

            if (offset == 0 && sectors == 0)
                return null;

            Console.WriteLine("Read Chunk " + dx + "," + dz + " @ " + offset + ":" + sectors);

            if (offset == 0 || sectors == 0)
                throw new InvalidDataException("zero offset/sector");

            offset = offset << 12; //4096 = 2**12
            int length = EndianBitConverter.Big.ToInt32(buffer, offset); //byte length
            if (((length + 5 - 1) >> 12) + 1 != sectors)
                throw new InvalidDataException("Body length is larger than the sectors, " + length + " > " + (sectors * 4096));
            if (buffer [offset + 4] != 2)
                throw new NotImplementedException("Only support zlib compression");
            
            McaChunk mc = new McaChunk(dx, dz);

            MemoryStream ms = new MemoryStream(buffer, offset + 5, length);
            
            using (ZlibStream compressed = new ZlibStream(ms, CompressionMode.Decompress))
            {
                EndianBinaryReader r = new EndianBinaryReader(EndianBitConverter.Big, compressed);
                mc.Tag = Tag.ReadTag(r);
            }
            
            return mc;
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:34,代码来源:McaChunk.cs

示例4: FFNT

        public FFNT(byte[] Data)
        {
            EndianBinaryReader er = new EndianBinaryReader(new MemoryStream(Data), Endianness.BigEndian);
            Header = new FFNTHeader(er);
            FontInfo = new FINF(er);
            er.BaseStream.Position = FontInfo.TGLPOffset - 8;
            TextureGlyph = new TGLP(er);

            List<CWDH> tmp = new List<CWDH>();
            er.BaseStream.Position = FontInfo.CWDHOffset - 8;
            CWDH Last;
            do
            {
                Last = new CWDH(er);
                tmp.Add(Last);
                if (Last.NextCWDHOffset != 0) er.BaseStream.Position = Last.NextCWDHOffset - 8;
            }
            while (Last.NextCWDHOffset != 0);
            CharWidths = tmp.ToArray();

            List<CMAP> tmp2 = new List<CMAP>();
            er.BaseStream.Position = FontInfo.CMAPOffset - 8;
            CMAP Last2;
            do
            {
                Last2 = new CMAP(er);
                tmp2.Add(Last2);
                if (Last2.NextCMAPOffset != 0) er.BaseStream.Position = Last2.NextCMAPOffset - 8;
            }
            while (Last2.NextCMAPOffset != 0);
            CharMaps = tmp2.ToArray();
            er.Close();
        }
开发者ID:wmltogether,项目名称:ZLD-TWW-HD-Chinese-Localization-Project,代码行数:33,代码来源:FFNT.cs

示例5: UnpackSng

        public static void UnpackSng(Stream input, Stream output, Platform platform) {
            EndianBitConverter conv = platform.GetBitConverter;

            using (var decrypted = new MemoryStream())
            using (var ebrDec = new EndianBinaryReader(conv, decrypted)) {
                byte[] key;
                switch (platform.platform) {
                    case GamePlatform.Mac:
                        key = RijndaelEncryptor.SngKeyMac;
                        break;
                    case GamePlatform.Pc:
                        key = RijndaelEncryptor.SngKeyPC;
                        break;
                    default:
                        key = null;
                        break;
                }
                if (key != null)
                    RijndaelEncryptor.DecryptSngData(input, decrypted, key, conv);
                else {
                    input.CopyTo(decrypted);
                    decrypted.Seek(8, SeekOrigin.Begin);
                }
                //unZip
                long plainLen = ebrDec.ReadUInt32();
                ushort xU = ebrDec.ReadUInt16();
                decrypted.Position -= 2;
                if (xU == 0x78DA || xU == 0xDA78) {//LE 55928 //BE 30938
                    RijndaelEncryptor.Unzip(decrypted, output, false);
                }
            }
        }
开发者ID:aequitas,项目名称:rocksmith-custom-song-toolkit,代码行数:32,代码来源:Sng2014File.cs

示例6: LoadTEX1FromFile

        private static List<Texture2D> LoadTEX1FromFile(EndianBinaryReader reader, long chunkStart)
        {
            ushort textureCount = reader.ReadUInt16();
            ushort padding = reader.ReadUInt16(); // Usually 0xFFFF?
            uint textureHeaderOffset = reader.ReadUInt32(); // textureCount # bti image headers are stored here, relative to chunkStart.
            uint stringTableOffset = reader.ReadUInt32(); // One filename per texture. relative to chunkStart.
            List<Texture2D> textureList = new List<Texture2D>();

            // Get all Texture Names
            reader.BaseStream.Position = chunkStart + stringTableOffset;
            StringTable stringTable = StringTable.FromStream(reader);

            for (int t = 0; t < textureCount; t++)
            {
                // 0x20 is the length of the BinaryTextureImage header which all come in a row, but then the stream gets jumped around while loading the BTI file.
                reader.BaseStream.Position = chunkStart + textureHeaderOffset + (t * 0x20);
                BinaryTextureImage texture = new BinaryTextureImage();
                texture.Load(reader, chunkStart + 0x20, t);

                Texture2D texture2D = new Texture2D(texture.Width, texture.Height);
                texture2D.Name = stringTable[t];
                texture2D.PixelData = texture.GetData();
                textureList.Add(texture2D);

                string executionPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                texture.SaveImageToDisk(executionPath + "/TextureDump/" + string.Format("{0}_({1}-{2}).png", stringTable[t], texture.Format, t));
            }

            return textureList;
        }
开发者ID:CryZe,项目名称:WindEditor2,代码行数:30,代码来源:TEX1.cs

示例7: Parse

		protected override void Parse (EndianBinaryReader r)
		{
			/*
            string channel = ReadString8(r);
            Varint int length = r.ReadInt16();
            if (length > MaxDataSize)
                throw new InvalidDataException("Plugin package payload size > " + MaxDataSize + " bytes");
            byte[] data = r.ReadBytesOrThrow(length);
            switch (channel)
            {
                case MCItemName.ChannelID:
                    return new MCItemName(data);
                case "MC|AdvCdm":
                case "MC|Beacon":
                case "MC|TPack":
                case "MC|TrList":
                case "MC|TrSel":
                case "MC|Brand":
                    return new UnknownPluginMessageServer(channel, data);
                default:
#if DEBUG
                    throw new InvalidOperationException("New Plugin channel: " + channel);
#else
                    return new UnknownPluginMessageServer(channel, data);
#endif
            }
*/
		}
开发者ID:mctraveler,项目名称:MineSharp,代码行数:28,代码来源:PluginMessageFromServer.cs

示例8: Update

        public bool Update()
        {
            var bitStream = downloader.DownloadStream;
            var reader = new EndianBinaryReader(EndianBitConverter.Big, bitStream);

            if(bitStream != null)
            {
                var stream = new StreamReader(bitStream);
                {
                    reader.ReadBytes(3); //"FLV"
                    reader.ReadBytes(6); //Other starter shit

                    while (true)
                    {
                        try
                        {
                            var footer = reader.ReadUInt32();
                            var tag = new FlvTag();
                            tag.Load(reader);

                            AddedTag(tag);

                        }
                        catch (Exception)
                        {
                            reader.Close();
                            //End of stream
                            return false;
                        }
                    }
                }
            }

            return true;
        }
开发者ID:Austech,项目名称:RTMP-CSharp,代码行数:35,代码来源:VideoClient.cs

示例9: readPixels

        private void readPixels(EndianBinaryReader reader, ushort width, ushort height, DmfFile file)
        {
            int totalPixels = width * height;
            uint xLocation = 1;
            uint yLocation = 1;
            for (int i = 0; i < totalPixels; i++)
            {
                short altitude = reader.ReadInt16();
                byte peakRoughness = reader.ReadByte();
                byte fractalRoughness = reader.ReadByte();
                byte cliffStrength = reader.ReadByte();
                byte erosionStrength = reader.ReadByte();
                byte autoLakeStrength = reader.ReadByte();
                byte climateId = reader.ReadByte();
                byte specialTypeId = reader.ReadByte();
                byte specialTypeParam = reader.ReadByte();

                file.addPixel(new DmfPixelInfo(xLocation, yLocation, altitude, peakRoughness, fractalRoughness, cliffStrength, erosionStrength, autoLakeStrength, climateId, specialTypeId, specialTypeParam));

                xLocation++;
                if (xLocation > width)
                {
                    xLocation = 1;
                    yLocation++;
                }
            }

            debugLine("pixel count: " + file.pixels.Count());
        }
开发者ID:Celludriel,项目名称:L3DT_Filemanager,代码行数:29,代码来源:DmfManager.cs

示例10: wnd1

 public wnd1(EndianBinaryReader er)
     : base(er)
 {
     long basepos = er.BaseStream.Position - 0x4C;
     InflationLeft = er.ReadUInt16() / 16f;
     InflationRight = er.ReadUInt16() / 16f;
     InflationTop = er.ReadUInt16() / 16f;
     InflationBottom = er.ReadUInt16() / 16f;
     FrameSizeLeft = er.ReadUInt16();
     FrameSizeRight = er.ReadUInt16();
     FrameSizeTop = er.ReadUInt16();
     FrameSizeBottom = er.ReadUInt16();
     NrFrames = er.ReadByte();
     byte tmp = er.ReadByte();
     UseLTMaterial = (tmp & 1) == 1;
     UseVtxColorForAllWindow = (tmp & 2) == 2;
     Kind = (WindowKind)((tmp >> 2) & 3);
     DontDrawContent = (tmp & 8) == 16;
     Padding = er.ReadUInt16();
     ContentOffset = er.ReadUInt32();
     FrameOffsetTableOffset = er.ReadUInt32();
     er.BaseStream.Position = basepos + ContentOffset;
     Content = new WindowContent(er);
     er.BaseStream.Position = basepos + FrameOffsetTableOffset;
     WindowFrameOffsets = er.ReadUInt32s(NrFrames);
     WindowFrames = new WindowFrame[NrFrames];
     for (int i = 0; i < NrFrames; i++)
     {
         er.BaseStream.Position = basepos + WindowFrameOffsets[i];
         WindowFrames[i] = new WindowFrame(er);
     }
     er.BaseStream.Position = basepos + SectionSize;
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:33,代码来源:wnd1.cs

示例11: Load

 public void Load(MemoryStream memory)
 {
     var reader = new EndianBinaryReader(EndianBitConverter.Big, memory);
     switch (Format)
     {
         case BasicHeader.HeaderFormats.F0: //11 bytes
             {
                 var timeStampByte = new byte[4] {0x00, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                 TimeStamp = EndianBitConverter.Big.ToInt32(timeStampByte, 0);
                 var lengthByte = new byte[4] {0x00, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                 MessageLength = EndianBitConverter.Big.ToInt32(lengthByte, 0);
                 MessageType = reader.ReadByte();
                 var messageStreamBytes = reader.ReadBytes(4);
                 MessageStreamId = EndianBitConverter.Little.ToInt32(messageStreamBytes, 0);
             }
             break;
         case BasicHeader.HeaderFormats.F1: //7 bytes
             {
                 var timeStampByte = new byte[4] {0x00, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                 TimeStamp = EndianBitConverter.Big.ToInt32(timeStampByte, 0);
                 var lengthByte = new byte[4] {0x00, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                 MessageLength = EndianBitConverter.Big.ToInt32(lengthByte, 0);
                 MessageType = reader.ReadByte();
             }
             break;
         case BasicHeader.HeaderFormats.F2: //3 bytes
             {
                 var timeStampByte = new byte[4] {0x00, reader.ReadByte(), reader.ReadByte(), reader.ReadByte()};
                 TimeStamp = EndianBitConverter.Big.ToInt32(timeStampByte, 0);
             }
             break;
         case BasicHeader.HeaderFormats.F3: //No bytes
             break;
     }
 }
开发者ID:Austech,项目名称:RtmpSharp2,代码行数:35,代码来源:MessageHeader.cs

示例12: read

		public void read(EndianBinaryReader r) {
			Time = r.ReadSingle();
			Measure = r.ReadInt16();
			Beat = r.ReadInt16();
			PhraseIteration = r.ReadInt32();
			Mask = r.ReadInt32();
		}
开发者ID:aequitas,项目名称:rocksmith-custom-song-toolkit,代码行数:7,代码来源:Sng2014HSL.cs

示例13: POTIRoute

 public POTIRoute(EndianBinaryReader er)
 {
     NrPoints = er.ReadUInt16();
     Setting1 = er.ReadByte();
     Setting2 = er.ReadByte();
     for (int i = 0; i < NrPoints; i++) Points.Add(new POTIPoint(er));
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:7,代码来源:POTI.cs

示例14: Fill

    static public void Fill(byte[] bytes)
    {

        var binReader = new EndianBinaryReader(Endian.LittleEndian, new MemoryStream(bytes));
        binReader.Endian = binReader.ReadBoolean() ? Endian.LittleEndian : Endian.BigEndian;
        
        
        var jumpPos = binReader.ReadInt32();
        
        //跳过表头信息
        binReader.BaseStream.Position = jumpPos;
        
        /*
        var headerCount = binReader.ReadInt32();
        var headers = new string[headerCount];
        var types = new string[headerCount];
        for (var i = 0; i < headerCount; i++)
        {
            headers[i] = binReader.ReadUTF();
            types[i] = binReader.ReadUTF();
        }
        */
        
        var count = binReader.ReadInt32();
        for (int i = 0; i < count; i++)
        {
            var vo = new LangVO();
            vo.decode(binReader);
            list_vo.Add(vo);
            dic_vo.Add(vo.Age, vo);
        }

    }
开发者ID:superkaka,项目名称:mycsharp,代码行数:33,代码来源:LangVO.cs

示例15: ByteBuffer

 //Constructors
 public ByteBuffer()
 {
     stream = new MemoryStream();
     bitConverter = new LittleEndianBitConverter();
     writer = new EndianBinaryWriter(bitConverter, stream);
     reader = new EndianBinaryReader(bitConverter, stream);
 }
开发者ID:gbarresi,项目名称:buffer_bci,代码行数:8,代码来源:ByteBuffer.cs


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