当前位置: 首页>>代码示例>>C#>>正文


C# IByteBuffer类代码示例

本文整理汇总了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);
        }
开发者ID:GMZ,项目名称:fo-dicom,代码行数:27,代码来源:PixelDataConverter.cs

示例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);
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:7,代码来源:DuplicatedByteBuffer.cs

示例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);
        }
开发者ID:dalong123,项目名称:DotNetty,代码行数:28,代码来源:SlicedByteBuffer.cs

示例4: default

        int IEventHandler.Peek(BufferedSocket bufferedSocket, IByteBuffer msg, ref EndPoint ep)
        {
            Contract.Requires(ep != null);
            //Contract.Requires(bufferedSocket != null);

            return default(int);
        }
开发者ID:splitice,项目名称:EventCore,代码行数:7,代码来源:IEventHandler.cs

示例5: DicomReaderEventArgs

 public DicomReaderEventArgs(long position, DicomTag tag, DicomVR vr, IByteBuffer data)
 {
     Position = position;
     Tag = tag;
     VR = vr;
     Data = data;
 }
开发者ID:aerik,项目名称:fo-dicom,代码行数:7,代码来源:DicomReaderEventArgs.cs

示例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));
        }
开发者ID:HakanL,项目名称:animatroller,代码行数:7,代码来源:NettyClient.cs

示例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;
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:27,代码来源:AbstractByteBufferAllocator.cs

示例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;
            }
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:32,代码来源:StreamExtensionMethods.cs

示例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);
     }
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:8,代码来源:LineBasedFrameDecoder.cs

示例10: UnwrapIfNeeded

 static IByteBuffer UnwrapIfNeeded(IByteBuffer buf)
 {
     if (buf is AdvancedLeakAwareByteBuffer || buf is SimpleLeakAwareByteBuffer)
     {
         return buf.Unwrap();
     }
     return buf;
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:8,代码来源:AbstractPooledByteBufTest.cs

示例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;
        }
开发者ID:einaregilsson,项目名称:mongo-csharp-driver,代码行数:16,代码来源:LazyBsonDocument.cs

示例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;
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:16,代码来源:RawBsonArray.cs

示例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);
 }
开发者ID:dalong123,项目名称:DotNetty,代码行数:14,代码来源:ByteBufferUtil.cs

示例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;
     }
 }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:11,代码来源:StreamExtensionMethods.cs

示例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;
        }
开发者ID:cihanozhan,项目名称:mongo-csharp-driver,代码行数:17,代码来源:ByteBufferStream.cs


注:本文中的IByteBuffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。