コード例 #1
0
 /// <summary>
 /// Sends the format to be used by the server when sending Framebuffer Updates. See RFB Doc v. 3.8 section 6.3.1.
 /// </summary>
 /// <param name="buffer">A Framebuffer telling the server how to encode pixel data. Typically this will be the same one sent by the server during initialization.</param>
 public void WriteSetPixelFormat(FrameBufferInfos infos)
 {
     writer.Write(SET_PIXEL_FORMAT);
     WritePadding(3);
     writer.Write(infos.ToPixelFormat());                        // 16-byte Pixel Format
     writer.Flush();
 }
コード例 #2
0
        /// <summary>
        /// Reads the server's Initialization message, specifically the remote Framebuffer's properties. See RFB Doc v. 3.8 section 6.1.5.
        /// </summary>
        /// <returns>Returns a Framebuffer object representing the geometry and properties of the remote host.</returns>
        public FrameBufferInfos ReadServerInit()
        {
            int w = (int)reader.ReadUInt16();
            int h = (int)reader.ReadUInt16();
            FrameBufferInfos buffer = FrameBufferInfos.FromPixelFormat(reader.ReadBytes(16), w, h);
            int length = (int)reader.ReadUInt32();

            buffer.DesktopName = GetString(reader.ReadBytes(length));

            return(buffer);
        }
コード例 #3
0
        public override int ReadPixel()
        {
            // NOTE: the 16 bit pixel value uses a 565 layout (i.e., 5 bits
            // for Red, 6 for Green, 5 for Blue).  As such, I'm doing an extra
            // shift below for each colour to get from 565 to 888 in order to
            // return a full 32-bit pixel value.
            byte[] b = reader.ReadBytes(2);

            ushort           pixel = (ushort)(((uint)b[0]) & 0xFF | ((uint)b[1]) << 8);
            FrameBufferInfos i     = framebuffer.infos;

            byte red   = (byte)(((pixel >> i.RedShift) & i.RedMax) << 3);                   // 5 bits to 8
            byte green = (byte)(((pixel >> i.GreenShift) & i.GreenMax) << 2);               // 6 bits to 8
            byte blue  = (byte)(((pixel >> i.BlueShift) & i.BlueMax) << 3);                 // 5 bits to 8

            return(ToGdiPlusOrder(red, green, blue));
        }
コード例 #4
0
        public override int ReadPixel()
        {
            // Read the pixel value
            byte[] b = reader.ReadBytes(4);

            uint pixel = (uint)(((uint)b[0]) & 0xFF |
                                ((uint)b[1]) << 8 |
                                ((uint)b[2]) << 16 |
                                ((uint)b[3]) << 24);

            FrameBufferInfos i = framebuffer.infos;

            // Extract RGB intensities from pixel
            byte red   = (byte)((pixel >> i.RedShift) & i.RedMax);
            byte green = (byte)((pixel >> i.GreenShift) & i.GreenMax);
            byte blue  = (byte)((pixel >> i.BlueShift) & i.BlueMax);

            return(ToGdiPlusOrder(red, green, blue));
        }
コード例 #5
0
        /// <summary>
        /// Finish setting-up protocol with VNC Host.  Should be called after Connect and Authenticate (if password required).
        /// </summary>
        public void Initialize()
        {
            // Finish initializing protocol with host
            rfb.WriteClientInitialisation(false);
            bufferInfos = rfb.ReadServerInit();

            theBitmap = new Bitmap(bufferInfos.Width, bufferInfos.Height);

            rfb.WriteSetPixelFormat(bufferInfos);    // just use the server's framebuffer format

            rfb.WriteSetEncodings(new uint[] { RfbProtocol.ZRLE_ENCODING,
                                               RfbProtocol.HEXTILE_ENCODING,
                                               //	RfbProtocol.CORRE_ENCODING, // CoRRE is buggy in some hosts, so don't bother using
                                               RfbProtocol.RRE_ENCODING,
                                               RfbProtocol.COPYRECT_ENCODING,
                                               RfbProtocol.RAW_ENCODING });

            // Create an EncodedRectangleFactory so that EncodedRectangles can be built according to set pixel layout
            factory = new EncodedRectangleFactory(rfb);
        }