DecodeUInt16BE() public static méthode

Decodes a ushort from a byte-array, in big-endian encoding.
public static DecodeUInt16BE ( byte buffer, int offset ) : ushort
buffer byte /// A array which contains the . ///
offset int /// The index in at which the starts. ///
Résultat ushort
        /// <summary>
        /// Decodes a <see cref="VncPixelFormat"/> from a <see cref="byte"/> array.
        /// </summary>
        /// <param name="buffer">
        /// The <see cref="byte"/> array which contains the <see cref="VncPixelFormat"/> data.
        /// </param>
        /// <param name="offset">
        /// The first index in the <paramref name="buffer"/> which contains the <see cref="VncPixelFormat"/>
        /// data.
        /// </param>
        /// <returns>
        /// A <see cref="VncPixelFormat"/> object.
        /// </returns>
        internal static VncPixelFormat Decode(byte[] buffer, int offset)
        {
            var bitsPerPixel   = buffer[offset + 0];
            var depth          = buffer[offset + 1];
            var isLittleEndian = buffer[offset + 2] == 0;
            var isPalettized   = buffer[offset + 3] == 0;
            var redBits        = BitsFromMax(VncUtility.DecodeUInt16BE(buffer, offset + 4));
            var greenBits      = BitsFromMax(VncUtility.DecodeUInt16BE(buffer, offset + 6));
            var blueBits       = BitsFromMax(VncUtility.DecodeUInt16BE(buffer, offset + 8));
            var redShift       = buffer[offset + 10];
            var greenShift     = buffer[offset + 11];
            var blueShift      = buffer[offset + 12];

            return(new VncPixelFormat(
                       bitsPerPixel,
                       depth,
                       redBits,
                       redShift,
                       greenBits,
                       greenShift,
                       blueBits,
                       blueShift,
                       isLittleEndian,
                       isPalettized));
        }
Exemple #2
0
 /// <summary>
 /// Reads a <see cref="ushort"/> in big-endian encoding from the stream and advances the
 /// position within the stream by two bytes.
 /// </summary>
 /// <returns>
 /// The <see cref="ushort"/> which was read from the stream.
 /// </returns>
 public ushort ReceiveUInt16BE()
 {
     return(VncUtility.DecodeUInt16BE(this.Receive(2), 0));
 }