本文整理汇总了C#中EndianBinaryReader.ReadUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# EndianBinaryReader.ReadUInt16方法的具体用法?C# EndianBinaryReader.ReadUInt16怎么用?C# EndianBinaryReader.ReadUInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EndianBinaryReader
的用法示例。
在下文中一共展示了EndianBinaryReader.ReadUInt16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadTEX1FromFile
private static List<Texture2D> LoadTEX1FromFile(EndianBinaryReader reader, long chunkStart)
{
ushort textureCount = reader.ReadUInt16();
ushort padding = reader.ReadUInt16(); // Usually 0xFFFF?
uint textureHeaderOffset = reader.ReadUInt32(); // textureCount # bti image headers are stored here, relative to chunkStart.
uint stringTableOffset = reader.ReadUInt32(); // One filename per texture. relative to chunkStart.
List<Texture2D> textureList = new List<Texture2D>();
// Get all Texture Names
reader.BaseStream.Position = chunkStart + stringTableOffset;
StringTable stringTable = StringTable.FromStream(reader);
for (int t = 0; t < textureCount; t++)
{
// 0x20 is the length of the BinaryTextureImage header which all come in a row, but then the stream gets jumped around while loading the BTI file.
reader.BaseStream.Position = chunkStart + textureHeaderOffset + (t * 0x20);
BinaryTextureImage texture = new BinaryTextureImage();
texture.Load(reader, chunkStart + 0x20, t);
Texture2D texture2D = new Texture2D(texture.Width, texture.Height);
texture2D.Name = stringTable[t];
texture2D.PixelData = texture.GetData();
textureList.Add(texture2D);
string executionPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
texture.SaveImageToDisk(executionPath + "/TextureDump/" + string.Format("{0}_({1}-{2}).png", stringTable[t], texture.Format, t));
}
return textureList;
}
示例2: POTI
public POTI(EndianBinaryReader er)
{
Signature = er.ReadString(Encoding.ASCII, 4);
if (Signature != "ITOP") throw new SignatureNotCorrectException(Signature, "ITOP", er.BaseStream.Position - 4);
NrRoutes = er.ReadUInt16();
NrPoints = er.ReadUInt16();
for (int i = 0; i < NrRoutes; i++) Routes.Add(new POTIRoute(er));
}
示例3: FFNTHeader
public UInt32 NrBlocks; //文件内数据块数量 FINF + TGLP + CWDH * N + CMAP * N
public FFNTHeader(EndianBinaryReader er)
{
Signature = er.ReadString(Encoding.ASCII, 4);//FFNT
Endianness = er.ReadUInt16();
HeaderSize = er.ReadUInt16();
Version = er.ReadUInt32();
FileSize = er.ReadUInt32();
NrBlocks = er.ReadUInt32();
}
示例4: wnd1
public wnd1(EndianBinaryReader er)
: base(er)
{
long basepos = er.BaseStream.Position - 0x4C;
InflationLeft = er.ReadUInt16() / 16f;
InflationRight = er.ReadUInt16() / 16f;
InflationTop = er.ReadUInt16() / 16f;
InflationBottom = er.ReadUInt16() / 16f;
FrameSizeLeft = er.ReadUInt16();
FrameSizeRight = er.ReadUInt16();
FrameSizeTop = er.ReadUInt16();
FrameSizeBottom = er.ReadUInt16();
NrFrames = er.ReadByte();
byte tmp = er.ReadByte();
UseLTMaterial = (tmp & 1) == 1;
UseVtxColorForAllWindow = (tmp & 2) == 2;
Kind = (WindowKind)((tmp >> 2) & 3);
DontDrawContent = (tmp & 8) == 16;
Padding = er.ReadUInt16();
ContentOffset = er.ReadUInt32();
FrameOffsetTableOffset = er.ReadUInt32();
er.BaseStream.Position = basepos + ContentOffset;
Content = new WindowContent(er);
er.BaseStream.Position = basepos + FrameOffsetTableOffset;
WindowFrameOffsets = er.ReadUInt32s(NrFrames);
WindowFrames = new WindowFrame[NrFrames];
for (int i = 0; i < NrFrames; i++)
{
er.BaseStream.Position = basepos + WindowFrameOffsets[i];
WindowFrames[i] = new WindowFrame(er);
}
er.BaseStream.Position = basepos + SectionSize;
}
示例5: ReadGrayscaleColor
private static Color ReadGrayscaleColor(EndianBinaryReader reader)
{
ushort x = reader.ReadUInt16();
reader.ReadUInt16();
reader.ReadUInt16();
reader.ReadUInt16();
return Color.FromArgb(255,
(byte) ((x / 10000.0f) * 255),
(byte) ((x / 10000.0f) * 255),
(byte) ((x / 10000.0f) * 255));
}
示例6: ReadCMYKColor
private static Color ReadCMYKColor(EndianBinaryReader reader)
{
ushort x = reader.ReadUInt16();
ushort y = reader.ReadUInt16();
ushort z = reader.ReadUInt16();
ushort w = reader.ReadUInt16();
float c = (100 - (x / 655.35f)) / 100.0f;
float m = (100 - (y / 655.35f)) / 100.0f;
float ye = (100 - (z / 655.35f)) / 100.0f;
float k = (100 - (w / 655.35f)) / 100.0f;
return ColorSpaceHelper.CMYKtoColor(c, m, ye, k);
}
示例7: pic1
public pic1(EndianBinaryReader er)
: base(er)
{
VertexColorLT = er.ReadColor8();
VertexColorRT = er.ReadColor8();
VertexColorLB = er.ReadColor8();
VertexColorRB = er.ReadColor8();
MaterialId = er.ReadUInt16();
NrTexCoordEntries = er.ReadUInt16();
TexCoordEntries = new TexCoord[NrTexCoordEntries];
for (int i = 0; i < NrTexCoordEntries; i++)
{
TexCoordEntries[i] = new TexCoord(er);
}
}
示例8: POTIRoute
public POTIRoute(EndianBinaryReader er)
{
NrPoints = er.ReadUInt16();
Setting1 = er.ReadByte();
Setting2 = er.ReadByte();
for (int i = 0; i < NrPoints; i++) Points.Add(new POTIPoint(er));
}
示例9: 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);
}
示例10: Parse
protected override void Parse(EndianBinaryReader r)
{
Version = (ProtocolVersion)ReadVarInt(r);
Host = ReadString8(r);
Port = r.ReadUInt16();
State = (HandshakeState)ReadVarInt(r);
DebugGotAll(r);
}
示例11: GetPolygons
public static List<Polygon> GetPolygons(EndianBinaryReader reader, int numAllPolygons)
{
List<Polygon> polygons = new List<Polygon>();
for (int i = 0; i < numAllPolygons; i++)
{
Polygon polygon = new Polygon();
polygon.polygonType = (PolygonType)reader.ReadByte();
polygon.size = reader.ReadByte();
polygon.BaceFaceMode = (FaceMode)reader.ReadByte();
polygon.unknown = reader.ReadByte();
polygon.vertex1 = reader.ReadUInt16();
polygon.vertex1 /= 4;
polygon.vertex2 = reader.ReadUInt16();
polygon.vertex2 /= 4;
polygon.vertex3 = reader.ReadUInt16();
polygon.vertex3 /= 4;
if (polygon.polygonType == PolygonType.Quad)
{
polygon.vertex4 = reader.ReadUInt16();
polygon.vertex4 /= 4;
}
polygon.u1 = reader.ReadByte();
polygon.v1 = reader.ReadByte();
polygon.u2 = reader.ReadByte();
polygon.v2 = reader.ReadByte();
polygon.u3 = reader.ReadByte();
polygon.v3 = reader.ReadByte();
if (polygon.polygonType == PolygonType.Quad)
{
polygon.u4 = reader.ReadByte();
polygon.v4 = reader.ReadByte();
}
polygons.Add(polygon);
}
return polygons;
}
示例12: Deserialize
public void Deserialize(PacketChecksumType checksumType, byte[] data)
{
MemoryStream ms = new MemoryStream(data);
EndianBinaryReader reader = new EndianBinaryReader(EndianBitConverter.Little, ms);
if (reader.ReadByte() != 0x01)
throw new InvalidDataException("Message start byte must be 0x01");
StatusCode status = (StatusCode) reader.ReadByte();
if (status != StatusCode.CYRET_SUCCESS)
throw new BootloaderError(status);
ushort length = reader.ReadUInt16();
if (length > data.Length - 7)
throw new InvalidDataException("Invalid data length");
this.DeserializePayload(reader, length);
ushort checksum = reader.ReadUInt16();
if (checksum != PacketChecksum.ComputeChecksum(checksumType, data, length + 4))
throw new InvalidDataException("Invalid checksum");
if (reader.ReadByte() != 0x17)
throw new InvalidDataException("Message end byte must be 0x17");
}
示例13: Load
public override void Load()
{
using (
var reader = new EndianBinaryReader(EndianBitConverter.Big, File.Open(FilePath, FileMode.Open, FileAccess.Read),
Encoding.Unicode))
{
ushort version = reader.ReadUInt16();
LoadACOData(reader, version);
if (reader.BaseStream.Position != reader.BaseStream.Length)
{
// Version 2 is here, so clear what we have
Clear();
version = reader.ReadUInt16();
LoadACOData(reader, version);
}
}
Dirty = false;
}
示例14: FromStream
public static WEP FromStream(EndianBinaryReader reader)
{
/*=====================================================================
WEP HEADER (0x50) 80 bytes long
=====================================================================*/
reader.Skip(0x04); // TODO: skip magic 0x04 (4 dec) "H01" check for file type?
byte numJoints = reader.ReadByte();
byte numGroups = reader.ReadByte();
ushort numTriangles = reader.ReadUInt16();
ushort numQuads = reader.ReadUInt16();
ushort numPolygons = reader.ReadUInt16();
uint ptrTexture1 = (uint)(reader.ReadUInt32() + 0x10); // same as ptrTexture... why?
reader.Skip(0x30); // header padding?
uint ptrTexture = (uint)(reader.ReadUInt32() + 0x10);
uint ptrGroups = (uint)(reader.ReadUInt32() + 0x10);
uint ptrVertices = (uint)(reader.ReadUInt32() + 0x10);
uint ptrPolygons = (uint)(reader.ReadUInt32() + 0x10);
/*=====================================================================
LOCALS
=====================================================================*/
int numAllPolygons = numTriangles + numQuads + numPolygons;
int numOfPalettes = 7; // palettes of 2/3 color count.
/*=====================================================================
STREAM READER
=====================================================================*/
WEP wep = new WEP();
wep.joints = VSTools.GetJoints(reader, numJoints);
wep.groups = VSTools.GetGroups(reader, numGroups);
wep.vertices = VSTools.GetVertices(reader, wep.groups);
wep.polygons = VSTools.GetPolygons(reader, numAllPolygons);
wep.textures = VSTools.GetTextures(reader, numOfPalettes);
return wep;
}
示例15: txt1
public txt1(EndianBinaryReader er)
: base(er)
{
long baseoffset = er.BaseStream.Position - 0x4C;
NrCharacters = er.ReadUInt16();
NrCharacters2 = er.ReadUInt16();
MaterialId = er.ReadUInt16();
FontId = er.ReadUInt16();
PositionType = er.ReadByte();
TextAlignment = er.ReadByte();
TextFlags = er.ReadByte();
Padding = er.ReadByte();
StringOffset = er.ReadUInt32();
TopColor = er.ReadColor8();
BottomColor = er.ReadColor8();
FontSize = er.ReadVector2();
CharSpace = er.ReadSingle();
LineSpace = er.ReadSingle();
er.BaseStream.Position = baseoffset + StringOffset;
Text = er.ReadStringNT(Encoding.Unicode);
er.BaseStream.Position = baseoffset + SectionSize;
}