本文整理汇总了C#中EndianBinaryWriter类的典型用法代码示例。如果您正苦于以下问题:C# EndianBinaryWriter类的具体用法?C# EndianBinaryWriter怎么用?C# EndianBinaryWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EndianBinaryWriter类属于命名空间,在下文中一共展示了EndianBinaryWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: writeWmfAuxPixelData
private static void writeWmfAuxPixelData(EndianBinaryWriter writer, WmfFile file, WmfPixelInfo pixel)
{
if (file.header.auxDataType > 0)
{
writer.Write(pixel.waterTypeId);
writer.Write(pixel.waterBodyIndex);
}
}
示例2: Update
static void Update(object o)
{
int count = 0;
int max = MinecraftServer.MaxSlots;
List<string> players = new List<string>();
foreach (Client p in PlayerList.List)
{
if (p.MinecraftUsername == "Player")
continue;
if (p.Settings.Cloaked != null)
continue;
count ++;
players.Add(p.Name);
if (p.Session is VanillaSession == false)
max ++;
}
using (MemoryStream ms = new MemoryStream())
{
ms.WriteByte(0xff);
EndianBinaryWriter w = new EndianBinaryWriter(EndianBitConverter.Big, ms);
WriteString16(w,
"§1\0" +
((int)MinecraftServer.FrontendVersion).ToString() + "\0" +
MinecraftServer.FrontendVersion.ToText() + "\0" +
(MinecraftServer.PingReplyMessage ?? "Hi") + "\0" +
count + "\0" + max);
cache = ms.ToArray();
//Debug.WriteLine(BitConverter.ToString(cache));
}
}
示例3: SaveGame
public void SaveGame()
{
if (isSaving()) {
Log.Debug("Already doing a save: " + tempSavePath);
}
String name = Guid.NewGuid().ToString();
Log.Debug("Request save: " + name);
currentSaveData = new MemoryStream();
BZip2Stream bzip = new BZip2Stream(currentSaveData, CompressionMode.Compress);
saveWriter = new EndianBinaryWriter(new BigEndianBitConverter(),bzip, Encoding.UTF8);
saveWriter.Write((byte)formatVersion);
saveWriter.Write(Singleton<SimulationManager>.instance.m_metaData.m_CityName);
saveWriter.Write(Singleton<EconomyManager>.instance.LastCashAmount);
saveWriter.Write(Singleton<EconomyManager>.instance.LastCashDelta);
int population = (int)Singleton<DistrictManager>.instance.m_districts.m_buffer[0].m_populationData.m_finalCount;
saveWriter.Write(population);
var timeSpan = (Singleton<SimulationManager>.instance.m_currentGameTime - new DateTime(1970, 1, 1, 0, 0, 0));
saveWriter.Write(timeSpan.TotalSeconds);
SavePanel savePanel = UIView.library.Get<SavePanel>("SavePanel");
tempSavePath = Path.Combine(DataLocation.saveLocation, name + ".crp");
savePanel.SaveGame(name);
WaitForSave();
}
示例4: 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);
}
示例5: ByteBuffer
//Constructors
public ByteBuffer()
{
stream = new MemoryStream();
bitConverter = new LittleEndianBitConverter();
writer = new EndianBinaryWriter(bitConverter, stream);
reader = new EndianBinaryReader(bitConverter, stream);
}
示例6: 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();
}
示例7: Convert
public void Convert(EndianBinaryWriter writer)
{
var jbtWriter = new JbtWriter(writer);
var zf = new ZipFile(jarFile);
foreach (ZipEntry ze in zf)
{
if (!ze.IsFile) continue;
if (!ze.Name.EndsWith(".class")) continue;
var type = new CompileTypeInfo();
type.Read(zf.GetInputStream(ze));
var reader = new BinaryReader(zf.GetInputStream(ze));
var buffer = new byte[ze.Size];
reader.Read(buffer, 0, (int)ze.Size);
jbtWriter.Write(type.Name, buffer);
}
jbtWriter.Flush();
}
示例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: 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();
}
示例10: ToByteArray
public byte[] ToByteArray()
{
using (MemoryStream buffer = new MemoryStream(100))
{
using (EndianBinaryWriter bw = new EndianBinaryWriter(new BigEndianBitConverter(), buffer))
{
bw.Write(connection_id);
bw.Write(action);
bw.Write(transaction_id);
bw.Write(info_hash);
bw.Write(peer_id);
bw.Write(downloaded);
bw.Write(left);
bw.Write(uploaded);
bw.Write(clientEvent);
bw.Write(ip.GetAddressBytes());
bw.Write(key);
bw.Write(num_want);
bw.Write(port);
bw.Write(extensions);
}
return buffer.ToArray();
}
}
示例11: Prepare
protected override void Prepare(EndianBinaryWriter w)
{
WriteVarInt(w, (int)Version);
WriteString8(w, Host);
w.Write((ushort)Port);
WriteVarInt(w, (int)State);
}
示例12: 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 });
}
}
示例13: Prepare
protected override void Prepare(EndianBinaryWriter w)
{
WriteString8(w, ServerID);
WriteVarInt(w, PublicKey.Length);
w.Write(PublicKey);
WriteVarInt(w, VerifyToken.Length);
w.Write(VerifyToken);
}
示例14: testWriteString16_nullstring
public void testWriteString16_nullstring()
{
// test that a null string writes no output.
MemoryStream stream = new MemoryStream();
EndianBinaryWriter writer = new EndianBinaryWriter(stream);
writer.WriteString16(null);
Assert.AreEqual(0, stream.Length);
}
示例15: Prepare
protected override void Prepare (EndianBinaryWriter w)
{
throw new NotImplementedException();
/*
WriteString8(w, Channel);
Varint w.Write((short)Data.Length);
w.Write(Data); */
}