本文整理汇总了C#中System.IO.BinaryReader.ReadInt16方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadInt16方法的具体用法?C# BinaryReader.ReadInt16怎么用?C# BinaryReader.ReadInt16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadInt16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadFromStream
public void LoadFromStream(BinaryReader reader)
{
this.First = reader.ReadInt16();
this.Second = reader.ReadInt16();
this.UseLine = reader.ReadInt16();
this.Third = reader.ReadInt16();
}
示例2: WaveHeaderIN
//public ushort MaxAudioLevel;
private static WaveProcessor WaveHeaderIN(char Digit)
{
String Path = HttpContext.Current.Server.MapPath(String.Format("~/Epayment/DigitVoice/{0}.WAV", Digit));
FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
try
{
WaveProcessor Header = new WaveProcessor {Length = (int) fs.Length - 8};
fs.Position = 22;
Header.Channels = br.ReadInt16(); //1
fs.Position = 24;
Header.SampleRate = br.ReadInt32(); //8000
fs.Position = 34;
Header.BitsPerSample = br.ReadInt16(); //16
Header.DataLength = (int)fs.Length - 44;
byte[] arrfile = new byte[fs.Length - 44];
fs.Position = 44;
fs.Read(arrfile, 0, arrfile.Length);
return Header;
}
finally
{
br.Close();
fs.Close();
}
}
示例3: IPHeader
private ushort usTotalLength; //Шестнадцать битов для общей длины датаграммы (заголовок + сообщение)
#endregion Fields
#region Constructors
public IPHeader(byte[] byBuffer, int nReceived)
{
try
{
MemoryStream memoryStream = new MemoryStream(byBuffer, 0, nReceived);
BinaryReader binaryReader = new BinaryReader(memoryStream);
byVersionAndHeaderLength = binaryReader.ReadByte();
byDifferentiatedServices = binaryReader.ReadByte();
usTotalLength = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
usIdentification = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
usFlagsAndOffset = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
byTTL = binaryReader.ReadByte();
byProtocol = binaryReader.ReadByte();
sChecksum = IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
uiSourceIPAddress = (uint)(binaryReader.ReadInt32());
uiDestinationIPAddress = (uint)(binaryReader.ReadInt32());
byHeaderLength = byVersionAndHeaderLength;
byHeaderLength <<= 4;
byHeaderLength >>= 4;
byHeaderLength *= 4;
Array.Copy(byBuffer, byHeaderLength, byIPData, 0, usTotalLength - byHeaderLength);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
示例4: Read
/// <summary>
/// The read.
/// </summary>
/// <param name="client">
/// </param>
/// <param name="packet">
/// </param>
public static void Read(Client client, byte[] packet)
{
LogUtil.Debug(DebugInfoDetail.Network, "\r\nReceived:\r\n" + HexOutput.Output(packet));
MemoryStream m_stream = new MemoryStream(packet);
BinaryReader m_reader = new BinaryReader(m_stream);
// now we should do password check and then send OK or Error
// sending OK now
m_stream.Position = 8;
short userNameLength = IPAddress.NetworkToHostOrder(m_reader.ReadInt16());
string userName = Encoding.ASCII.GetString(m_reader.ReadBytes(userNameLength));
short loginKeyLength = IPAddress.NetworkToHostOrder(m_reader.ReadInt16());
string loginKey = Encoding.ASCII.GetString(m_reader.ReadBytes(loginKeyLength));
LoginEncryption loginEncryption = new LoginEncryption();
if (loginEncryption.IsValidLogin(loginKey, client.ServerSalt, userName))
{
client.IsBot = true;
byte[] chars = AccountCharacterList.Create(userName);
LogUtil.Debug(DebugInfoDetail.Network, "\r\nReceived:\r\n" + HexOutput.Output(chars));
client.Send(chars);
}
else
{
byte[] loginerr = LoginError.Create();
client.Send(loginerr);
client.Server.DisconnectClient(client);
}
}
示例5: Load
// As found in .DAT archives (RESOURCE.DAT, IO.DAT)
public void Load(string destinationDirectory, string baseName, BinaryReader binaryReader)
{
xOffset = binaryReader.ReadInt16();
yOffset = binaryReader.ReadInt16();
binaryReader.BaseStream.Seek(4, SeekOrigin.Current);
width = binaryReader.ReadUInt16();
height = binaryReader.ReadUInt16();
binaryReader.BaseStream.Seek(2, SeekOrigin.Current);
uint length = binaryReader.ReadUInt32();
var imageOffset = binaryReader.BaseStream.Position;
var rowDataOffsets = new ushort[height];
for (int i = 0; i < height; ++i) {
rowDataOffsets[i] = binaryReader.ReadUInt16();
}
var bmp = new Bmp(width, height);
var imageData = binaryReader.ReadBytes((int)length - 2*height);
ReadImage(imageData, rowDataOffsets, false, bmp.Data);
Debug.Assert(binaryReader.BaseStream.Position - imageOffset == length);
bmp.Save(Path.Combine(destinationDirectory, baseName), ImageFormat);
Bmp.SaveOffsets(baseName, xOffset, yOffset);
}
示例6: ItemBounds
static ItemBounds()
{
m_Bounds = new Rectangle2D[TileData.ItemTable.Length];
if (File.Exists("Data/Binary/Bounds.bin"))
{
using (FileStream fs = new FileStream("Data/Binary/Bounds.bin", FileMode.Open, FileAccess.Read, FileShare.Read))
{
BinaryReader bin = new BinaryReader(fs);
int count = Math.Min(m_Bounds.Length, (int)(fs.Length / 8));
for (int i = 0; i < count; ++i)
{
int xMin = bin.ReadInt16();
int yMin = bin.ReadInt16();
int xMax = bin.ReadInt16();
int yMax = bin.ReadInt16();
m_Bounds[i].Set(xMin, yMin, (xMax - xMin) + 1, (yMax - yMin) + 1);
}
bin.Close();
}
}
else
{
Console.WriteLine("Warning: Data/Binary/Bounds.bin does not exist");
}
}
示例7: Version
private static bool Version(BinaryReader reader)
{
reader.ReadInt16(); // minor
var major = reader.ReadInt16();
return major == 2 || major == 3;
}
示例8: AddCliloc
public static void AddCliloc( string lang )
{
StringList list = StringList.GetList( lang );
if ( list == null )
list = StringList.AddLanguage( lang );
string path = Core.FindDataFile( String.Format( "cliloc.{0}", lang ) );
if ( path == null )
{
Console.WriteLine( "Warning: cliloc.{0} not found", lang );
return;
}
using ( BinaryReader bin = new BinaryReader( new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.Read ), Encoding.ASCII ) )
{
bin.ReadInt32();
bin.ReadInt16();
Encoding utf8 = Encoding.GetEncoding( "UTF-8", new EncoderReplacementFallback(""), new DecoderReplacementFallback("") );
while ( bin.PeekChar() != -1 )
{
int number = bin.ReadInt32();
bin.ReadByte(); //State in Cliloc
int length = bin.ReadInt16(); //Max of 65535 characters
StringEntry entry = new StringEntry( number, LState.Original, StringList.FormatArguments( utf8.GetString( bin.ReadBytes( length ) ) ) );
list.Table[number] = entry;
}
bin.Close();
}
}
示例9: load_chr
public void load_chr(string path)
{
this.listBox.Items.Clear();
BinaryReader binaryReader = new BinaryReader(File.Open(path, FileMode.Open), Encoding.GetEncoding("EUC-KR"));
int num = (int)binaryReader.ReadInt16();
for (int num2 = 0; num2 != num; num2++)
{
Mesh mesh = new Mesh();
mesh.read(ref binaryReader);
this.list_mesh.Add(mesh);
}
int num3 = (int)binaryReader.ReadInt16();
for (int num2 = 0; num2 != num3; num2++)
{
Materiel materiel = new Materiel();
materiel.read(ref binaryReader);
this.list_materiel.Add(materiel);
}
int num4 = (int)binaryReader.ReadInt16();
for (int num2 = 0; num2 != num4; num2++)
{
Effect effect = new Effect();
effect.read(ref binaryReader);
this.list_effect.Add(effect);
}
int num5 = (int)binaryReader.ReadInt16();
for (int num2 = 0; num2 != num5; num2++)
{
Object @object = new Object();
@object.read(ref binaryReader);
this.list_object.Add(@object);
this.listBox.Items.Add("Entry [" + num2 + "] : ");
}
binaryReader.Close();
}
示例10: Load
public void Load(string filePath, ClientType clientType)
{
this.Path = filePath;
this.clientType = clientType;
BinaryReader binaryReader = new BinaryReader(File.Open(filePath, FileMode.Open));
short num = binaryReader.ReadInt16();
this.listDDS = new List<TSI.DDS>((int)num);
for (int i = 0; i < (int)num; i++)
{
TSI.DDS dDS = new TSI.DDS();
dDS.Path = RoseFile.ReadSString(ref binaryReader);
dDS.ColourKey = binaryReader.ReadInt32();
this.listDDS.Add(dDS);
}
short num2 = binaryReader.ReadInt16();
for (int i = 0; i < (int)num; i++)
{
short num3 = binaryReader.ReadInt16();
this.listDDS[i].ListDDS_element = new List<TSI.DDS.DDSElement>((int)num3);
for (int j = 0; j < (int)num3; j++)
{
TSI.DDS.DDSElement dDSElement = new TSI.DDS.DDSElement();
dDSElement.OwnerId = binaryReader.ReadInt16();
dDSElement.X = binaryReader.ReadInt32();
dDSElement.Y = binaryReader.ReadInt32();
dDSElement.Width = binaryReader.ReadInt32() - dDSElement.X;
dDSElement.Height = binaryReader.ReadInt32() - dDSElement.Y;
dDSElement.Color = binaryReader.ReadInt32();
dDSElement.Name = RoseFile.ReadFString(ref binaryReader, 32);
this.listDDS[i].ListDDS_element.Add(dDSElement);
}
}
binaryReader.Close();
}
示例11: StringTable
public StringTable(string path)
{
m_Entries = new Dictionary<int, StringEntry>();
using (BinaryReader bin = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)))
{
m_Header1 = bin.ReadInt32();
m_Header2 = bin.ReadInt16();
byte[] m_Buffer = new byte[1024];
while (bin.BaseStream.Length != bin.BaseStream.Position)
{
int number = bin.ReadInt32();
byte flag = bin.ReadByte();
int length = bin.ReadInt16();
if (length > m_Buffer.Length)
m_Buffer = new byte[(length + 1023) & ~1023];
bin.Read(m_Buffer, 0, length);
string text = Encoding.UTF8.GetString(m_Buffer, 0, length);
m_Entries.Add(number, new StringEntry(number, text, flag));
}
}
}
示例12: Load
public void Load(string destinationDirectory, string resourceName, BinaryReader binaryReader)
{
binaryReader.BaseStream.Seek(2, SeekOrigin.Current);
uint length = binaryReader.ReadUInt32();
byte[] imageData = binaryReader.ReadBytes((int)length);
short xOffset = binaryReader.ReadInt16();
short yOffset = binaryReader.ReadInt16();
ushort width = binaryReader.ReadUInt16();
ushort height = binaryReader.ReadUInt16();
binaryReader.BaseStream.Seek(8, SeekOrigin.Current);
var bmp = new Bmp(width, height);
var colorData = bmp.Data;
var palette = PaletteLoader.DefaultPalette;
int index = 0;
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
colorData[y, x] = palette.Colors[imageData[index]];
++index;
}
}
bmp.Save(Path.Combine(destinationDirectory, resourceName), ImageFormat);
Bmp.SaveOffsets(resourceName, xOffset, yOffset);
}
示例13: ItemBounds
static ItemBounds()
{
string path = Path.Combine(Path.Combine(Core.Config.ConfigDirectory, "Binary"), "Bounds.bin");
if ( File.Exists( path ) )
{
using ( FileStream fs = new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.Read ) )
{
BinaryReader bin = new BinaryReader( fs );
m_Bounds = new Rectangle2D[0x4000];
for ( int i = 0; i < 0x4000; ++i )
{
int xMin = bin.ReadInt16();
int yMin = bin.ReadInt16();
int xMax = bin.ReadInt16();
int yMax = bin.ReadInt16();
m_Bounds[i].Set( xMin, yMin, (xMax - xMin) + 1, (yMax - yMin) + 1 );
}
bin.Close();
}
}
else
{
log.Warn(String.Format("{0} does not exist", path));
m_Bounds = new Rectangle2D[0x4000];
}
}
示例14: TinyImage
/// <summary>
/// Initializes new instance.
/// </summary>
public TinyImage(Stream stream)
{
BinaryReader reader = new BinaryReader(stream, Encoding.ASCII);
Width = reader.ReadInt16();
Height = reader.ReadInt16();
ImageData = reader.ReadBytes(Width*Height);
}
示例15: IPHeader
public IPHeader(ArraySegment<byte> buffer)
{
using (var memoryStream = new MemoryStream(buffer.Array, buffer.Offset, buffer.Count))
{
using (var binaryReader = new BinaryReader(memoryStream))
{
var versionAndHeaderLength = binaryReader.ReadByte();
var differentiatedServices = binaryReader.ReadByte();
DifferentiatedServices = (byte)(differentiatedServices >> 2);
CongestionNotification = (byte)(differentiatedServices & 0x03);
TotalLength = (ushort) IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
Debug.Assert(TotalLength >= 20, "Invalid IP packet Total Lenght");
Identification = (ushort) IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
_flagsAndOffset = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
Ttl = binaryReader.ReadByte();
_protocol = binaryReader.ReadByte();
Checksum = IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
SourceAddress = new IPAddress(binaryReader.ReadUInt32());
DestinationAddress = new IPAddress(binaryReader.ReadUInt32());
HeaderLength = (versionAndHeaderLength & 0x0f) * 4;
}
}
Raw = buffer;
Data = new ArraySegment<byte>(buffer.Array, buffer.Offset + HeaderLength, MessageLength);
}