本文整理汇总了C#中EndianBinaryReader.ReadSByte方法的典型用法代码示例。如果您正苦于以下问题:C# EndianBinaryReader.ReadSByte方法的具体用法?C# EndianBinaryReader.ReadSByte怎么用?C# EndianBinaryReader.ReadSByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EndianBinaryReader
的用法示例。
在下文中一共展示了EndianBinaryReader.ReadSByte方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: hfzReadTile
private HfzTile hfzReadTile(EndianBinaryReader reader, HfzHeader fh, UInt32 TileX, UInt32 TileY, Boolean extraPixelBullshit)
{
debugLine("TileX: "+ TileX +", TileY: " + TileY);
List<float> pTileData = new List<float>();
UInt32 i = 0, j = 0;
UInt32 TileSize = fh.TileSize;
UInt32 mapWidth = fh.nx;
UInt32 mapHeight = fh.ny;
UInt32 Rows = TileSize;
UInt32 RowSize = TileSize-1;
if (extraPixelBullshit)
{
Epsilon e = new Epsilon(1E-3);
if (RealExtensions.EQ(TileX, (mapWidth / TileSize), e))
{
debugLine("Entering X on " + TileX + "," + TileY);
debugLine("result: " + (TileSize - (((TileX + 1) * TileSize) - mapWidth)));
Rows = TileSize;
RowSize = (TileSize - (((TileX + 1) * TileSize) - mapWidth)) - 1;
}
if (RealExtensions.EQ(TileY, (mapHeight / TileSize), e))
{
debugLine("Entering Y on " + TileX + "," + TileY);
debugLine("result: " + (TileSize - (((TileY + 1) * TileSize) - mapHeight)));
Rows = TileSize - (((TileY + 1) * TileSize) - mapHeight);
RowSize = TileSize - 1;
}
if (RealExtensions.EQ(TileX, (mapWidth / TileSize), e) && RealExtensions.EQ(TileY, (mapHeight / TileSize), e))
{
debugLine("Entering X,Y on " + TileX + "," + TileY);
debugLine("result: " + (TileSize - (((TileY + 1) * TileSize) - mapHeight)));
debugLine("result: " + ((TileSize - (((TileX + 1) * TileSize) - mapWidth)) - 1));
Rows = TileSize - (((TileY + 1) * TileSize) - mapHeight);
RowSize = (TileSize - (((TileX + 1) * TileSize) - mapWidth)) - 1;
}
}
// read vert offset and sale
byte LineDepth = 0;
Int32 FirstVal = 0;
int tileValues = 0;
int firstValues = 0;
try
{
float VertScale = reader.ReadSingle();
float VertOffset = reader.ReadSingle();
for (j = 0; j < Rows; j++)
{
LineDepth = reader.ReadByte(); // 1, 2, or 4
debugLine("Linedepth " + LineDepth);
FirstVal = reader.ReadInt32();
debugLine("FirstVal " + FirstVal);
tileValues++;
firstValues++;
float pixelValue = (float)FirstVal * VertScale + VertOffset;
// set first pixel
pTileData.Add(pixelValue);
debugLine("FirstValue: " + pixelValue);
Int32 LastVal = FirstVal;
Int32 li;
for (i = 0; i < RowSize; i++)
{
switch (LineDepth)
{
case 1:
sbyte bvalue = reader.ReadSByte();
li = (Int32)bvalue;
break;
case 2:
short svalue = reader.ReadInt16();
li = (Int32)svalue;
break;
default:
li = reader.ReadInt32();
break;
}
pixelValue = (float)(li + LastVal) * VertScale + VertOffset;
LastVal = li + LastVal;
pTileData.Add(pixelValue);
tileValues++;
debugLine("v: " + pixelValue);
}
}
debugLine("TileValues: " + tileValues);
debugLine("FirstValues: " + firstValues);
}
catch (Exception)
{
System.Console.WriteLine("TileSize: " + TileSize);
//.........这里部分代码省略.........
示例2: CharWidthInfo
public CharWidthInfo(EndianBinaryReader er)
{
Left = er.ReadSByte();
GlyphWidth = er.ReadByte();
CharWidth = er.ReadByte();
}
示例3: Read
public static Metadata Read(EndianBinaryReader r)
{
Metadata m = new Metadata();
while (true)
{
byte f = r.ReadByte();
if (f == 0x7F)
return m;
MetaField mf = new MetaField(f & 0x1F, (MetaType)(f >> 5));
switch (mf.Type)
{
case MetaType.Byte:
mf.Byte = r.ReadSByte();
break;
case MetaType.Short:
mf.Short = r.ReadInt16();
break;
case MetaType.Int:
mf.Int = r.ReadInt32();
break;
case MetaType.Float:
mf.Float = r.ReadSingle();
break;
case MetaType.String:
mf.String = Packet.ReadString8(r);
break;
case MetaType.Item:
mf.Item = SlotItem.Read(r);
break;
case MetaType.Vector:
mf.Vector = new CoordInt();
mf.Vector.X = r.ReadInt32();
mf.Vector.Y = r.ReadInt32();
mf.Vector.Z = r.ReadInt32();
break;
case MetaType.VectorF:
mf.VectorF = new CoordDouble();
mf.VectorF.X = r.ReadSingle();
mf.VectorF.Y = r.ReadSingle();
mf.VectorF.Z = r.ReadSingle();
break;
default:
throw new NotImplementedException();
}
m.Fields.Add(mf.ID, mf);
}
}
示例4: readValueFromReader
private float readValueFromReader(EndianBinaryReader reader, HffHeader header, uint xLocation, uint yLocation)
{
float value;
if (header.floatingPointFlag)
{
float readSingleValue = reader.ReadSingle();
debugLine("v: " + readSingleValue);
value = header.verticalScale * readSingleValue + header.verticalOffset;
debugLine("cv: " + value);
}
else
{
switch (header.dataSize)
{
case 1:
sbyte readSbyteValue = reader.ReadSByte();
debugLine("v: " + readSbyteValue);
value = header.verticalScale * readSbyteValue + header.verticalOffset;
debugLine("cv: " + value);
break;
case 2:
ushort readShortValue = reader.ReadUInt16();
debugLine("v: " + readShortValue);
value = header.verticalScale * readShortValue + header.verticalOffset;
debugLine("cv: " + value);
break;
default: throw new Exception("Invalid pixel data at x: " + xLocation + ", y: " + yLocation);
}
}
return value;
}