本文整理汇总了C#中System.IO.BinaryReader.ReadUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadUInt16方法的具体用法?C# BinaryReader.ReadUInt16怎么用?C# BinaryReader.ReadUInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadUInt16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RespawnInfo
public RespawnInfo(BinaryReader reader, int Version, int Customversion)
{
MonsterIndex = reader.ReadInt32();
Location = new Point(reader.ReadInt32(), reader.ReadInt32());
Count = reader.ReadUInt16();
Spread = reader.ReadUInt16();
Delay = reader.ReadUInt16();
Direction = reader.ReadByte();
if (Envir.LoadVersion >= 36)
{
RoutePath = reader.ReadString();
}
if (Version > 67)
{
RandomDelay = reader.ReadUInt16();
RespawnIndex = reader.ReadInt32();
SaveRespawnTime = reader.ReadBoolean();
RespawnTicks = reader.ReadUInt16();
}
else
{
RespawnIndex = ++SMain.Envir.RespawnIndex;
}
}
示例2: FaceGroup
public FaceGroup(BinaryReader reader)
{
Min = new Vector3(reader);
Max = new Vector3(reader);
StartFace = reader.ReadUInt16();
EndFace = reader.ReadUInt16();
}
示例3: check
protected override void check(object sender, EventArgs e) {
int read_width = 0;
int read_height = 0;
int read_cwidth = 0;
int read_cheight = 0;
int read_quality = 0;
int read_samples = 0;
using (Stream stream = new FileStream(outPath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
using (BinaryReader reader = new BinaryReader(stream, Encoding.Default)) {
read_width = reader.ReadUInt16();
read_height = reader.ReadUInt16();
read_cwidth = reader.ReadUInt16();
read_cheight = reader.ReadUInt16();
read_quality = reader.ReadByte();
read_samples = reader.ReadByte();
}
}
System.Windows.Forms.MessageBox.Show(
"image width: " + inC1.imageWidth + " = " + read_width +
"\nimage height: " + inC1.imageHeight + " = " + read_height +
"\nchannel width: " + inC1.channelWidth + " = " + read_cwidth +
"\nchannel height: " + inC1.channelHeight + " = " + read_cheight +
"\nquality: " + inC1.quantizeQuality + " = " + read_quality +
"\nsamples: " + inC1.samplingMode + " = " + (DataBlob.Samples)read_samples
, "File Information");
}
示例4: LoadFromDbAsync
public async Task<ImageInfo[]> LoadFromDbAsync(string dbFileName)
{
var file = await FileSystem.Current.GetFileFromPathAsync(dbFileName).ConfigureAwait(false);
if (file == null)
throw new FileNotFoundException();
using (var fs = await file.OpenAsync(FileAccess.Read).ConfigureAwait(false))
using (var gz = new GZipStream(fs, CompressionMode.Decompress))
using (var br = new BinaryReader(gz))
{
long count = br.ReadInt32();
_info = new ImageInfo[count];
for (var i = 0; i < count; i++)
{
var hash = br.ReadUInt64();
var titleId = br.ReadUInt16();
var episodeId = br.ReadUInt16();
var frame = br.ReadUInt32();
_info[i] = new ImageInfo
{
Hash = hash,
TitleId = titleId,
EpisodeId = episodeId,
Frame = frame
};
}
}
return _info;
}
示例5: RWTriangle
/// <summary>
/// Initialize an instance of this structure by reading it from the given <see cref="BinaryReader"/>.
/// </summary>
/// <param name="reader">The <see cref="BinaryReader"/> to read the structure from.</param>
internal RWTriangle(BinaryReader reader)
{
C = reader.ReadUInt16();
B = reader.ReadUInt16();
MatID = reader.ReadInt16();
A = reader.ReadUInt16();
}
示例6: MixFile
public MixFile(string filename, int priority)
{
this.priority = priority;
s = FileSystem.Open(filename);
// Detect format type
s.Seek(0, SeekOrigin.Begin);
var reader = new BinaryReader(s);
var isCncMix = reader.ReadUInt16() != 0;
// The C&C mix format doesn't contain any flags or encryption
var isEncrypted = false;
if (!isCncMix)
isEncrypted = (reader.ReadUInt16() & 0x2) != 0;
List<PackageEntry> entries;
if (isEncrypted)
{
long unused;
entries = ParseHeader(DecryptHeader(s, 4, out dataStart), 0, out unused);
}
else
entries = ParseHeader(s, isCncMix ? 0 : 4, out dataStart);
index = entries.ToDictionaryWithConflictLog(x => x.Hash,
"{0} ({1} format, Encrypted: {2}, DataStart: {3})".F(filename, (isCncMix ? "C&C" : "RA/TS/RA2"), isEncrypted, dataStart),
null, x => "(offs={0}, len={1})".F(x.Offset, x.Length)
);
}
示例7: Parse
/// <summary>
///
/// </summary>
/// <param name="input"></param>
public void Parse(Stream input)
{
BinaryReader br = new BinaryReader(input);
_FrameSize = new Rect(this.Version);
_FrameSize.Parse(input);
_FrameRateDelay = br.ReadUInt16();
_FrameRate = (_FrameRateDelay >> 8) + ((_FrameRateDelay & 0xFF) / 100);
_FrameCount = br.ReadUInt16();
int x = Math.Abs((this._FrameSize.Xmax - this._FrameSize.Xmin) / 12);
int y = Math.Abs((this._FrameSize.Ymax - this._FrameSize.Ymin) / 12);
if (x > SwfFile.Configuration.MaximumStageSizeX)
{
Log.Warn(this, "The x value(" + x + ") of the stage exceeds the allowed maximum.");
}
if (x < SwfFile.Configuration.MinimumStageSizeX)
{
Log.Warn(this, "The x value(" + x + ") of the stage under-runs the allowed minimum.");
}
if (y > SwfFile.Configuration.MaximumStageSizeY)
{
Log.Warn(this, "The y value(" + y + ") of the stage exceeds the allowed maximum.");
}
if (y < SwfFile.Configuration.MinimumStageSizeY)
{
Log.Warn(this, "The y value(" + y + ") of the stage under-runs the allowed minimum.");
}
}
示例8: PosTbl
public PosTbl(Stream si)
{
var binaryReader = new BinaryReader(si);
int num = tbloff - 144;
si.Position = num + 160;
va0 = binaryReader.ReadUInt16();
va2 = binaryReader.ReadUInt16();
si.Position = num + 168;
va8 = binaryReader.ReadInt32();
vac = binaryReader.ReadInt32();
si.Position = num + 176;
vb0 = binaryReader.ReadInt32();
vb4 = binaryReader.ReadInt32();
vb8 = binaryReader.ReadInt32();
si.Position = num + 192;
vc0 = binaryReader.ReadInt32();
vc4 = binaryReader.ReadInt32();
vc8 = binaryReader.ReadInt32();
vcc = binaryReader.ReadInt32();
si.Position = num + 208;
vd0 = binaryReader.ReadInt32();
vd4 = binaryReader.ReadInt32();
vd8 = binaryReader.ReadInt32();
vdc = binaryReader.ReadInt32();
si.Position = num + 224;
ve0 = binaryReader.ReadInt32();
ve4 = binaryReader.ReadInt32();
ve8 = binaryReader.ReadInt32();
vec = binaryReader.ReadInt32();
si.Position = num + 240;
vf0 = binaryReader.ReadInt32();
vf4 = binaryReader.ReadInt32();
vf8 = binaryReader.ReadInt32();
vfc = binaryReader.ReadInt32();
}
示例9: 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);
}
示例10: Read
public override void Read(string file)
{
BinaryReader br = new BinaryReader(File.OpenRead(file));
uint file_size = (uint)br.BaseStream.Length;
// Read header values
ushort depth = br.ReadUInt16();
ushort width = br.ReadUInt16();
ushort height = br.ReadUInt16();
ushort unknown = br.ReadUInt16();
ColorFormat format = (depth == 0x01) ? ColorFormat.colors256 : ColorFormat.colors16;
// Palette
int palette_length = (depth == 0x01) ? 0x200 : 0x20;
Color[][] colors = new Color[1][];
colors[0] = Actions.BGR555ToColor(br.ReadBytes(palette_length));
palette = new RawPalette(colors, false, format);
// Tiles
int tiles_length = width * height;
if (depth == 0)
tiles_length /= 2;
Byte[] tiles = br.ReadBytes(tiles_length);
br.Close();
Set_Tiles(tiles, width, height, format, TileForm.Lineal, true);
}
示例11: ReadCustomData
internal static void ReadCustomData(Player player, BinaryReader reader)
{
int count = reader.ReadUInt16();
for (int k = 0; k < count; k++)
{
string modName = reader.ReadString();
string name = reader.ReadString();
byte[] data = reader.ReadBytes(reader.ReadUInt16());
Mod mod = ModLoader.GetMod(modName);
ModPlayer modPlayer = mod == null ? null : player.GetModPlayer(mod, name);
if (modPlayer != null)
{
using (MemoryStream stream = new MemoryStream(data))
{
using (BinaryReader customReader = new BinaryReader(stream))
{
modPlayer.LoadCustomData(customReader);
}
}
if (modName == "ModLoader" && name == "MysteryPlayer")
{
((MysteryPlayer)modPlayer).RestoreData(player);
}
}
else
{
ModPlayer mystery = player.GetModPlayer(ModLoader.GetMod("ModLoader"), "MysteryPlayer");
((MysteryPlayer)mystery).AddData(modName, name, data);
}
}
}
示例12: ReadContentFrom
protected override void ReadContentFrom(BinaryReader input)
{
//https://www.microsoft.com/typography/otspec/cmap.htm
long beginAt = input.BaseStream.Position;
//
ushort version = input.ReadUInt16(); // 0
ushort tableCount = input.ReadUInt16();
var entries = new CMapEntry[tableCount];
for (int i = 0; i < tableCount; i++)
{
ushort platformId = input.ReadUInt16();
ushort encodingId = input.ReadUInt16();
uint offset = input.ReadUInt32();
entries[i] = new CMapEntry(platformId, encodingId, offset);
}
charMaps = new CharacterMap[tableCount];
for (int i = 0; i < tableCount; i++)
{
CMapEntry entry = entries[i];
input.BaseStream.Seek(beginAt + entry.Offset, SeekOrigin.Begin);
CharacterMap cmap = charMaps[i] = ReadCharacterMap(entry, input);
cmap.PlatformId = entry.PlatformId;
cmap.EncodingId = entry.EncodingId;
}
}
示例13: OBJf
public OBJf(IffChunk Chunk)
: base(Chunk)
{
MemoryStream MemStream = new MemoryStream(Chunk.Data);
BinaryReader Reader = new BinaryReader(MemStream);
//Unknown + version (always 0)
Reader.ReadBytes(8);
string Header = Encoding.ASCII.GetString(Reader.ReadBytes(4));
if (Header != "fJBO")
return; //Error? This shouldn't occur...
m_NumEntries = Reader.ReadInt32();
for (int i = 0; i < m_NumEntries; i++)
{
IDPair FuncIDs = new IDPair();
FuncIDs.GuardFuncID = Reader.ReadUInt16();
FuncIDs.FunctionID = Reader.ReadUInt16();
m_FuncIDs.Add(FuncIDs);
}
}
示例14: Read
public override void Read(Stream input)
{
BinaryReader reader = new BinaryReader(input, Encoding.Default, true);
uint magicNumber1 = reader.ReadUInt32(); // foxf
ushort magicNumber2 = reader.ReadUInt16(); // pk
FpkType = (FpkType) reader.ReadByte(); // ' ' or 'd'
byte magicNumber3 = reader.ReadByte(); // w
ushort magicNumber4 = reader.ReadUInt16(); // in
uint fileSize = reader.ReadUInt32();
reader.Skip(18);
uint magicNumber5 = reader.ReadUInt32(); // 2
uint fileCount = reader.ReadUInt32();
uint referenceCount = reader.ReadUInt32();
reader.Skip(4);
for (int i = 0; i < fileCount; i++)
{
Entries.Add(FpkEntry.ReadFpkEntry(input));
}
for (int i = 0; i < referenceCount; i++)
{
References.Add(FpkReference.ReadFpkReference(input));
}
}
示例15: Metadata
public Metadata(BinaryReader reader)
{
magic = reader.ReadUInt32();
if (magic != 0x424A5342)
return;
offset = (uint)reader.BaseStream.Position - 4;
majorVersion = reader.ReadUInt16();
minorVersion = reader.ReadUInt16();
reserved = reader.ReadUInt32();
versionString = readString(reader, reader.ReadInt32());
flags = reader.ReadUInt16();
int numStreams = reader.ReadUInt16();
streams = new DotNetStream[numStreams];
uint lastOffset = offset;
for (int i = 0; i < numStreams; i++) {
uint fileOffset = offset + reader.ReadUInt32();
uint size = reader.ReadUInt32();
string name = readAsciizString(reader);
streams[i] = new DotNetStream(name, fileOffset, size);
lastOffset = Math.Max(lastOffset, fileOffset + size);
}
lastOffset = Math.Max(lastOffset, (uint)reader.BaseStream.Position);
length = lastOffset - offset;
headerLength = (uint)reader.BaseStream.Position - offset;
}