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


C# EndianBinaryWriter.Write方法代码示例

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


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

示例1: Write

 public override void Write(EndianBinaryWriter er, CGFXWriterContext c)
 {
     base.Write(er, c);
     if (TextureImage != null) er.Write((uint)4);
     else er.Write((uint)0);
     if (TextureImage != null) TextureImage.Write(er, c);
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:7,代码来源:TXOB.cs

示例2: ToBytes

        public byte[] ToBytes()
        {
            var memory = new MemoryStream();
            var writer = new EndianBinaryWriter(EndianBitConverter.Big, memory);

            switch (Format)
            {
                case BasicHeader.HeaderFormats.F0: //11 bytes
                    writer.Write(EndianBitConverter.Big.GetBytes(TimeStamp), 1, 3);
                    writer.Write(EndianBitConverter.Big.GetBytes(MessageLength), 1, 3);
                    writer.Write((byte) MessageType);
                    writer.Write(EndianBitConverter.Little.GetBytes(MessageStreamId));
                    break;
                case BasicHeader.HeaderFormats.F1: //7 bytes
                    writer.Write(EndianBitConverter.Big.GetBytes(TimeStamp), 1, 3);
                    writer.Write(EndianBitConverter.Big.GetBytes(MessageLength), 1, 3);
                    writer.Write((byte) MessageType);
                    break;
                case BasicHeader.HeaderFormats.F2: //3 bytes
                    writer.Write(EndianBitConverter.Big.GetBytes(TimeStamp), 1, 3);
                    break;
                case BasicHeader.HeaderFormats.F3: //No bytes
                    break;
            }
            return memory.ToArray();
        }
开发者ID:Austech,项目名称:RtmpSharp2,代码行数:26,代码来源:MessageHeader.cs

示例3: Prepare

 protected override void Prepare(EndianBinaryWriter w)
 {
     WriteString8(w, ServerID);
     WriteVarInt(w, PublicKey.Length);
     w.Write(PublicKey);	
     WriteVarInt(w, VerifyToken.Length);
     w.Write(VerifyToken);         
 }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:8,代码来源:EncryptionRequest.cs

示例4: Prepare

 protected override void Prepare(EndianBinaryWriter w)
 {
     BlockPosition.Write(w);
     w.Write((byte)FaceDirection);
     SlotItem.Write(w, this.Item);
     w.Write((byte)CursorX);
     w.Write((byte)CursorY);
     w.Write((byte)CursorZ);
 }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:9,代码来源:PlayerBlockPlacement.cs

示例5: WriteString16

 static void WriteString16(EndianBinaryWriter writer, string message)
 {   
     byte[] buffer = Encoding.BigEndianUnicode.GetBytes(message);
     short length = (short)(buffer.Length / 2);
     if (message.Length != length)
         throw new InvalidProgramException();
     writer.Write(length);
     writer.Write(buffer);
 }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:9,代码来源:LegacyStatus.cs

示例6: ToByteArray

        public byte[] ToByteArray()
        {
            using (MemoryStream buffer = new MemoryStream(16))
            {
                using (EndianBinaryWriter bw = new EndianBinaryWriter(new BigEndianBitConverter(), buffer))
                {
                    bw.Write(connection_id);
                    bw.Write(action);
                    bw.Write(transaction_id);
                }

                return buffer.ToArray();
            }
        }
开发者ID:Dozey,项目名称:Distribution2,代码行数:14,代码来源:UdpConnectRequestPacket.cs

示例7: Save

		public override void Save()
		{
			using (
				var writer = new EndianBinaryWriter(EndianBitConverter.Little,
				                                    File.Open(FilePath, FileMode.Create, FileAccess.Write)))
			{
				foreach (NamedColor c in this)
				{
					writer.Write(c.Color.R);
					writer.Write(c.Color.G);
					writer.Write(c.Color.B);
				}
			}
		}
开发者ID:NovusTheory,项目名称:mcskin3d,代码行数:14,代码来源:ACTSwatch.cs

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

示例9: WriteIMAGBlock

 public void WriteIMAGBlock(EndianBinaryWriter er)
 {
     //long basepos = er.BaseStream.Position;
     er.Write("IMAG", Encoding.ASCII, false);
     er.Write((uint)GetIMAGBlockSize());
     foreach (var v in IMAGBlockEntries)
     {
         long curpos = er.BaseStream.Position;
         er.BaseStream.Position = v.Key;
         er.Write((uint)(curpos - v.Key));
         er.BaseStream.Position = curpos;
         er.Write(v.Value, 0, v.Value.Length);
         while ((er.BaseStream.Position % 128) != 0) er.Write((byte)0);
     }
     while ((er.BaseStream.Position % 64) != 0) er.Write((byte)0);
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:16,代码来源:CGFXWriterContext.cs

示例10: Encode

        /// <inheritdoc/>
        public void Encode(ImageBase image, Stream stream)
        {
            Guard.NotNull(image, nameof(image));
            Guard.NotNull(stream, nameof(stream));

            int imageWidth = image.Width;
            int imageHeight = image.Height;
            ushort max = JpegConstants.MaxLength;

            if (imageWidth > max || imageHeight > max)
            {
                throw new ImageFormatException($"Image dimensions exceed maximum allowable bounds of {max}px.");
            }

            using (EndianBinaryWriter writer = new EndianBinaryWriter(new BigEndianBitConverter(), stream))
            {
                this.WriteApplicationHeader(image, writer);
                this.WriteDescreteQuantizationTables(writer);
                this.WriteStartOfFrame(image, writer);
                this.WriteHuffmanTables(writer);
                this.WriteStartOfScan(image, writer);

                writer.Write(new[] { JpegConstants.Markers.XFF, JpegConstants.Markers.EOI });
            }
        }
开发者ID:joaonlopes,项目名称:ThumbnailCreator,代码行数:26,代码来源:JpegEncoder2.cs

示例11: Prepare

 protected override void Prepare(EndianBinaryWriter w)
 {
     WriteVarInt(w, (int)Version);
     WriteString8(w, Host);
     w.Write((ushort)Port);
     WriteVarInt(w, (int)State);
 }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:7,代码来源:Handshake.cs

示例12: BuildPacket

        public static byte[] BuildPacket(Packets.LicensePlatePacket plateExpected)
        {
            var mem = new MemoryStream();
            var writer = new EndianBinaryWriter(Configuration.EndianBitConverter, mem, Configuration.Encoding);

            var licenseBytes = Configuration.Encoding.GetBytes(plateExpected.LicensePlate.LicenseNumber);

            writer.Write(licenseBytes);
            writer.Write(01u);
            writer.Write((UInt32)plateExpected.CaptureTime.ToBinary());
            writer.Write((UInt32)plateExpected.CaptureLocation.Id);

            int imgCount = plateExpected.EvidenceImageData.Count;
            writer.Write((uint)imgCount);

            var imgData = plateExpected.EvidenceImageData;
            for (int i = 0; i < imgCount; ++i)
            {
                writer.Write((uint)imgData[i].Length);
            }

            for (int i = 0; i < imgCount; ++i)
            {
                writer.Write(imgData[i]);
            }

            return mem.ToArray();
        }
开发者ID:vanan08,项目名称:damany,代码行数:28,代码来源:PacketGenerator.cs

示例13: Write

 public void Write(EndianBinaryWriter er)
 {
     long offpos = er.BaseStream.Position;
     //header.Write(er, 0);
     er.Write(Signature, Encoding.ASCII, false);
     er.Write((uint)0);
     dict.Write(er);
     for (int i = 0; i < models.Length; i++)
     {
         dict[i].Value.Offset = (uint)(er.BaseStream.Position - offpos);
         models[i].Write(er);
     }
     long curpos = er.BaseStream.Position;
     er.BaseStream.Position = offpos + 4;
     er.Write((UInt32)(curpos - offpos));
     dict.Write(er);
     er.BaseStream.Position = curpos;
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:18,代码来源:MDL0.cs

示例14: ToBytes

        public byte[] ToBytes()
        {
            MHeader.Format = BHeader.Format;
            MHeader.MessageLength = 0;
            if (Data != null)
            {
                MHeader.MessageLength = Data.Length;
            }

            var memory = new MemoryStream();
            var writer = new EndianBinaryWriter(EndianBitConverter.Big, memory);
            writer.Write(BHeader.ToBytes());
            writer.Write(MHeader.ToBytes());
            if (Data != null)
            {
                writer.Write(Data);
            }
            return memory.ToArray();
        }
开发者ID:Austech,项目名称:RtmpSharp2,代码行数:19,代码来源:Chunk.cs

示例15: ToByteArray

        public byte[] ToByteArray()
        {
            using(MemoryStream buffer = new MemoryStream(16 + (20 * info_hash.Length)))
            {
                using(EndianBinaryWriter bw = new EndianBinaryWriter(new BigEndianBitConverter(), buffer))
                {
                    bw.Write(connection_id);
                    bw.Write(action);
                    bw.Write(transaction_id);

                    for (int i = 0; i < info_hash.Length; i++)
                    {
                        bw.Write(info_hash[i]);
                    }
                }

                return buffer.ToArray();
            }
        }
开发者ID:Dozey,项目名称:Distribution2,代码行数:19,代码来源:UdpScrapeRequestPacket.cs


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