本文整理汇总了C#中ByteBuffer.Position方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.Position方法的具体用法?C# ByteBuffer.Position怎么用?C# ByteBuffer.Position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.Position方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public int Read (ByteBuffer buffer)
{
int offset = buffer.Position () + buffer.ArrayOffset ();
int num2 = s.Read (buffer.Array (), offset, (buffer.Limit () + buffer.ArrayOffset ()) - offset);
buffer.Position (buffer.Position () + num2);
return num2;
}
示例2: Write
public int Write (ByteBuffer buffer)
{
int offset = buffer.Position () + buffer.ArrayOffset ();
int count = (buffer.Limit () + buffer.ArrayOffset ()) - offset;
s.Write (buffer.Array (), offset, count);
buffer.Position (buffer.Position () + count);
return count;
}
示例3: Set
public void Set(int size, int type, int stride, ByteBuffer pointer)
{
if (stride == 0)
{
switch (type)
{
case 0x1400:
case 0x1401:
stride = size;
break;
case 0x1402:
stride = size * 2;
break;
case 0x1406:
stride = size * 4;
break;
}
}
this.size = size;
this.type = type;
this.stride = stride;
this.pointer = pointer;
this.pos = pointer.Position();
}
示例4: WriteHeader
/// <summary>
/// Writes MAT-file header into <c>Stream</c>
/// </summary>
/// <param name="stream">The output stream</param>
private void WriteHeader( BinaryWriter stream )
{
//write descriptive text
MatFileHeader header = MatFileHeader.CreateHeader();
char[] dest = new char[116];
char[] src = header.Description.ToCharArray();
Array.Copy( src, 0, dest, 0, src.Length );
byte[] endianIndicator = header.EndianIndicator;
//ByteBuffer buf = new ByteBuffer( dest.Length * 2 + /* char size */ + 2 + endianIndicator.Length );
ByteBuffer buf = new ByteBuffer(128); // The header is always a 128-byte header
for( int i = 0; i < dest.Length; i++ )
{
buf.Put( (byte)dest[i] );
}
//write subsyst data offset
buf.Position( buf.Position() + 8 );
// write version
int version = header.Version;
//buf.Put( (byte)(version >> 8) );
//buf.Put( (byte)version );
buf.PutShort((short)version);
buf.Put( endianIndicator );
stream.Write( buf.Array() );
}
示例5: CompactByteBuffer
// 渡されたByteBufferを切り诘めた、新しいByteBufferを作る
private ByteBuffer CompactByteBuffer(ByteBuffer b)
{
int count = b.Position();
ByteBuffer ret = ByteBuffer.Allocate(count);
b.Position(0);
for (int i = 0; i < count; i++)
{
ret.Put(b.Get());
}
ret.Position(0);
return ret;
}