本文整理汇总了C#中IByteBuffer类的典型用法代码示例。如果您正苦于以下问题:C# IByteBuffer类的具体用法?C# IByteBuffer怎么用?C# IByteBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IByteBuffer类属于命名空间,在下文中一共展示了IByteBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: YbrFull422ToRgb
public static IByteBuffer YbrFull422ToRgb(IByteBuffer data)
{
byte[] oldPixels = data.Data;
byte[] newPixels = new byte[(oldPixels.Length / 4) * 2 * 3];
unchecked
{
int y1, y2, cb, cr;
for (int n = 0, p = 0; n < oldPixels.Length;)
{
y1 = oldPixels[n++];
y2 = oldPixels[n++];
cb = oldPixels[n++];
cr = oldPixels[n++];
newPixels[p++] = (byte)(y1 + 1.4020 * (cr - 128) + 0.5);
newPixels[p++] = (byte)(y1 - 0.3441 * (cb - 128) - 0.7141 * (cr - 128) + 0.5);
newPixels[p++] = (byte)(y1 + 1.7720 * (cb - 128) + 0.5);
newPixels[p++] = (byte)(y2 + 1.4020 * (cr - 128) + 0.5);
newPixels[p++] = (byte)(y2 - 0.3441 * (cb - 128) - 0.7141 * (cr - 128) + 0.5);
newPixels[p++] = (byte)(y2 + 1.7720 * (cb - 128) + 0.5);
}
}
return new MemoryByteBuffer(newPixels);
}
示例2: DuplicatedByteBuffer
public DuplicatedByteBuffer(IByteBuffer source)
: base(source.MaxCapacity)
{
var asDuplicate = source as DuplicatedByteBuffer;
this.buffer = asDuplicate != null ? asDuplicate.buffer : source;
this.SetIndex(source.ReaderIndex, source.WriterIndex);
}
示例3: SlicedByteBuffer
public SlicedByteBuffer(IByteBuffer buffer, int index, int length)
: base(length)
{
if (index < 0 || index > buffer.Capacity - length)
{
throw new ArgumentOutOfRangeException("index", buffer + ".slice(" + index + ", " + length + ')');
}
var slicedByteBuf = buffer as SlicedByteBuffer;
if (slicedByteBuf != null)
{
this.buffer = slicedByteBuf.buffer;
this.adjustment = slicedByteBuf.adjustment + index;
}
else if (buffer is DuplicatedByteBuffer)
{
this.buffer = buffer.Unwrap();
this.adjustment = index;
}
else
{
this.buffer = buffer;
this.adjustment = index;
}
this.length = length;
this.SetWriterIndex(length);
}
示例4: default
int IEventHandler.Peek(BufferedSocket bufferedSocket, IByteBuffer msg, ref EndPoint ep)
{
Contract.Requires(ep != null);
//Contract.Requires(bufferedSocket != null);
return default(int);
}
示例5: DicomReaderEventArgs
public DicomReaderEventArgs(long position, DicomTag tag, DicomVR vr, IByteBuffer data)
{
Position = position;
Tag = tag;
VR = vr;
Data = data;
}
示例6: WriteStringToBuffer
internal static void WriteStringToBuffer(IByteBuffer buffer, string input)
{
int typeBytes = Encoding.UTF8.GetByteCount(input);
buffer.WriteByte(typeBytes);
buffer.WriteBytes(Encoding.UTF8.GetBytes(input));
}
示例7: ToLeakAwareBuffer
protected static IByteBuffer ToLeakAwareBuffer(IByteBuffer buf)
{
IResourceLeak leak;
switch (ResourceLeakDetector.Level)
{
case ResourceLeakDetector.DetectionLevel.Simple:
leak = AbstractByteBuffer.LeakDetector.Open(buf);
if (leak != null)
{
buf = new SimpleLeakAwareByteBuffer(buf, leak);
}
break;
case ResourceLeakDetector.DetectionLevel.Advanced:
case ResourceLeakDetector.DetectionLevel.Paranoid:
leak = AbstractByteBuffer.LeakDetector.Open(buf);
if (leak != null)
{
buf = new AdvancedLeakAwareByteBuffer(buf, leak);
}
break;
case ResourceLeakDetector.DetectionLevel.Disabled:
break;
default:
throw new ArgumentOutOfRangeException();
}
return buf;
}
示例8: ReadBytesAsync
public static async Task ReadBytesAsync(this Stream stream, IByteBuffer buffer, int offset, int count, CancellationToken cancellationToken)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
if (offset < 0 || offset > buffer.Length)
{
throw new ArgumentOutOfRangeException("offset");
}
if (count < 0 || offset + count > buffer.Length)
{
throw new ArgumentOutOfRangeException("count");
}
while (count > 0)
{
var backingBytes = buffer.AccessBackingBytes(offset);
var bytesToRead = Math.Min(count, backingBytes.Count);
var bytesRead = await stream.ReadAsync(backingBytes.Array, backingBytes.Offset, bytesToRead, cancellationToken).ConfigureAwait(false);
if (bytesRead == 0)
{
throw new EndOfStreamException();
}
offset += bytesRead;
count -= bytesRead;
}
}
示例9: Decode
protected internal sealed override void Decode(IChannelHandlerContext context, IByteBuffer input, List<object> output)
{
object decode = this.Decode(context, input);
if (decode != null)
{
output.Add(decode);
}
}
示例10: UnwrapIfNeeded
static IByteBuffer UnwrapIfNeeded(IByteBuffer buf)
{
if (buf is AdvancedLeakAwareByteBuffer || buf is SimpleLeakAwareByteBuffer)
{
return buf.Unwrap();
}
return buf;
}
示例11: LazyBsonDocument
// constructors
/// <summary>
/// Initializes a new instance of the <see cref="LazyBsonDocument"/> class.
/// </summary>
/// <param name="slice">The slice.</param>
/// <exception cref="System.ArgumentNullException">slice</exception>
/// <exception cref="System.ArgumentException">LazyBsonDocument cannot be used with an IByteBuffer that needs disposing.</exception>
public LazyBsonDocument(IByteBuffer slice)
{
if (slice == null)
{
throw new ArgumentNullException("slice");
}
_slice = slice;
}
示例12: RawBsonArray
// constructors
/// <summary>
/// Initializes a new instance of the <see cref="RawBsonArray"/> class.
/// </summary>
/// <param name="slice">The slice.</param>
/// <exception cref="System.ArgumentNullException">slice</exception>
/// <exception cref="System.ArgumentException">RawBsonArray cannot be used with an IByteBuffer that needs disposing.</exception>
public RawBsonArray(IByteBuffer slice)
{
if (slice == null)
{
throw new ArgumentNullException("slice");
}
_slice = slice;
}
示例13: Equals
/// <summary>
/// Returns {@code true} if and only if the two specified buffers are
/// identical to each other as described in {@link ByteBuf#equals(Object)}.
/// This method is useful when implementing a new buffer type.
/// </summary>
public static bool Equals(IByteBuffer bufferA, IByteBuffer bufferB)
{
int aLen = bufferA.ReadableBytes;
if (aLen != bufferB.ReadableBytes)
{
return false;
}
return Equals(bufferA, bufferA.ReaderIndex, bufferB, bufferB.ReaderIndex, aLen);
}
示例14: WriteBufferAsync
public static async Task WriteBufferAsync(this Stream stream, IByteBuffer buffer, int offset, int count, CancellationToken cancellationToken)
{
while (count > 0)
{
var backingBytes = buffer.AccessBackingBytes(offset);
var bytesToWrite = Math.Min(count, backingBytes.Count - backingBytes.Offset);
await stream.WriteAsync(backingBytes.Array, backingBytes.Offset, bytesToWrite, cancellationToken);
offset += bytesToWrite;
count -= bytesToWrite;
}
}
示例15: ByteBufferStream
// constructors
/// <summary>
/// Initializes a new instance of the <see cref="ByteBufferStream"/> class.
/// </summary>
/// <param name="buffer">The buffer.</param>
/// <param name="ownsBuffer">Whether the stream owns the buffer and should Dispose it when done.</param>
public ByteBufferStream(IByteBuffer buffer, bool ownsBuffer = false)
{
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
_buffer = buffer;
_ownsBuffer = ownsBuffer;
_length = buffer.Length;
}