示例#1
0
 public EncodedRectangle Build(QuadNode node, VncHost.Encoding encoding)
 {
     int[] pixels = node.NodeData;
     EncodedRectangle e;
     switch (encoding)
     {
         case VncHost.Encoding.RawEncoding:
             e = new RawRectangle(rfb, framebuffer, pixels, node.Bounds);
             break;
         case VncHost.Encoding.CopyRectEncoding:
             e = new CopyRectRectangle(rfb, framebuffer, node.Bounds);
             break;
         case VncHost.Encoding.RreEncoding:
             e = new RreRectangle(rfb, framebuffer, pixels, node.Bounds);
             break;
         case VncHost.Encoding.CoRreEncoding:
             e = new CoRreRectangle(rfb, framebuffer, pixels, node.Bounds);
             break;
         case VncHost.Encoding.HextileEncoding:
             e = new HextileRectangle(rfb, framebuffer, pixels, node.Bounds);
             break;
         case VncHost.Encoding.ZrleEncoding:
             e = new ZrleRectangle(rfb, framebuffer, pixels, node.Bounds);
             break;
         case VncHost.Encoding.ZlibEncoding:
             e = new ZlibRectangle(rfb, framebuffer, pixels, node.Bounds);
             break;
         default:
             // Sanity check
             throw new Exception("Unsupported Encoding Format received: " + encoding + ".");
     }
     return e;
 }
示例#2
0
        /// <summary>
        /// Creates an object type derived from EncodedRectangle, based on the value of encoding.
        /// </summary>
        /// <param name="rectangle">A Rectangle object defining the bounds of the rectangle to be created</param>
        /// <param name="encoding">An Integer indicating the encoding type to be used for this rectangle.  Used to determine the type of EncodedRectangle to create.</param>
        /// <returns></returns>
        public EncodedRectangle Build(Rectangle rectangle, RfbProtocol.Encoding encoding)
        {
            EncodedRectangle e = null;
            int[] pixels = null;
            //Bitmap bmp = PixelGrabber.CreateScreenCapture(rectangle);
            if (framebuffer.ProcessFrameRaw != null) {
                    pixels = framebuffer.ProcessFrameRaw();
            } else {
                    Bitmap bmp = new Bitmap(rectangle.Width, rectangle.Height);
                    Graphics g = Graphics.FromImage(bmp);
                    if (framebuffer.ProcessFrame != null) {
                        framebuffer.ProcessFrame(bmp);
                    } else {
                        g.CopyFromScreen(rectangle.X, rectangle.Y, 0, 0, new Size(rectangle.Width, rectangle.Height));
                    }
                    pixels = PixelGrabber.GrabPixels(bmp, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, bmp.PixelFormat);
            }

            switch (encoding)
            {
                case RfbProtocol.Encoding.RAW_ENCODING:
                    e = new RawRectangle(rfb, framebuffer, pixels, rectangle);
                    break;
                case RfbProtocol.Encoding.COPYRECT_ENCODING:
                    e = new CopyRectRectangle(rfb, framebuffer, pixels, rectangle);
                    break;
                case RfbProtocol.Encoding.RRE_ENCODING:
                    e = new RreRectangle(rfb, framebuffer, pixels, rectangle);
                    break;
                case RfbProtocol.Encoding.CORRE_ENCODING:
                    e = new CoRreRectangle(rfb, framebuffer, pixels, rectangle);
                    break;
                case RfbProtocol.Encoding.HEXTILE_ENCODING:
                    e = new HextileRectangle(rfb, framebuffer, pixels, rectangle);
                    break;
                case RfbProtocol.Encoding.ZRLE_ENCODING:
                    e = new ZrleRectangle(rfb, framebuffer, pixels, rectangle);
                    break;
                case RfbProtocol.Encoding.ZLIB_ENCODING:
                    e = new ZlibRectangle(rfb, framebuffer, pixels, rectangle);
                    break;
                default:
                    // Sanity check
                    throw new VncProtocolException("Unsupported Encoding Format received: " + encoding.ToString() + ".");
            }
            return e;
        }
示例#3
0
        public EncodedRectangle Build(Bitmap bmp,int x, int y, RfbProtocol.Encoding encoding)
        {
            EncodedRectangle e = null;
            int[] pixels = PixelGrabber.GrabPixels(bmp, 0, 0, bmp.Width, bmp.Height, bmp.PixelFormat);
            Rectangle rect = new Rectangle(x, y, bmp.Width, bmp.Height);

            switch (encoding)
            {
                case RfbProtocol.Encoding.RAW_ENCODING:
                    e = new RawRectangle(rfb, framebuffer, pixels, rect);
                    break;
                case RfbProtocol.Encoding.COPYRECT_ENCODING:
                    e = new CopyRectRectangle(rfb, framebuffer, pixels, rect);
                    break;
                case RfbProtocol.Encoding.RRE_ENCODING:
                    e = new RreRectangle(rfb, framebuffer, pixels, rect);
                    break;
                case RfbProtocol.Encoding.CORRE_ENCODING:
                    e = new CoRreRectangle(rfb, framebuffer, pixels, rect);
                    break;
                case RfbProtocol.Encoding.HEXTILE_ENCODING:
                    e = new HextileRectangle(rfb, framebuffer, pixels, rect);
                    break;
                case RfbProtocol.Encoding.ZRLE_ENCODING:
                    e = new ZrleRectangle(rfb, framebuffer, pixels, rect);
                    break;
                case RfbProtocol.Encoding.ZLIB_ENCODING:
                    e = new ZlibRectangle(rfb, framebuffer, pixels, rect);
                    break;
                default:
                    // Sanity check
                    throw new VncProtocolException("Unsupported Encoding Format received: " + encoding.ToString() + ".");
            }
            return e;
        }