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


C# BinaryReader.ReadInt32BE方法代码示例

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


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

示例1: ParseIndex

        private void ParseIndex(Stream stream, int i)
        {
            using (var br = new BinaryReader(stream))
            {
                stream.Seek(-12, SeekOrigin.End);
                int count = br.ReadInt32();
                stream.Seek(0, SeekOrigin.Begin);

                if (count * (16 + 4 + 4) > stream.Length)
                    throw new Exception("ParseIndex failed");

                for (int j = 0; j < count; ++j)
                {
                    byte[] key = br.ReadBytes(16);

                    if (key.IsZeroed()) // wtf?
                        key = br.ReadBytes(16);

                    if (key.IsZeroed()) // wtf?
                        throw new Exception("key.IsZeroed()");

                    IndexEntry entry = new IndexEntry();
                    entry.Index = i;
                    entry.Size = br.ReadInt32BE();
                    entry.Offset = br.ReadInt32BE();

                    CDNIndexData.Add(key, entry);
                }
            }
        }
开发者ID:hurricup,项目名称:CASCExplorer,代码行数:30,代码来源:CDNIndexHandler.cs

示例2: Read

        public static ShapefileHeader Read(BinaryReader reader)
        {
            ShapefileHeader header = new ShapefileHeader();

            int fileType = reader.ReadInt32BE();
            if (fileType != 9994)
                throw new Exception("The first four bytes of this file indicate this is not a shape file.");

            // skip 5 unsed bytes
            reader.BaseStream.Seek(20L, SeekOrigin.Current);

            header.FileLength = reader.ReadInt32BE();

            int version = reader.ReadInt32();
            if (version != 1000)
                throw new Exception("Shapefile is not the proper version");

            header.ShapeType = (ShapefileGeometryType)reader.ReadInt32();

            double[] coords = new double[4];
            for (int i = 0; i < 4; i++)
                coords[i] = reader.ReadDouble();
            header.Bounds = new Envelope(coords[0], coords[2], coords[1], coords[3]);

            // Skip to end of header
            reader.BaseStream.Seek(100L, SeekOrigin.Begin);

            return header;
        }
开发者ID:interworks,项目名称:FastShapefile,代码行数:29,代码来源:ShapefileHeader.cs

示例3: Sample

        public Sample(BinaryReader reader)
            : this()
        {
            SourceStart = reader.ReadInt32BE();
            SourceLength = reader.ReadUInt16BE()*2;
            LoopStart = reader.ReadInt32BE();

            Data = new byte[SourceLength];
        }
开发者ID:IllidanS4,项目名称:AmiMus,代码行数:9,代码来源:HippelCOSO.cs

示例4: InstallHandler

        public InstallHandler(BinaryReader stream, BackgroundWorkerEx worker)
        {
            worker?.ReportProgress(0, "Loading \"install\"...");

            stream.ReadBytes(2); // IN

            byte b1 = stream.ReadByte();
            byte b2 = stream.ReadByte();
            short numTags = stream.ReadInt16BE();
            int numFiles = stream.ReadInt32BE();

            int numMaskBytes = (numFiles + 7) / 8;

            List<InstallTag> Tags = new List<InstallTag>();

            for (int i = 0; i < numTags; i++)
            {
                InstallTag tag = new InstallTag();
                tag.Name = stream.ReadCString();
                tag.Type = stream.ReadInt16BE();

                byte[] bits = stream.ReadBytes(numMaskBytes);

                for (int j = 0; j < numMaskBytes; j++)
                    bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023);

                tag.Bits = new BitArray(bits);

                Tags.Add(tag);
            }

            for (int i = 0; i < numFiles; i++)
            {
                InstallEntry entry = new InstallEntry();
                entry.Name = stream.ReadCString();
                entry.MD5 = stream.ReadBytes(16);
                entry.Size = stream.ReadInt32BE();

                InstallData.Add(entry);

                entry.Tags = Tags.FindAll(tag => tag.Bits[i]);

                worker?.ReportProgress((int)((i + 1) / (float)numFiles * 100));
            }
        }
开发者ID:aeo24,项目名称:WoWMap,代码行数:45,代码来源:InstallHandler.cs

示例5: InstallHandler

        public InstallHandler(BinaryReader stream)
        {
            stream.ReadBytes(2); // IN

            byte b1 = stream.ReadByte();
            byte b2 = stream.ReadByte();
            short numTags = stream.ReadInt16BE();
            int numFiles = stream.ReadInt32BE();
            int numMaskBytes = (numFiles + 7) / 8;

            List<InstallTag> Tags = new List<InstallTag>();

            for (int i = 0; i < numTags; i++)
            {
                InstallTag tag = new InstallTag();
                tag.Name = stream.ReadCString();
                tag.Type = stream.ReadInt16BE();

                byte[] bits = stream.ReadBytes(numMaskBytes);

                for (int j = 0; j < numMaskBytes; j++)
                    bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023);

                tag.Bits = new BitArray(bits);
                Tags.Add(tag);
            }

            for (int i = 0; i < numFiles; i++)
            {
                InstallEntry entry = new InstallEntry();
                entry.Name = stream.ReadCString();
                entry.MD5 = stream.Read<MD5Hash>();
                entry.Size = stream.ReadInt32BE();

                InstallData.Add(entry);

                entry.Tags = Tags.FindAll(tag => tag.Bits[i]);
            }
        }
开发者ID:Kruithne,项目名称:W3DT,代码行数:39,代码来源:InstallHandler.cs

示例6: ValidateIndex

        public static void ValidateIndex(string shapefilePath)
        {
            string indexPath = Path.ChangeExtension(shapefilePath, ".shx");

            int posShouldBe = 50, recordNum = 1;
            using (BinaryReader shape = new BinaryReader(new FileStream(shapefilePath, FileMode.Open)))
            using (BinaryReader index = new BinaryReader(new FileStream(indexPath, FileMode.Open)))
            {
                ShapefileHeader shapeHeader = ShapefileHeader.Read(shape);
                ShapefileHeader indexHeader = ShapefileHeader.Read(index);

                if (shapeHeader.FileLength * 2 != new FileInfo(shapefilePath).Length)
                    Console.WriteLine("length");

                if (indexHeader.FileLength * 2 != new FileInfo(indexPath).Length)
                    Console.WriteLine("length");

                while (index.BaseStream.Position < index.BaseStream.Length)
                {
                    int filePos = index.ReadInt32BE();

                    if (filePos != posShouldBe)
                        Console.WriteLine("Ding");

                    int indexContentLength = index.ReadInt32BE();

                    shape.BaseStream.Seek(filePos * 2, SeekOrigin.Begin);

                    int shapeRecordNumber = shape.ReadInt32BE();
                    int shapeContentLength = shape.ReadInt32BE();

                    if (shapeRecordNumber != recordNum++ || shapeContentLength != indexContentLength)
                        Console.WriteLine("Ding");

                    posShouldBe += indexContentLength + 4;
                }
            }
        }
开发者ID:interworks,项目名称:FastShapefile,代码行数:38,代码来源:ValidateShapefile.cs

示例7: DownloadHandler

        public DownloadHandler(BinaryReader stream, BackgroundWorkerEx worker)
        {
            worker?.ReportProgress(0, "Loading \"download\"...");

            stream.Skip(2); // DL

            byte b1 = stream.ReadByte();
            byte b2 = stream.ReadByte();
            byte b3 = stream.ReadByte();

            int numFiles = stream.ReadInt32BE();

            short numTags = stream.ReadInt16BE();

            int numMaskBytes = (numFiles + 7) / 8;

            for (int i = 0; i < numFiles; i++)
            {
                MD5Hash key = stream.Read<MD5Hash>();

                //byte[] unk = stream.ReadBytes(0xA);
                stream.Skip(0xA);

                //var entry = new DownloadEntry() { Index = i, Unk = unk };
                var entry = new DownloadEntry() { Index = i };

                DownloadData.Add(key, entry);

                worker?.ReportProgress((int)((i + 1) / (float)numFiles * 100));
            }

            for (int i = 0; i < numTags; i++)
            {
                DownloadTag tag = new DownloadTag();
                string name = stream.ReadCString();
                tag.Type = stream.ReadInt16BE();

                byte[] bits = stream.ReadBytes(numMaskBytes);

                for (int j = 0; j < numMaskBytes; j++)
                    bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023);

                tag.Bits = new BitArray(bits);

                Tags.Add(name, tag);
            }
        }
开发者ID:WoW-Tools,项目名称:CASCExplorer,代码行数:47,代码来源:DownloadHandler.cs

示例8: ParseIndex

        private void ParseIndex(string idx)
        {
            using (var fs = new FileStream(idx, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            using (var br = new BinaryReader(fs))
            {
                int h2Len = br.ReadInt32();
                int h2Check = br.ReadInt32();
                byte[] h2 = br.ReadBytes(h2Len);

                long padPos = (8 + h2Len + 0x0F) & 0xFFFFFFF0;
                fs.Position = padPos;

                int dataLen = br.ReadInt32();
                int dataCheck = br.ReadInt32();

                int numBlocks = dataLen / 18;

                for (int i = 0; i < numBlocks; i++)
                {
                    IndexEntry info = new IndexEntry();
                    byte[] key = br.ReadBytes(9);
                    byte indexHigh = br.ReadByte();
                    int indexLow = br.ReadInt32BE();

                    info.Index = (indexHigh << 2 | (byte)((indexLow & 0xC0000000) >> 30));
                    info.Offset = (indexLow & 0x3FFFFFFF);
                    info.Size = br.ReadInt32();

                    // duplicate keys wtf...
                    //IndexData[key] = info; // use last key
                    if (!LocalIndexData.ContainsKey(key)) // use first key
                        LocalIndexData.Add(key, info);
                }

                padPos = (dataLen + 0x0FFF) & 0xFFFFF000;
                fs.Position = padPos;

                fs.Position += numBlocks * 18;
                //for (int i = 0; i < numBlocks; i++)
                //{
                //    var bytes = br.ReadBytes(18); // unknown data
                //}

                //if (fs.Position != fs.Length)
                //    throw new Exception("idx file under read");
            }
        }
开发者ID:aeo24,项目名称:WoWMap,代码行数:47,代码来源:LocalIndexHandler.cs

示例9: DownloadHandler

        public DownloadHandler(BinaryReader stream)
        {
            stream.Skip(2); // DL

            byte b1 = stream.ReadByte();
            byte b2 = stream.ReadByte();
            byte b3 = stream.ReadByte();

            int numFiles = stream.ReadInt32BE();

            short numTags = stream.ReadInt16BE();

            int numMaskBytes = numFiles / 8 + (numFiles % 8 > 0 ? 1 : 0);

            for (int i = 0; i < numFiles; i++)
            {
                byte[] key = stream.ReadBytes(0x10);
                byte[] unk = stream.ReadBytes(0xA);
                DownloadEntry entry = new DownloadEntry() { Index = i, Unk = unk };

                DownloadData.Add(key, entry);
            }

            for (int i = 0; i < numTags; i++)
            {
                DownloadTag tag = new DownloadTag();
                string name = stream.ReadCString();
                tag.Type = stream.ReadInt16BE();

                byte[] bits = stream.ReadBytes(numMaskBytes);

                for (int j = 0; j < numMaskBytes; j++)
                    bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023);

                tag.Bits = new BitArray(bits);

                Tags.Add(name, tag);
            }
        }
开发者ID:Kruithne,项目名称:W3DT,代码行数:39,代码来源:DownloadHandler.cs

示例10: SonicArrangerFile

        public SonicArrangerFile(Stream stream)
        {
            var reader = new BinaryReader(stream, Encoding.ASCII);
            string soar = new string(reader.ReadChars(4));
            if(soar != "SOAR")
            {
                stream.Position = 0;
                long start = ReadTo(reader, pcstart);
                int songptr = 0x28;
                int ovtbptr = reader.ReadInt32BE();
                int notbptr = reader.ReadInt32BE();
                int intbptr = reader.ReadInt32BE();
                int syntptr = reader.ReadInt32BE();

                stream.Position = start+songptr;
                int songs = (ovtbptr-songptr)/12;
                Songs = new Song[songs];
                for(int i = 0; i < songs; i++)
                {
                    Songs[i] = new Song(reader);
                }

                stream.Position = start+ovtbptr;
                int voices = (notbptr-ovtbptr)/4;
                Voices = new Voice[voices];
                for(int i = 0; i < voices; i++)
                {
                    Voices[i] = new Voice(reader);
                }

                stream.Position = start+notbptr;
                int notes = (intbptr-notbptr)/4;
                Notes = new Note[notes];
                for(int i = 0; i < notes; i++)
                {
                    Notes[i] = new Note(reader);
                }

                stream.Position = start+intbptr;
                int instrs = (syntptr-intbptr)/152;
                Instruments = new Instrument[instrs];
                for(int i = 0; i < instrs; i++)
                {
                    Instruments[i] = new Instrument(reader);
                }
            }else{
                Version = new string(reader.ReadChars(4));

                string tag;
                while(true)
                {
                    tag = new string(reader.ReadChars(4));
                    switch(tag)
                    {
                        case "STBL":
                            Songs = new SongTable(reader).Songs;
                            break;
                        case "OVTB":
                            Voices = new OverTable(reader).Voices;
                            break;
                        case "NTBL":
                            Notes = new NoteTable(reader).Notes;
                            break;
                        case "INST":
                            Instruments = new InstrumentTable(reader).Instruments;
                            break;
                        default:
                            return;
                    }
                }
            }
        }
开发者ID:IllidanS4,项目名称:AmiMus,代码行数:72,代码来源:SonicArranger.cs

示例11: SongTable

 public SongTable(BinaryReader reader)
 {
     Count = reader.ReadInt32BE();
     Songs = new Song[Count];
     for(int i = 0; i < Count; i++)
     {
         Songs[i] = new Song(reader);
     }
 }
开发者ID:IllidanS4,项目名称:AmiMus,代码行数:9,代码来源:SonicArranger.cs

示例12: OverTable

 public OverTable(BinaryReader reader)
 {
     Count = reader.ReadInt32BE();
     Voices = new Voice[Count*4];
     for(int i = 0; i < Count*4; i++)
     {
         Voices[i] = new Voice(reader);
     }
 }
开发者ID:IllidanS4,项目名称:AmiMus,代码行数:9,代码来源:SonicArranger.cs

示例13: NoteTable

 public NoteTable(BinaryReader reader)
 {
     Count = reader.ReadInt32BE();
     Notes = new Note[Count];
     for(int i = 0; i < Count; i++)
     {
         Notes[i] = new Note(reader);
     }
 }
开发者ID:IllidanS4,项目名称:AmiMus,代码行数:9,代码来源:SonicArranger.cs

示例14: InstrumentTable

 public InstrumentTable(BinaryReader reader)
 {
     Count = reader.ReadInt32BE();
     Instruments = new Instrument[Count];
     for(int i = 0; i < Count; i++)
     {
         Instruments[i] = new Instrument(reader);
     }
 }
开发者ID:IllidanS4,项目名称:AmiMus,代码行数:9,代码来源:SonicArranger.cs

示例15: LoadPng

        public static Texture LoadPng(Stream stream)
        {
            List<byte> idat = new List<byte> ();
            byte bitDepth = 0;
            ColorType colorType = ColorType.Grayscale;
            ByteColor[] palette = null;
            int width = 0, height = 0;
            using (var reader = new BinaryReader (stream)) {
                if (reader.ReadUInt64 () != PNG_SIGNATURE) {
                    throw new Exception ("Not a PNG file");
                }
                string chunktype = "";
                byte[] typeBuf = new byte[4];
                while (chunktype != "IEND") {
                    var length = reader.ReadInt32BE ();
                    reader.Read (typeBuf, 0, 4);
                    chunktype = Encoding.ASCII.GetString (typeBuf);
                    switch (chunktype) {
                    case "IHDR":
                        width = reader.ReadInt32BE ();
                        height = reader.ReadInt32BE ();
                        bitDepth = reader.ReadByte ();
                        colorType = (ColorType)reader.ReadByte ();
                        if (reader.ReadByte () != 0) {
                            throw new Exception (); //Compression method
                        }
                        if (reader.ReadByte () != 0) {
                            throw new Exception (); //Filter method
                        }
                        if (reader.ReadByte () != 0) {
                            throw new NotImplementedException (); //Interlacing
                        }
                        break;
                    case "PLTE":
                        if (length % 3 != 0)
                            throw new Exception (); //Invalid Palette
                        int count = length / 3;
                        palette = new ByteColor[length / 3];
                        for (int i = 0; i < count; i++) {
                            palette [i] = new ByteColor (
                                reader.ReadByte (),
                                reader.ReadByte (),
                                reader.ReadByte (),
                                255);
                        }
                        break;
                    case "tRNS":
                        if (colorType == ColorType.Palette) {
                            for (int i = 0; i < length; i++) {
                                palette [i].A = reader.ReadByte ();
                            }
                        } else {
                            throw new NotImplementedException (); //Are the others BigEndian? Investigate
                        }
                        break;
                    case "IDAT":
                        idat.AddRange (reader.ReadBytes (length));
                        break;
                    default:
                        reader.BaseStream.Seek (length, SeekOrigin.Current);
                        break;
                    }
                    reader.BaseStream.Seek (4, SeekOrigin.Current); //Skip CRC
                }
            }
            byte[] decompressedBytes = null;
            using (var compressedStream = new MemoryStream (idat.ToArray (), 2, idat.Count - 6)) { //skip zlib header
                using (var decompressedStream = new MemoryStream ()) {
                    try {
                        using (var deflateStream = new DeflateStream (compressedStream, CompressionMode.Decompress)) {
                            deflateStream.CopyTo (decompressedStream);
                        }
                        decompressedBytes = decompressedStream.ToArray ();
                    } catch (Exception exception) {
                        throw new Exception ("An error occurred during DEFLATE decompression.", exception);
                    }
                }

            }
            var scanlines = GetScanlines (decompressedBytes, bitDepth, colorType, width);
            var colors = GetData (scanlines, width, height, colorType, bitDepth, palette);
            var texture = new Texture (width, height);
            texture.SetData (colors, null);
            return texture;
        }
开发者ID:CallumDev,项目名称:BubbleEngine,代码行数:85,代码来源:PngLoader.cs


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