/// <summary> /// Serializes this <see cref="VncPixelFormat"/> to a <see cref="byte"/> array. /// </summary> /// <param name="buffer"> /// The <see cref="byte"/> array to which to encode the <see cref="VncPixelFormat"/> object. /// </param> /// <param name="offset"> /// The first <see cref="byte"/> at which to store the <see cref="VncPixelFormat"/> data. /// </param> internal void Encode(byte[] buffer, int offset) { buffer[offset + 0] = (byte)this.BitsPerPixel; buffer[offset + 1] = (byte)this.BitDepth; buffer[offset + 2] = (byte)(this.IsLittleEndian ? 0 : 1); buffer[offset + 3] = (byte)(this.IsPalettized ? 0 : 1); VncUtility.EncodeUInt16BE(buffer, offset + 4, (ushort)((1 << this.RedBits) - 1)); VncUtility.EncodeUInt16BE(buffer, offset + 6, (ushort)((1 << this.GreenBits) - 1)); VncUtility.EncodeUInt16BE(buffer, offset + 8, (ushort)((1 << this.BlueBits) - 1)); buffer[offset + 10] = (byte)this.RedShift; buffer[offset + 11] = (byte)this.GreenShift; buffer[offset + 12] = (byte)this.BlueShift; }
private void SendFramebufferUpdateRequest(bool incremental, int x, int y, int width, int height) { var p = new byte[10]; p[0] = (byte)3; p[1] = (byte)(incremental ? 1 : 0); VncUtility.EncodeUInt16BE(p, 2, (ushort)x); VncUtility.EncodeUInt16BE(p, 4, (ushort)y); VncUtility.EncodeUInt16BE(p, 6, (ushort)width); VncUtility.EncodeUInt16BE(p, 8, (ushort)height); this.c.Send(p); }
/// <summary> /// 向VNC服务端发送一个鼠标动作,点击鼠标按钮等 /// </summary> /// <param name="x">鼠标的X坐标。</param> /// <param name="y">鼠标的Y坐标。</param> /// <param name="pressedButtons"> /// A bit mask of pressed mouse buttons, in X11 convention: 1 is left, 2 is middle, and 4 is right. /// Mouse wheel scrolling is treated as a button event: 8 for up and 16 for down. /// </param> public void SendPointerEvent(int x, int y, int pressedButtons) { var p = new byte[6]; p[0] = (byte)5; p[1] = (byte)pressedButtons; VncUtility.EncodeUInt16BE(p, 2, (ushort)x); VncUtility.EncodeUInt16BE(p, 4, (ushort)y); if (IsConnected) { _c.Send(p); } }
private void SendFramebufferUpdateRequest(bool incremental) { var p = new byte[10]; p[0] = (byte)3; p[1] = (byte)(incremental ? 1 : 0); VncUtility.EncodeUInt16BE(p, 2, (ushort)0); VncUtility.EncodeUInt16BE(p, 4, (ushort)0); VncUtility.EncodeUInt16BE(p, 6, (ushort)this.Framebuffer.Width); VncUtility.EncodeUInt16BE(p, 8, (ushort)this.Framebuffer.Height); this.c.Send(p); }
/// <summary> /// Writes a <see cref="ushort"/> in big endian encoding to the current position in the stream and advances the position within the stream by two bytes. /// </summary> /// <param name="value"> /// The <see cref="ushort"/> to write to the stream. /// </param> public void SendUInt16BE(ushort value) { this.Send(VncUtility.EncodeUInt16BE(value)); }