Exemplo n.º 1
0
        private void ReadRreRectCore(Rectangle rect, bool isCompact)
        {
            UInt32 numSubRects = ReadUInt32();

            byte[] data    = ReadBytes(bytesPp);
            Color  bgColor = GetColorFromData(data, 0);

            int subRectSize = bytesPp;

            if (isCompact)
            {
                subRectSize += RfbSize.CoRreSubRect;
            }
            else
            {
                subRectSize += RfbSize.RreSubRect;
            }

            RreSubRectMsg[] subRects = new RreSubRectMsg[numSubRects];
            for (int i = 0; i < numSubRects; i++)
            {
                byte[] rectBytes = ReadBytes(subRectSize);
                subRects[i] = new RreSubRectMsg(rectBytes, bytesPp, isCompact);
            }

            FillRreRect(rect, bgColor, subRects);
        }
Exemplo n.º 2
0
        private void ReadHexRect(Rectangle rect)
        {
            Color     bgColor = App.Black;
            UInt32    fgPixel = 0;
            Rectangle tile    = new Rectangle();

            for (tile.Y = rect.Y; tile.Y < rect.Bottom; tile.Y += 16)
            {
                for (tile.X = rect.X; tile.X < rect.Right; tile.X += 16)
                {
                    tile.Width  = 16;
                    tile.Height = 16;
                    tile.Width  = Math.Min(tile.Right, rect.Right) - tile.Left;
                    tile.Height = Math.Min(tile.Bottom, rect.Bottom) - tile.Top;

                    RfbHexSubEncoding encoding = (RfbHexSubEncoding)ReadByte();

                    if ((encoding & RfbHexSubEncoding.Raw) != 0)
                    {
                        ReadRawRect(tile);
                        if (opts.ViewOpts.ScrnUpdAlgo == ScrnUpdAlgo.Asap)
                        {
                            view.InvalidateRect(tile);
                        }
                        continue;
                    }

                    byte[] data;
                    if ((encoding & RfbHexSubEncoding.BgSpec) != 0)
                    {
                        data    = ReadBytes(bytesPp);
                        bgColor = GetColorFromData(data, 0);
                    }

                    if ((encoding & RfbHexSubEncoding.FgSpec) != 0)
                    {
                        data    = ReadBytes(bytesPp);
                        fgPixel = RfbProtoUtil.GetPixelFromData(data, 0, bytesPp);
                    }

                    byte numSubRects = 0;
                    if ((encoding & RfbHexSubEncoding.AnySubRects) != 0)
                    {
                        numSubRects = ReadByte();
                    }

                    bool subRectsColored = ((encoding & RfbHexSubEncoding.SubRectsColored) != 0);

                    int subRectSize = RfbSize.HexSubRect;
                    subRectSize += subRectsColored ? (int)bytesPp : 0;
                    RreSubRectMsg[] subRects  = new RreSubRectMsg[numSubRects];
                    byte[]          rectBytes = ReadBytes(subRectSize * numSubRects);
                    for (int i = 0; i < numSubRects; i++)
                    {
                        subRects[i] = new HexSubRectMsg(rectBytes, (UInt32)(i * subRectSize), bytesPp, subRectsColored, fgPixel);
                    }
                    FillRreRect(tile, bgColor, subRects);
                    if (opts.ViewOpts.ScrnUpdAlgo == ScrnUpdAlgo.Asap)
                    {
                        view.InvalidateRect(tile);
                    }
                }
            }
        }