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


C# EndianBinaryReader.Close方法代码示例

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


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

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

示例2: PaletteFile

        public PaletteFile(string filename)
        {
            EndianBinaryReader reader = new EndianBinaryReader(EndianBitConverter.Big, File.Open(filename, FileMode.Open));

            while (true)
            {
                int blockLength = 0;
                PaletteBlockType blockType = (PaletteBlockType)reader.ReadInt32();
                blockLength = reader.ReadInt32();

                switch (blockType)
                {
                    case PaletteBlockType.Attributes:

                        //contains name of palette and some attributes
                        //we dont care about this
                        reader.Seek(blockLength, SeekOrigin.Current);
                        break;

                    case PaletteBlockType.PixelData:
                        int entryCount = reader.ReadInt32();
                        int bytesPerEntry = reader.ReadInt32();
                        _paletteData = reader.ReadBytes(entryCount * bytesPerEntry);

                        break;

                    case PaletteBlockType.Null:
                        break;

                    default:
                        reader.Seek(blockLength, SeekOrigin.Current);
                        break;
                }
                if (reader.BaseStream.Position == reader.BaseStream.Length)
                    break;
            }

            reader.Close();
        }
开发者ID:sikora507,项目名称:OpenC1,代码行数:39,代码来源:PaletteFile.cs

示例3: ActFile

        public ActFile(string filename)
        {
            Stream file = OpenDataFile(filename);
            if (!Exists)
                return;

            EndianBinaryReader reader = new EndianBinaryReader(EndianBitConverter.Big, file);

            CActor currentActor = null;
            Stack<CActor> actorStack = new Stack<CActor>();
            List<CActor> flatActorList = new List<CActor>();

            while (true)
            {
                int blockLength = 0;
                ActorBlockType blockType = (ActorBlockType)reader.ReadInt32();
                blockLength = reader.ReadInt32();

                switch (blockType)
                {
                    case ActorBlockType.Name:

                        currentActor = new CActor();

                        if (actorStack.Count == 0)
                        {
                            _actors.Add(currentActor);
                        }
                        else
                        {
                            CActor parent = actorStack.Peek();
                            currentActor.Parent = parent;
                            parent.Children.Add(currentActor);
                        }

                        flatActorList.Add(currentActor);
                        actorStack.Push(currentActor);

                        currentActor.Flags = reader.ReadBytes(2);
                        currentActor.SetName(ReadNullTerminatedString(reader));
                        break;

                    case ActorBlockType.TransformMatrix:

                        Matrix matrix = new Matrix();
                        matrix.M11 = reader.ReadSingle();
                        matrix.M12 = reader.ReadSingle();
                        matrix.M13 = reader.ReadSingle();
                        matrix.M21 = reader.ReadSingle();
                        matrix.M22 = reader.ReadSingle();
                        matrix.M23 = reader.ReadSingle();
                        matrix.M31 = reader.ReadSingle();
                        matrix.M32 = reader.ReadSingle();
                        matrix.M33 = reader.ReadSingle();
                        matrix.M41 = reader.ReadSingle();
                        matrix.M42 = reader.ReadSingle();
                        matrix.M43 = reader.ReadSingle();
                        matrix.M44 = 1;

                        currentActor.Matrix = matrix;

                        break;

                    case ActorBlockType.HierarchyStart:
                        //Debug.WriteLine("Hierarchy start");
                        break;

                    case ActorBlockType.ActorEnd:
                        actorStack.Pop();
                        //Debug.WriteLine("Hierarchy end");
                        break;

                    case ActorBlockType.MaterialNames:
                        currentActor.MaterialName = ReadNullTerminatedString(reader);
                        break;

                    case ActorBlockType.ModelName:
                        string modelName = ReadNullTerminatedString(reader);
                        currentActor.ModelName = modelName;
                        break;

                    case ActorBlockType.BoundingBox:
                        currentActor.BoundingBox = new BoundingBox(
                            new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()) * GameVars.Scale,
                            new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()) * GameVars.Scale
                            );
                        break;

                    case ActorBlockType.Null:
                        break;

                    default:
                        reader.Seek(blockLength, SeekOrigin.Current);
                        break;
                }
                if (reader.BaseStream.Position == reader.BaseStream.Length)
                    break;
            }
            reader.Close();

//.........这里部分代码省略.........
开发者ID:sikora507,项目名称:OpenC1,代码行数:101,代码来源:ActFile.cs

示例4: MatFile

        public MatFile(string filename)
        {
            Stream file = OpenDataFile(filename);
            if (!Exists)
                return;

            EndianBinaryReader reader = new EndianBinaryReader(EndianBitConverter.Big, file);

            CMaterial currentMaterial = null;

            while (true)
            {
                int blockLength = 0;
                MaterialBlockType blockType = (MaterialBlockType)reader.ReadInt32();
                blockLength = reader.ReadInt32();

                byte[] flags;

                switch (blockType)
                {
                    case MaterialBlockType.Attributes:
                        currentMaterial = new CMaterial();
                        _materials.Add(currentMaterial);

                        byte[] color = reader.ReadBytes(4);
                        byte[] otherColors = reader.ReadBytes(16);
                        flags = reader.ReadBytes(2);
                        byte[] transform = reader.ReadBytes(24);
                        currentMaterial.SimpMatPixelIndex = reader.ReadByte();
                        currentMaterial.SimpMatGradientCount = reader.ReadByte();

                        currentMaterial.DoubleSided = flags[0] == 0x10;
                        currentMaterial.Name = ReadNullTerminatedString(reader);

                        break;

                    case MaterialBlockType.AttributesV2:
                        currentMaterial = new CMaterial();
                        _materials.Add(currentMaterial);

                        reader.ReadBytes(4); //color
                        reader.ReadBytes(16); //othercolors
                        flags = reader.ReadBytes(4); // flags
                        reader.ReadBytes(24); //transform
                        reader.ReadBytes(4); //unk
                        currentMaterial.DoubleSided = flags[0] == 0x10;
                        reader.BaseStream.Position += 13;
                        currentMaterial.Name = ReadNullTerminatedString(reader);

                        break;

                    case MaterialBlockType.TextureName:
                        currentMaterial.PixName = ReadNullTerminatedString(reader);
                        break;

                    case MaterialBlockType.TabName:
                        string tabName = ReadNullTerminatedString(reader);
                        break;

                    case MaterialBlockType.Null:
                        break;

                    default:
                        reader.Seek(blockLength, SeekOrigin.Current);
                        break;
                }
                if (reader.BaseStream.Position == reader.BaseStream.Length)
                    break;
            }

            reader.Close();
        }
开发者ID:sikora507,项目名称:OpenC1,代码行数:72,代码来源:MatFile.cs

示例5: Extract

        static void Extract(string FileName, EndianBinary.Endian Endian)
        {
            FileStream Input = new FileStream(FileName, FileMode.Open);
            EndianBinaryReader Reader = new EndianBinaryReader(Input, Endian);

            byte b = Reader.ReadByte();
            MemoryStream SignatureBuffer = new MemoryStream();
            while (b != 0)
            {
                SignatureBuffer.WriteByte(b);
                b = Reader.ReadByte();
            }
            string Signature = Encoding.ASCII.GetString(SignatureBuffer.ToArray());
            SignatureBuffer.Dispose();
            Reader.BaseStream.Seek(8, SeekOrigin.Begin); //Pula parte da assinatura

            if (Signature != "MSSG")
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Invalid file!");
                Console.ResetColor();
            }

            string OutDir = Path.GetFileNameWithoutExtension(FileName);
            Directory.CreateDirectory(OutDir);

            ulong FileCount = Reader.ReadUInt64();
            ulong FileLength = Reader.ReadUInt64();
            Reader.ReadUInt64(); //??? 0x800

            for (ulong Entry = 0; Entry < FileCount; Entry++)
            {
                Input.Seek((long)(0x20 + Entry * 0x20), SeekOrigin.Begin);

                ulong Offset = Reader.ReadUInt64();
                ulong Length1 = Reader.ReadUInt64();
                ulong Length2 = Reader.ReadUInt64();
                Reader.ReadUInt64(); //Padding

                Input.Seek((long)Offset, SeekOrigin.Begin);
                byte[] Buffer = new byte[Length1];
                Reader.Read(Buffer, 0, Buffer.Length);

                string SubFileSignature = Encoding.ASCII.GetString(Buffer, 0, 4);
                bool IsLangFile = SubFileSignature == "LANG";
                File.WriteAllBytes(Path.Combine(OutDir, "file_" + Entry.ToString() + (IsLangFile ? ".lang" : ".bin")), Buffer);
            }

            Reader.Close();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Extracted all files from " + Path.GetFileName(FileName) + "!");
            Console.ResetColor();
        }
开发者ID:gdkchan,项目名称:DOA5Tool,代码行数:54,代码来源:Program.cs

示例6: Dump

        static void Dump(string FileName, EndianBinary.Endian Endian)
        {
            string OutFile = Path.GetFileNameWithoutExtension(FileName) + ".txt";
            StringBuilder Output = new StringBuilder();

            FileStream Input = new FileStream(FileName, FileMode.Open);
            EndianBinaryReader Reader = new EndianBinaryReader(Input, Endian);

            Section Lang = ParseSection(Reader);
            if (Lang.Signature != "LANG")
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Invalid file!");
                Console.ResetColor();
            }

            Input.Seek(ParsePack(Reader, Lang)[0].Offset, SeekOrigin.Begin);
            Section Category = ParseSection(Reader);
            Input.Seek(ParsePack(Reader, Category)[0].Offset, SeekOrigin.Begin);
            Section String = ParseSection(Reader);
            List<PackEntry> StringPack = ParsePack(Reader, String);

            foreach (PackEntry Entry in StringPack)
            {
                Input.Seek(Entry.Offset, SeekOrigin.Begin);

                byte[] Buffer = new byte[Entry.Length - 2];
                Reader.Read(Buffer, 0, Buffer.Length);
                Output.Append(UTF16.GetString(Buffer, Endian));
                Output.AppendLine(null);
                Output.AppendLine(null);
            }

            File.WriteAllText(OutFile, Output.ToString().TrimEnd());

            Reader.Close();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Dumped " + Path.GetFileName(FileName) + "!");
            Console.ResetColor();
        }
开发者ID:gdkchan,项目名称:DOA5Tool,代码行数:41,代码来源:Program.cs

示例7: DatFile

        public DatFile(string filename, bool deformMainModel)
        {
            if (filename.EndsWith(".ACT", StringComparison.InvariantCultureIgnoreCase))
                filename = filename.ToUpper().Replace(".ACT", ".DAT"); //fix up some 3rd party vehicle weirdness

            CModel currentModel = null;

            Stream file = OpenDataFile(filename);
            if (!Exists)
                return;

            EndianBinaryReader reader = new EndianBinaryReader(EndianBitConverter.Big, file);

            while (true)
            {
                int type = reader.ReadInt32();
                int size = 0;
                if (type != (int)BlockType.Null)
                    size = reader.ReadInt32();

                switch (type)
                {
                    case (int)BlockType.Null:
                        break;

                    case (int)BlockType.ModelName:
                        reader.Seek(2, SeekOrigin.Current);
                        string name = ReadNullTerminatedString(reader);

                        if (deformMainModel && Path.GetFileNameWithoutExtension(name).Equals(Path.GetFileNameWithoutExtension(filename), StringComparison.InvariantCultureIgnoreCase))
                            currentModel = new CDeformableModel();
                        else
                            currentModel = new CModel();

                        currentModel.Name = name;
                        _models.Add(currentModel);

                        break;

                    case (int)BlockType.Vertices:
                        ReadVertexBlock(reader, currentModel);
                        break;

                    case (int)BlockType.Faces:
                        ReadPolygonBlock(reader, currentModel);
                        break;

                    case (int)BlockType.TextureCoords:
                        ReadTextureMapBlock(reader, currentModel);
                        break;

                    case (int)BlockType.Materials:
                        ReadMaterialsBlock(reader, currentModel);
                        break;

                    case (int)BlockType.FaceMaterials:
                        ReadFaceMaterialsBlock(reader, currentModel);
                        break;

                    default:
                        Debug.WriteLine("Unknown section: " + type);
                        reader.Seek(size, SeekOrigin.Current);
                        break;
                }

                if (reader.BaseStream.Position == reader.BaseStream.Length)
                    break;
            }

            reader.Close();
            if (filename == "FAUST.DAT")
            {
            }
            _models.Resolve(true);
        }
开发者ID:sikora507,项目名称:OpenC1,代码行数:75,代码来源:DatFile.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: PixFile


//.........这里部分代码省略.........

                switch (blockType)
                {
                    case PixBlockType.Attributes:

                        int type = reader.ReadByte();
                        if (type == 7)
                        {
                            /* bmp palette data? - seen in some splat pack textures. Jump over it, and its pixel data */
                            reader.Seek(blockLength-1, SeekOrigin.Current);
                            _skipNextPixelSection = true;
                            break;
                        }
                        currentPix = new PixMap();
                        currentPix.Width = reader.ReadInt16();
                        int width2 = reader.ReadInt16();
                        currentPix.Height = reader.ReadInt16();

                        byte[] unk2 = reader.ReadBytes(4);
                        currentPix.Name = ReadNullTerminatedString(reader);
                        _pixMaps.Add(currentPix);
                        break;

                    case PixBlockType.PixelData:

                        if (_skipNextPixelSection)
                        {
                            reader.Seek(blockLength, SeekOrigin.Current);
                            _skipNextPixelSection = false;
                            break;
                        }
                        int pixelCount = reader.ReadInt32();
                        int bytesPerPixel = reader.ReadInt32();
                        if (bytesPerPixel > 3)
                        {
                            bytesPerPixel = 1;  //PixEd sometimes doesnt get this right
                        }

                        if (currentPix == null)
                        {
                            int size = (int)Math.Sqrt(pixelCount);
                            currentPix = new PixMap();
                            currentPix.Name = Path.GetFileName(filename);
                            currentPix.Width = size;
                            currentPix.Height = size;
                            _pixMaps.Add(currentPix);
                        }

                        byte[] pixels = reader.ReadBytes(pixelCount * bytesPerPixel);
                        Texture2D texture=null;

                        if (bytesPerPixel == 1)
                        {
                            texture = new Texture2D(Engine.Device, currentPix.Width, currentPix.Height, 1, TextureUsage.None, SurfaceFormat.Color);
                            texture.SetData<byte>(Helpers.GetBytesForImage(pixels, currentPix.Width, currentPix.Height, GameVars.Palette));
                        }
                        else if (bytesPerPixel == 2)
                        {
                            texture = new Texture2D(Engine.Device, currentPix.Width, currentPix.Height, 1, TextureUsage.None, SurfaceFormat.Bgr565);
                            int j = 0;
                            byte[] px = new byte[2];
                            for (int i = 0; i < pixels.Length; i += 2)
                            {
                                byte tmp = pixels[i + 1];
                                pixels[i + 1] = pixels[i];
                                pixels[i] = tmp;
                            }
                            texture.SetData<byte>(pixels);
                        }
                        else if (bytesPerPixel ==3 )
                        {
                            texture = new Texture2D(Engine.Device, currentPix.Width, currentPix.Height, 1, TextureUsage.None, SurfaceFormat.Color);
                            int j = 0;
                            byte[] px2 = new byte[pixels.Length * 4];
                            for (int i = 0; i < pixels.Length; i += 3)
                            {
                                px2[j++] = pixels[i];
                                px2[j++] = pixels[i+1];
                                px2[j++] = pixels[i+2];
                                px2[j++] = 255;
                            }
                            texture.SetData<byte>(px2);
                        }

                        currentPix.Texture = texture;
                        break;

                    case PixBlockType.Null:
                        break;

                    default:
                        reader.Seek(blockLength, SeekOrigin.Current);
                        break;
                }
                if (reader.BaseStream.Position+3 >= reader.BaseStream.Length)
                    break;
            }

            reader.Close();
        }
开发者ID:sikora507,项目名称:OpenC1,代码行数:101,代码来源:PixFile.cs


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