本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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 });
}
}
示例11: Prepare
protected override void Prepare(EndianBinaryWriter w)
{
WriteVarInt(w, (int)Version);
WriteString8(w, Host);
w.Write((ushort)Port);
WriteVarInt(w, (int)State);
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
}