本文整理汇总了C#中EndianBinaryReader.ReadUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# EndianBinaryReader.ReadUInt32方法的具体用法?C# EndianBinaryReader.ReadUInt32怎么用?C# EndianBinaryReader.ReadUInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EndianBinaryReader
的用法示例。
在下文中一共展示了EndianBinaryReader.ReadUInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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;
}
示例4: 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();
}
示例5: Update
public bool Update()
{
var bitStream = downloader.DownloadStream;
var reader = new EndianBinaryReader(EndianBitConverter.Big, bitStream);
if(bitStream != null)
{
var stream = new StreamReader(bitStream);
{
reader.ReadBytes(3); //"FLV"
reader.ReadBytes(6); //Other starter shit
while (true)
{
try
{
var footer = reader.ReadUInt32();
var tag = new FlvTag();
tag.Load(reader);
AddedTag(tag);
}
catch (Exception)
{
reader.Close();
//End of stream
return false;
}
}
}
}
return true;
}
示例6: mat1
public mat1(EndianBinaryReader er)
{
long startpos = er.BaseStream.Position;
Signature = er.ReadString(Encoding.ASCII, 4);
if (Signature != "mat1") throw new SignatureNotCorrectException(Signature, "mat1", er.BaseStream.Position - 4);
SectionSize = er.ReadUInt32();
NrMaterials = er.ReadUInt32();
MaterialEntryOffsets = er.ReadUInt32s((int)NrMaterials);
Materials = new MaterialEntry[NrMaterials];
for (int i = 0; i < NrMaterials; i++)
{
er.BaseStream.Position = startpos + MaterialEntryOffsets[i];
Materials[i] = new MaterialEntry(er);
}
er.BaseStream.Position = startpos + SectionSize;
}
示例7: TEX0
public TEX0(EndianBinaryReader er)
{
long basepos = er.BaseStream.Position;
Signature = er.ReadString(Encoding.ASCII, 4);
if (Signature != "TEX0") throw new SignatureNotCorrectException(Signature, "TEX0", er.BaseStream.Position - 4);
SectionSize = er.ReadUInt32();
TexInfo = new texInfo(er);
Tex4x4Info = new tex4x4Info(er);
PlttInfo = new plttInfo(er);
dictTex = new Dictionary<DictTexData>(er);
for (int i = 0; i < dictTex.numEntry; i++)
{
dictTex[i].Value.ReadData(er, TexInfo.ofsTex, Tex4x4Info.ofsTex, Tex4x4Info.ofsTexPlttIdx, basepos);
}
dictPltt = new Dictionary<DictPlttData>(er);
List<UInt32> Offset = new List<uint>();
for (int i = 0; i < dictPltt.numEntry; i++)
{
Offset.Add(dictPltt[i].Value.offset);
}
Offset = Offset.Distinct().ToList();
Offset.Sort();
for (int i = 0; i < dictPltt.numEntry; i++)
{
int idx = Offset.IndexOf(dictPltt[i].Value.offset);
if (idx == Offset.Count - 1)
{
dictPltt[i].Value.ReadData(er, PlttInfo.ofsPlttData, (uint)er.BaseStream.Length - (Offset[idx] + PlttInfo.ofsPlttData + (uint)basepos), basepos);
}
else
{
dictPltt[i].Value.ReadData(er, PlttInfo.ofsPlttData, Offset[idx + 1] - Offset[idx], basepos);
}
}
}
示例8: ImageTextureCtr
public ImageTextureCtr(EndianBinaryReader er)
: base(er)
{
TextureImageOffset = (UInt32)er.BaseStream.Position + er.ReadUInt32();
long curpos = er.BaseStream.Position;
er.BaseStream.Position = TextureImageOffset;
TextureImage = new PixelBasedImageCtr(er);
er.BaseStream.Position = curpos;
}
示例9: FromStream
public static BoundingVolume FromStream(EndianBinaryReader er)
{
uint type = er.ReadUInt32();
er.BaseStream.Position -= 4;
switch (type)
{
case 0x80000000:
return new OrientedBoundingBox(er);
}
return new BoundingVolume(er);
}
示例10: 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;
}
示例11: MaterialEntry
public MaterialEntry(EndianBinaryReader er)
{
Name = er.ReadString(Encoding.ASCII, 20).Replace("\0", "");
BufferColor = er.ReadColor8();
ConstColors = new Color[6];
ConstColors[0] = er.ReadColor8();
ConstColors[1] = er.ReadColor8();
ConstColors[2] = er.ReadColor8();
ConstColors[3] = er.ReadColor8();
ConstColors[4] = er.ReadColor8();
ConstColors[5] = er.ReadColor8();
Flags = er.ReadUInt32();
//Material Flag:
// 0-1: Nr texMap
// 2-3: Nr texMatrix
// 4-5: Nr texCoordGen
// 6-8: Nr tevStage
// 9: Has alphaCompare
// 10: Has blendMode
// 11: Use Texture Only
// 12: Separate Blend Mode
// 14: Has Indirect Parameter
//15-16: Nr projectionTexGenParameter
// 17: Has Font Shadow Parameter
TexMaps = new TexMap[Flags & 3];
for (int i = 0; i < (Flags & 3); i++)
{
TexMaps[i] = new TexMap(er);
}
TexMatrices = new TexMatrix[(Flags >> 2) & 3];
for (int i = 0; i < ((Flags >> 2) & 3); i++)
{
TexMatrices[i] = new TexMatrix(er);
}
TexCoordGens = new TexCoordGen[(Flags >> 4) & 3];
for (int i = 0; i < ((Flags >> 4) & 3); i++)
{
TexCoordGens[i] = new TexCoordGen(er);
}
TevStages = new TevStage[(Flags >> 6) & 7];
for (int i = 0; i < ((Flags >> 6) & 7); i++)
{
TevStages[i] = new TevStage(er);
}
if (((Flags >> 9) & 1) == 1) AlphaTest = new AlphaCompare(er);
if (((Flags >> 10) & 1) == 1) ColorBlendMode = new BlendMode(er);
if (((Flags >> 12) & 1) == 1) AlphaBlendMode = new BlendMode(er);
//Some more things
}
示例12: MDL0
public MDL0(EndianBinaryReader er)
{
long basepos = er.BaseStream.Position;
Signature = er.ReadString(Encoding.ASCII, 4);
if (Signature != "MDL0") throw new SignatureNotCorrectException(Signature, "MDL0", er.BaseStream.Position - 4);
SectionSize = er.ReadUInt32();
dict = new Dictionary<MDL0Data>(er);
models = new Model[dict.numEntry];
long curpos = er.BaseStream.Position;
for (int i = 0; i < dict.numEntry; i++)
{
er.BaseStream.Position = dict[i].Value.Offset + basepos;//er.GetMarker("ModelSet");
models[i] = new Model(er);
}
}
示例13: Load
public void Load(Stream stream)
{
var reader = new EndianBinaryReader(EndianBitConverter.Big, stream);
//Header
reader.ReadBytes(3); // "FLV"
Version = reader.ReadByte();
Bitmask = (BitmaskTypes) reader.ReadByte();
HeaderSize = reader.ReadUInt32();
//Start reading tags
while(stream.Position < stream.Length)
{
var footer = reader.ReadUInt32();
if(stream.Position >= stream.Length)
{
break;
}
var tag = new FlvTag();
tag.Load(reader);
Tags.Add(tag);
}
}
示例14: LoadArchive
/// <summary>
/// Loads an archive into a <see cref="VirtualFilesystemDirectory"/>, automatically de-compressing the archive if required.
///
/// </summary>
/// <param name="filePath">Filepath of file to (optionally) decompress and load.</param>
/// <returns><see cref="VirtualFilesystemDirectory"/> containing the contents, or null if filepath is not a valid archive.</returns>
public static VirtualFilesystemDirectory LoadArchive(string filePath)
{
if(string.IsNullOrEmpty(filePath))
throw new ArgumentNullException("filePath", "Cannot load archive from empty file path!");
if (!File.Exists(filePath))
throw new ArgumentException("Cannot load archive from non-existant file!", "filePath");
MemoryStream decompressedFile = null;
using (EndianBinaryReader fileReader = new EndianBinaryReader(File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Endian.Big))
{
// Read the first 4 bytes to see if it's a compressed file (Yaz0) or a plain RARC file.
uint fileMagic = fileReader.ReadUInt32();
fileReader.BaseStream.Position = 0L; // Reset to the start so that the next thing to read it is at the start like it expects.
switch(fileMagic)
{
case 0x59617A30: // Yaz0 Compression
decompressedFile = Yaz0.Decode(fileReader);
break;
case 0x59617930: // Yay0 Compression
decompressedFile = Yay0.Decode(fileReader);
break;
case 0x52415243: // RARC - Uncompressed
decompressedFile = new MemoryStream((int)fileReader.BaseStream.Length);
fileReader.BaseStream.CopyTo(decompressedFile);
// Copying modifies the decompressedFile's read head (places it at new location) so we rewind.
decompressedFile.Position = 0L;
break;
default:
throw new NotImplementedException(string.Format("Unknown magic: {0}. If this is a Nintendo archive, open an Issue on GitHub!", fileMagic.ToString("X8")));
}
}
// Not an archive we know how to handle.
if (decompressedFile == null)
return null;
// Decompress the archive into the folder. It'll generate a sub-folder with the Archive's ROOT name.
Archive rarc = new Archive();
using (EndianBinaryReader reader = new EndianBinaryReader(decompressedFile, Endian.Big))
{
return rarc.ReadFile(reader);
}
}
示例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;
}