Beispiel #1
0
        /// <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));
        }
Beispiel #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));
 }