本文整理汇总了C#中System.Stream.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ReadInt32方法的具体用法?C# Stream.ReadInt32怎么用?C# Stream.ReadInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Stream
的用法示例。
在下文中一共展示了Stream.ReadInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessConnection
public void ProcessConnection(Stream conn)
{
int timeout = conn.ReadInt32();
int keylen = conn.ReadInt32();
int codelen = conn.ReadInt32();
string key = conn.ReadUTF8(keylen);
string work = conn.ReadUTF8(codelen).Trim();
if (work == "") {
ReturnWork("", conn);
return;
}
lock (exprs) {
string output = null;
string evopt =
Evaluate(key,
!exprs.ContainsKey(key) ? work : exprs[key] + "\n" + work,
timeout, ref output);
if (output != null || evopt == null) { // exception or result
ReturnWork(output ?? "", conn);
} else if (output == null && evopt != null) { // continuation
ReturnWork("(continue...)", conn);
}
exprs[key] = evopt;
}
}
示例2: R8Frame
public R8Frame(Stream s)
{
// Scan forward until we find some data
var type = s.ReadUInt8();
while (type == 0)
type = s.ReadUInt8();
var width = s.ReadInt32();
var height = s.ReadInt32();
var x = s.ReadInt32();
var y = s.ReadInt32();
Size = new Size(width, height);
Offset = new int2(width / 2 - x, height / 2 - y);
/*var imageOffset = */
s.ReadInt32();
var paletteOffset = s.ReadInt32();
var bpp = s.ReadUInt8();
if (bpp != 8)
throw new InvalidDataException("Error: {0} bits per pixel are not supported.".F(bpp));
var frameHeight = s.ReadUInt8();
var frameWidth = s.ReadUInt8();
FrameSize = new Size(frameWidth, frameHeight);
// Skip alignment byte
s.ReadUInt8();
Data = s.ReadBytes(width * height);
// Ignore palette
if (type == 1 && paletteOffset != 0)
s.Seek(520, SeekOrigin.Current);
}
示例3: ReadFrom
public void ReadFrom(Stream stream)
{
int numMaterials = stream.ReadInt32();
Layers = new MyMaterialLayer[numMaterials];
for (int i = 0; i < numMaterials; ++i)
{
Layers[i] = new MyMaterialLayer();
Layers[i].StartHeight = stream.ReadFloat();
Layers[i].EndHeight = stream.ReadFloat();
Layers[i].StartAngle = stream.ReadFloat();
Layers[i].EndAngle = stream.ReadFloat();
Layers[i].HeightStartDeviation = stream.ReadFloat();
Layers[i].AngleStartDeviation = stream.ReadFloat();
Layers[i].HeightEndDeviation = stream.ReadFloat();
Layers[i].AngleEndDeviation = stream.ReadFloat();
Layers[i].MaterialDefinition = MyDefinitionManager.Static.GetVoxelMaterialDefinition(stream.ReadString());
}
int numOreProbabilities = stream.ReadInt32();
OreProbabilities = new MyOreProbability[numOreProbabilities];
for (int i = 0; i < numOreProbabilities; ++i)
{
OreProbabilities[i] = new MyOreProbability();
OreProbabilities[i].CummulativeProbability = stream.ReadFloat();
OreProbabilities[i].OreName = stream.ReadString();
}
OreStartDepth = stream.ReadFloat();
OreEndDepth = stream.ReadFloat();
}
示例4: ParseFrames
TmpTDFrame[] ParseFrames(Stream s)
{
var start = s.Position;
var width = s.ReadUInt16();
var height = s.ReadUInt16();
var size = new Size(width, height);
s.Position += 8;
var imgStart = s.ReadUInt32();
s.Position += 8;
var indexEnd = s.ReadInt32();
var indexStart = s.ReadInt32();
s.Position = indexStart;
var count = indexEnd - indexStart;
var tiles = new TmpTDFrame[count];
var tilesIndex = 0;
foreach (var b in s.ReadBytes(count))
{
if (b != 255)
{
s.Position = imgStart + b * width * height;
tiles[tilesIndex++] = new TmpTDFrame(s.ReadBytes(width * height), size);
}
else
tiles[tilesIndex++] = new TmpTDFrame(null, size);
}
s.Position = start;
return tiles;
}
示例5: Container
public Container(Stream stream)
{
UInt16 stringLength = stream.ReadUInt16();
Name = stream.ReadAsciiString(stringLength);
ContainerType = stream.ReadUInt8();
Flags = (ContainerFlags)stream.ReadUInt16();
PrimitiveCount = stream.ReadUInt16();
PackfileBaseOffset = stream.ReadUInt32();
CompressionType = stream.ReadUInt8();
stringLength = stream.ReadUInt16();
StubContainerParentName = stream.ReadAsciiString(stringLength);
Int32 auxDataSize = stream.ReadInt32();
AuxData = new byte[auxDataSize];
stream.Read(AuxData, 0, auxDataSize);
TotalCompressedPackfileReadSize = stream.ReadInt32();
Primitives = new List<Primitive>();
PrimitiveSizes = new List<WriteTimeSizes>();
for (UInt16 i = 0; i < PrimitiveCount; i++)
{
var sizes = stream.ReadStruct<WriteTimeSizes>();
PrimitiveSizes.Add(sizes);
}
for (UInt16 i = 0; i < PrimitiveCount; i++)
{
Primitive primitive = new Primitive(stream);
Primitives.Add(primitive);
}
}
示例6: Read
/// <summary>
/// Читает запись представляющую полигон.
/// </summary>
/// <param name="file">Входной поток</param>
/// <param name="record">Запись Shape-файла в которую будет помещена прочитанная информация</param>
/// <param name="bounds">Ограничивающий прямоугольник, с которым должен пересекаться ограничивающий прямоугольник записи</param>
public override bool Read(/*BigEndianBinaryReader*/ Stream file, BoundingRectangle bounds, ShapeFileRecord record)
{
record.MinX = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
record.MinY = file.ReadDouble(); //ShapeFile.ReadDouble64_LE(stream);
record.MaxX = file.ReadDouble(); ;// ShapeFile.ReadDouble64_LE(stream);
record.MaxY = file.ReadDouble(); ;// ShapeFile.ReadDouble64_LE(stream);
int numParts = file.ReadInt32();// ShapeFile.ReadInt32_LE(stream);
int numPoints = file.ReadInt32(); //ShapeFile.ReadInt32_LE(stream);
if (!ShapeHandler.IsRecordInView(bounds, record))
{
file.Seek((long)numPoints * 16 + numParts * 4, SeekOrigin.Current);
return false;
}
for (int i = 0; i < numParts; i++)
record.Parts.Add(file.ReadInt32());//ShapeFile.ReadInt32_LE(stream));
for (int i = 0; i < numPoints; i++)
{
ICoordinate p =
PlanimetryEnvironment.NewCoordinate(
file.ReadDouble(),//ShapeFile.ReadDouble64_LE(stream),
file.ReadDouble());//ShapeFile.ReadDouble64_LE(stream));
record.Points.Add(p);
}
return true;
}
示例7: ReadExtent
protected override Extent ReadExtent(int shp, Stream reader)
{
var shapeHeaders = ShapeHeaders;
reader.Seek(shapeHeaders[shp].ByteOffset, SeekOrigin.Begin);
reader.ReadInt32(Endian.BigEndian); // Record Number
reader.ReadInt32(Endian.BigEndian); // Content Len
var shapeType = (ShapeType)reader.ReadInt32();
if (shapeType == ShapeType.NullShape) return new Extent();
var x = reader.ReadDouble();
var y = reader.ReadDouble();
return new Extent(x, y, x, y);
}
示例8: WavLoader
public WavLoader(Stream s)
{
while (s.Position < s.Length)
{
if ((s.Position & 1) == 1)
s.ReadByte(); // Alignment
var type = s.ReadASCII(4);
switch (type)
{
case "RIFF":
FileSize = s.ReadInt32();
Format = s.ReadASCII(4);
if (Format != "WAVE")
throw new NotSupportedException("Not a canonical WAVE file.");
break;
case "fmt ":
FmtChunkSize = s.ReadInt32();
AudioFormat = s.ReadInt16();
Type = (WaveType)AudioFormat;
if (Type != WaveType.Pcm && Type != WaveType.ImaAdpcm)
throw new NotSupportedException("Compression type is not supported.");
Channels = s.ReadInt16();
SampleRate = s.ReadInt32();
ByteRate = s.ReadInt32();
BlockAlign = s.ReadInt16();
BitsPerSample = s.ReadInt16();
s.ReadBytes(FmtChunkSize - 16);
break;
case "fact":
{
var chunkSize = s.ReadInt32();
UncompressedSize = s.ReadInt32();
s.ReadBytes(chunkSize - 4);
}
break;
case "data":
DataSize = s.ReadInt32();
RawOutput = s.ReadBytes(DataSize);
break;
default:
// Ignore unknown chunks
{
var chunkSize = s.ReadInt32();
s.ReadBytes(chunkSize);
}
break;
}
}
if (Type == WaveType.ImaAdpcm)
{
RawOutput = DecodeImaAdpcmData();
BitsPerSample = 16;
}
}
示例9: XccGlobalDatabase
public XccGlobalDatabase(Stream stream)
{
s = stream;
var entries = new List<string>();
while (s.Peek() > -1)
{
var count = s.ReadInt32();
for (var i = 0; i < count; i++)
{
var chars = new List<char>();
byte c;
// Read filename
while ((c = s.ReadUInt8()) != 0)
chars.Add((char)c);
entries.Add(new string(chars.ToArray()));
// Skip comment
while ((c = s.ReadUInt8()) != 0) { }
}
}
Entries = entries.ToArray();
}
示例10: ReadBody
public static ForwardedSubscriptionRequest ReadBody(Stream stream)
{
var clientId = stream.ReadInt32();
var topic = stream.ReadString();
var isAdd = stream.ReadBoolean();
return new ForwardedSubscriptionRequest(clientId, topic, isAdd);
}
示例11: ReadFrom
public void ReadFrom(Stream stream)
{
Seed = stream.ReadInt32();
Radius = stream.ReadFloat();
DeviationScale = stream.ReadFloat();
Diameter = Radius * 2.0f;
AveragePlanetRadius = stream.ReadFloat();
}
示例12: TmpTSReader
public TmpTSReader(Stream s)
{
var templateWidth = s.ReadUInt32();
var templateHeight = s.ReadUInt32();
var tileWidth = s.ReadInt32();
var tileHeight = s.ReadInt32();
var size = new Size(tileWidth, tileHeight);
var offsets = new uint[templateWidth * templateHeight];
for (var i = 0; i < offsets.Length; i++)
offsets[i] = s.ReadUInt32();
for (var i = 0; i < offsets.Length; i++)
{
s.Position = offsets[i];
tiles.Add(new TmpTSTile(s, size));
}
}
示例13: Read
public static W2Dzip Read(Stream stream)
{
// ReSharper disable UseObjectOrCollectionInitializer
var result = new W2Dzip();
// ReSharper restore UseObjectOrCollectionInitializer
stream.Seek(0, SeekOrigin.Begin);
result.header = stream.ReadUtf8String(4);
result.version = stream.ReadInt32();
result.fileCount = stream.ReadInt32();
result.userId = stream.ReadInt32();
result.metaOffset = stream.ReadInt64();
result.unknown = stream.ReadInt64();
stream.Seek(result.metaOffset, SeekOrigin.Begin);
result.fileEntry = FileEntry.Read(stream, result.fileCount, out result.estimatedMaximumBufferSize);
return result;
}
示例14: ReadBody
public static UnicastData ReadBody(Stream stream)
{
var clientId = stream.ReadInt32();
var topic = stream.ReadString();
var isImage = stream.ReadBoolean();
var nbytes = stream.ReadInt32();
var data = new byte[nbytes];
var offset = 0;
while (nbytes > 0)
{
var bytesRead = stream.Read(data, offset, nbytes);
if (bytesRead == 0)
throw new EndOfStreamException();
nbytes -= bytesRead;
offset += bytesRead;
}
return new UnicastData(clientId, topic, isImage, data);
}
示例15: Decompress
public override byte[] Decompress(Stream s, int dataLen, uint key)
{
var sb = new List<byte>();
var decoder = new LZWDecoder();
while (sb.Count < dataLen)
{
sb.AddRange(decoder.Decode(s.ReadBytes(s.ReadInt32())));
}
return sb.ToArray();
}