Ejemplo n.º 1
0
        internal static void drawMultiPatBltOrder()
        {
            int fgcolor = RdpBitmap.convertColor(ForegroundColor);
            int bgcolor = RdpBitmap.convertColor(BackgroundColor);

            foreach (Rectangle rectangle in DeltaList)
            {
                PatBltOrder.drawPatBltOrder(Opcode, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, fgcolor, bgcolor, Brush);
            }
        }
Ejemplo n.º 2
0
        internal static void drawPatBltOrder()
        {
            int x       = X;
            int y       = Y;
            int cX      = CX;
            int cY      = CY;
            int fgcolor = RdpBitmap.convertColor(ForegroundColor);
            int bgcolor = RdpBitmap.convertColor(BackgroundColor);

            drawPatBltOrder(Opcode, x, y, cX, cY, fgcolor, bgcolor, Brush);
        }
Ejemplo n.º 3
0
        internal static void drawRectangleOrder()
        {
            int num;

            if (Options.server_bpp == 0x10)
            {
                num = RdpBitmap.convertFrom16bit(((ColourB << 0x10) | (ColourG << 8)) | ColourR);
            }
            else
            {
                num = RdpBitmap.convertFrom8bit(ColourR);
            }
            fillRectangle(X, Y, CX, CY, num);
        }
Ejemplo n.º 4
0
        internal static RdpBitmap getBitmap(int cache_id, int cache_idx)
        {
            RdpBitmap bitmap = null;

            if ((cache_id < m_BitmapCache.Length) && (cache_idx < m_BitmapCache[cache_id].Length))
            {
                bitmap = m_BitmapCache[cache_id][cache_idx];
                if (bitmap != null)
                {
                    return(bitmap);
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
 internal static void Reset(bool bResetBitmapCache)
 {
     m_BitmapCaches = 0;
     m_TextCache.Clear();
     for (int i = 0; i < 0x100; i++)
     {
         m_TextCache.Add(null);
     }
     if (bResetBitmapCache)
     {
         m_BitmapCache[0] = new RdpBitmap[120];
         m_BitmapCache[1] = new RdpBitmap[120];
         m_BitmapCache[2] = new RdpBitmap[0x400];
     }
 }
Ejemplo n.º 6
0
        internal static void drawMemBltOrder()
        {
            int       x      = X;
            int       y      = Y;
            int       cX     = CX;
            int       cY     = CY;
            int       srcX   = SrcX;
            int       srcY   = SrcY;
            RdpBitmap bitmap = Cache.getBitmap(CacheID, CacheIDX);

            if (bitmap != null)
            {
                int boundsRight = (x + cX) - 1;
                if (boundsRight > Options.BoundsRight)
                {
                    boundsRight = Options.BoundsRight;
                }
                if (x < Options.BoundsLeft)
                {
                    x = Options.BoundsLeft;
                }
                cX = (boundsRight - x) + 1;
                int boundsBottom = (y + cY) - 1;
                if (boundsBottom > Options.BoundsBottom)
                {
                    boundsBottom = Options.BoundsBottom;
                }
                if (y < Options.BoundsTop)
                {
                    y = Options.BoundsTop;
                }
                cY    = (boundsBottom - y) + 1;
                srcX += x - X;
                srcY += y - Y;
                Options.Enter();
                try
                {
                    ChangedRect.Invalidate(x, y, cX, cY);
                    RasterOp.do_array(Opcode, Options.Canvas, Options.Canvas.Width, x, y, cX, cY, bitmap.getData(ColorTable), bitmap.getWidth(), srcX, srcY);
                }
                finally
                {
                    Options.Exit();
                }
            }
        }
Ejemplo n.º 7
0
        internal static void drawMultiRectangleOrder()
        {
            int num;

            if (Options.server_bpp == 0x10)
            {
                num = RdpBitmap.convertFrom16bit(((ColourB << 0x10) | (ColourG << 8)) | ColourR);
            }
            else
            {
                num = RdpBitmap.convertFrom8bit(ColourR);
            }
            foreach (Rectangle rectangle in DeltaList)
            {
                RectangleOrder.fillRectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, num);
            }
        }
Ejemplo n.º 8
0
 internal static void putBitmap(int cache_id, int cache_idx, RdpBitmap bitmap, int stamp)
 {
     try
     {
         if ((cache_id >= m_BitmapCache.Length) || (cache_idx >= m_BitmapCache[cache_id].Length))
         {
             throw new RDFatalException(string.Concat(new object[] { "Bitmap cache out of range (", cache_id, ",", cache_idx, ")!" }));
         }
         m_BitmapCache[cache_id][cache_idx] = bitmap;
         if (bitmap == null)
         {
             throw new Exception("Caching null bitmap!");
         }
         // Bitmap cache id: cache_id
     }
     catch { }
 }
Ejemplo n.º 9
0
        private static void processBitmapCache(RdpPacket data, bool bCompressed, bool bNoCompressionHdr)
        {
            int num2;
            int num  = num2 = 0;
            int num3 = data.ReadByte();

            data.ReadByte();
            int width  = data.ReadByte();
            int height = data.ReadByte();
            int bpp    = (data.ReadByte() + 7) / 8;

            num = data.ReadLittleEndian16();
            int num8 = data.ReadLittleEndian16();

            if (!bCompressed)
            {
                byte[] buffer = new byte[(width * height) * bpp];
                int    offset = (height - 1) * (width * bpp);

                for (int i = 0; i < height; i++)
                {
                    data.Read(buffer, offset, width * bpp);
                    offset -= width * bpp;
                }

                Cache.putBitmap(num3, num8, new RdpBitmap(buffer, width, height, bpp, 0, 0), 0);
            }
            else
            {
                if (!bNoCompressionHdr)
                {
                    data.ReadLittleEndian16();
                    num2 = data.ReadLittleEndian16();
                    data.ReadLittleEndian16();
                    data.ReadLittleEndian16();
                }
                else
                {
                    num2 = num;
                }

                if (bpp == 1)
                {
                    byte[] buffer2 = RdpBitmap.decompress(width, height, num2, data, bpp);

                    if (buffer2 != null)
                    {
                        Cache.putBitmap(num3, num8, new RdpBitmap(buffer2, width, height, bpp, 0, 0), 0);
                    }
                }
                else
                {
                    uint[] numArray = RdpBitmap.decompressInt(width, height, num2, data, bpp);

                    if (numArray != null)
                    {
                        Cache.putBitmap(num3, num8, new RdpBitmap(numArray, width, height, bpp, 0, 0), 0);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        private static void process_bmpdata(RdpPacket data, int flags, int cache_id, int cache_idx, ulong persist_key)
        {
            RdpBitmap bitmap;

            byte[] buffer;
            int    bpp = data.ReadByte();

            data.ReadByte();
            data.ReadByte();
            int num2   = data.ReadByte();
            int width  = data.ReadLittleEndian16();
            int height = data.ReadLittleEndian16();
            int size   = data.ReadLittleEndian32();

            if (num2 == 1)
            {
                if (bpp == 1)
                {
                    buffer = RdpBitmap.decompress(width, height, size, data, bpp);

                    if (buffer == null)
                    {
                        return;
                    }

                    bitmap = new RdpBitmap(buffer, width, height, bpp, 0, 0);
                }
                else
                {
                    uint[] numArray = RdpBitmap.decompressInt(width, height, size, data, bpp);

                    if (numArray == null)
                    {
                        return;
                    }

                    bitmap = new RdpBitmap(numArray, width, height, bpp, 0, 0);
                }
            }
            else
            {
                buffer = new byte[(width * height) * bpp];

                for (int i = 0; i < height; i++)
                {
                    data.Read(buffer, ((height - i) - 1) * (width * bpp), width * bpp);
                }

                if (bpp == 1)
                {
                    bitmap = new RdpBitmap(buffer, width, height, bpp, 0, 0);
                }
                else
                {
                    bitmap = new RdpBitmap(RdpBitmap.convertImage(buffer, bpp), width, height, bpp, 0, 0);
                }
            }

            if (bitmap != null)
            {
                Cache.putBitmap(cache_id, cache_idx, bitmap, 0);

                if ((flags & 0x100) != 0)
                {
                    bitmap.PersistCache(persist_key);
                    Cache.m_BitmapCaches++;
                }
            }
        }
Ejemplo n.º 11
0
        private static void process_bmpcache2(RdpPacket data, int flags, bool compressed)
        {
            RdpBitmap bitmap;
            int       num3;
            int       num4;

            byte[] buffer;
            ulong  key  = 0L;
            int    num2 = flags & 7;
            int    bpp  = ((flags & 0x38) >> 3) - 2;

            if ((flags & 0x800) != 0)
            {
                throw new RDFatalException("DO_NOT_CACHE flag not supported!");
            }

            if ((flags & 0x100) != 0)
            {
                byte[] buffer2 = new byte[8];
                data.Read(buffer2, 0, buffer2.Length);
                key = BitConverter.ToUInt64(buffer2, 0);
            }

            if ((flags & 0x80) != 0)
            {
                num3 = data.ReadEncodedUnsigned16();
                num4 = num3;
            }
            else
            {
                num3 = data.ReadEncodedUnsigned16();
                num4 = data.ReadEncodedUnsigned16();
            }

            int size = data.ReadEncoded32();
            int num6 = data.ReadEncodedUnsigned16();

            if (compressed)
            {
                if ((flags & 0x400) == 0)
                {
                    data.Position += 8L;
                    size          -= 8;
                }

                if (bpp == 1)
                {
                    buffer = RdpBitmap.decompress(num3, num4, size, data, bpp);

                    if (buffer == null)
                    {
                        return;
                    }

                    bitmap = new RdpBitmap(buffer, num3, num4, bpp, 0, 0);
                }
                else
                {
                    uint[] numArray = RdpBitmap.decompressInt(num3, num4, size, data, bpp);

                    if (numArray == null)
                    {
                        return;
                    }

                    bitmap = new RdpBitmap(numArray, num3, num4, bpp, 0, 0);
                }
            }
            else
            {
                buffer = new byte[(num3 * num4) * bpp];

                for (int i = 0; i < num4; i++)
                {
                    data.Read(buffer, ((num4 - i) - 1) * (num3 * bpp), num3 * bpp);
                }
                if (bpp == 1)
                {
                    bitmap = new RdpBitmap(buffer, num3, num4, bpp, 0, 0);
                }
                else
                {
                    bitmap = new RdpBitmap(RdpBitmap.convertImage(buffer, bpp), num3, num4, bpp, 0, 0);
                }
            }

            if (bitmap != null)
            {
                Cache.putBitmap(num2, num6, bitmap, 0);

                if ((flags & 0x100) != 0)
                {
                    bitmap.PersistCache(key);
                    Cache.m_BitmapCaches++;
                }
            }
        }
Ejemplo n.º 12
0
        internal static void processBitmapUpdates(RdpPacket data)
        {
            int num   = 0;
            int x     = 0;
            int y     = 0;
            int num4  = 0;
            int num5  = 0;
            int cx    = 0;
            int cy    = 0;
            int num8  = 0;
            int num9  = 0;
            int num10 = 0;
            int num11 = 0;
            int size  = 0;

            byte[] buffer = null;
            num = data.ReadLittleEndian16();
            for (int i = 0; i < num; i++)
            {
                x    = data.ReadLittleEndian16();
                y    = data.ReadLittleEndian16();
                num4 = data.ReadLittleEndian16();
                num5 = data.ReadLittleEndian16();
                cx   = data.ReadLittleEndian16();
                cy   = data.ReadLittleEndian16();
                int bpp = (data.ReadLittleEndian16() + 7) / 8;
                num10 = data.ReadLittleEndian16();
                num11 = data.ReadLittleEndian16();
                num8  = (num4 - x) + 1;
                num9  = (num5 - y) + 1;
                if (num10 == 0)
                {
                    buffer = new byte[(cx * cy) * bpp];
                    for (int j = 0; j < cy; j++)
                    {
                        data.Read(buffer, ((cy - j) - 1) * (cx * bpp), cx * bpp);
                    }
                    uint[] src = RdpBitmap.convertImage(buffer, bpp);
                    ChangedRect.Invalidate(x, y, cx, cy);
                    Options.Canvas.SetPixels(x, y, num8, num9, src, 0, 0, cx);
                }
                else
                {
                    if ((num10 & 0x400) != 0)
                    {
                        size = num11;
                    }
                    else
                    {
                        data.Position += 2L;
                        size           = data.ReadLittleEndian16();
                        data.Position += 4L;
                    }
                    if (bpp == 1)
                    {
                        buffer = RdpBitmap.decompress(cx, cy, size, data, bpp);
                        ChangedRect.Invalidate(x, y, num8, num9);
                        for (int k = 0; k < num9; k++)
                        {
                            int index = k * cx;
                            int num18 = 0;
                            while (num18 < num8)
                            {
                                int num19 = buffer[index];
                                Options.Canvas.SetPixel(x + num18, y + k, RdpBitmap.convertFrom8bit(num19));
                                num18++;
                                index++;
                            }
                        }
                    }
                    else
                    {
                        uint[] numArray2 = RdpBitmap.decompressInt(cx, cy, size, data, bpp);
                        ChangedRect.Invalidate(x, y, num8, num9);
                        Options.Canvas.SetPixels(x, y, num8, num9, numArray2, 0, 0, cx);
                    }
                }
            }
        }
Ejemplo n.º 13
0
        internal static void drawTriBltOrder()
        {
            int x           = X;
            int y           = Y;
            int cX          = CX;
            int cY          = CY;
            int srcX        = SrcX;
            int srcY        = SrcY;
            int boundsRight = (x + cX) - 1;

            if (boundsRight > Options.BoundsRight)
            {
                boundsRight = Options.BoundsRight;
            }
            if (x < Options.BoundsLeft)
            {
                x = Options.BoundsLeft;
            }
            cX = (boundsRight - x) + 1;
            int boundsBottom = (y + cY) - 1;

            if (boundsBottom > Options.BoundsBottom)
            {
                boundsBottom = Options.BoundsBottom;
            }
            if (y < Options.BoundsTop)
            {
                y = Options.BoundsTop;
            }
            cY    = (boundsBottom - y) + 1;
            srcX += x - X;
            srcY += y - Y;
            int fgcolor = RdpBitmap.convertColor(ForegroundColor);
            int bgcolor = RdpBitmap.convertColor(BackgroundColor);

            Options.Enter();
            try
            {
                RdpBitmap bitmap = Cache.getBitmap(CacheID, CacheIDX);
                if (bitmap != null)
                {
                    ChangedRect.Invalidate(x, y, cX, cY);
                    switch (Opcode)
                    {
                    case 0x69:
                        RasterOp.do_array(6, Options.Canvas, Options.Canvas.Width, x, y, cX, cY, bitmap.getData(ColorTable), bitmap.getWidth(), srcX, srcY);
                        PatBltOrder.drawPatBltOrder(9, x, y, cX, cY, fgcolor, bgcolor, Brush);
                        return;

                    case 0xb8:
                        PatBltOrder.drawPatBltOrder(6, x, y, cX, cY, fgcolor, bgcolor, Brush);
                        RasterOp.do_array(8, Options.Canvas, Options.Canvas.Width, x, y, cX, cY, bitmap.getData(ColorTable), bitmap.getWidth(), srcX, srcY);
                        PatBltOrder.drawPatBltOrder(6, x, y, cX, cY, fgcolor, bgcolor, Brush);
                        return;

                    case 0xc0:
                        RasterOp.do_array(12, Options.Canvas, Options.Canvas.Width, x, y, cX, cY, bitmap.getData(ColorTable), bitmap.getWidth(), srcX, srcY);
                        PatBltOrder.drawPatBltOrder(8, x, y, cX, cY, fgcolor, bgcolor, Brush);
                        return;
                    }
                    // Unimplemented Triblt opcode: Opcode
                    RasterOp.do_array(12, Options.Canvas, Options.Canvas.Width, x, y, cX, cY, bitmap.getData(ColorTable), bitmap.getWidth(), srcX, srcY);
                }
            }
            finally
            {
                Options.Exit();
            }
        }
Ejemplo n.º 14
0
        internal static void drawText()
        {
            int x           = X;
            int y           = Y;
            int num5        = 0;
            int sourceIndex = 0;
            int cx          = BoxRight - BoxLeft;
            int cy          = BoxBottom - BoxTop;
            int num9        = ClipRight - ClipLeft;
            int num10       = ClipBottom - ClipTop;
            int color       = RdpBitmap.convertColor(BackgroundColor);
            int fgcolor     = RdpBitmap.convertColor(ForegroundColor);

            Options.Enter();
            try
            {
                ChangedRect.Invalidate(BoxLeft, BoxTop, num9, num10);
                if (cx > 1)
                {
                    fillRectangle(BoxLeft, BoxTop, cx, cy, color);
                }
                else if (Mixmode == 1)
                {
                    fillRectangle(ClipLeft, ClipTop, num9, num10, color);
                }
                int num11 = 0;
                while (num11 < GlyphLength)
                {
                    Glyph  glyph;
                    byte[] buffer;
                    switch ((GlyphIndices[sourceIndex + num11] & 0xff))
                    {
                    case 0xfe:
                        buffer = Cache.getText(GlyphIndices[(sourceIndex + num11) + 1] & 0xff);
                        if (((buffer != null) && (buffer[1] == 0)) && ((Flags & 0x20) == 0))
                        {
                            if ((Flags & 4) == 0)
                            {
                                goto Label_01C7;
                            }
                            y += GlyphIndices[(sourceIndex + num11) + 2] & 0xff;
                        }
                        goto Label_01DD;

                    case 0xff:
                        if ((num11 + 2) >= GlyphLength)
                        {
                            throw new RDFatalException("Text order is incorrect");
                        }
                        break;

                    default:
                        goto Label_0339;
                    }
                    byte[] destinationArray = new byte[GlyphIndices[(sourceIndex + num11) + 2] & 0xff];
                    Array.Copy(GlyphIndices, sourceIndex, destinationArray, 0, GlyphIndices[(sourceIndex + num11) + 2] & 0xff);
                    Cache.putText(GlyphIndices[(sourceIndex + num11) + 1] & 0xff, destinationArray);
                    GlyphLength -= num11 + 3;
                    sourceIndex  = num11 + 3;
                    num11        = 0;
                    continue;
Label_01C7:
                    x += GlyphIndices[(sourceIndex + num11) + 2] & 0xff;
Label_01DD:
                    if ((num11 + 2) < GlyphLength)
                    {
                        num11 += 3;
                    }
                    else
                    {
                        num11 += 2;
                    }
                    GlyphLength -= num11;
                    sourceIndex  = num11;
                    num11        = 0;
                    for (int i = 0; i < buffer.Length; i++)
                    {
                        glyph = Cache.getFont(Font, buffer[i] & 0xff);
                        if ((Flags & 0x20) == 0)
                        {
                            num5 = buffer[++i] & 0xff;
                            if ((num5 & 0x80) != 0)
                            {
                                if ((Flags & 4) != 0)
                                {
                                    int num13 = twosComplement16((buffer[i + 1] & 0xff) | ((buffer[i + 2] & 0xff) << 8));
                                    y += num13;
                                    i += 2;
                                }
                                else
                                {
                                    int num14 = twosComplement16((buffer[i + 1] & 0xff) | ((buffer[i + 2] & 0xff) << 8));
                                    x += num14;
                                    i += 2;
                                }
                            }
                            else if ((Flags & 4) != 0)
                            {
                                y += num5;
                            }
                            else
                            {
                                x += num5;
                            }
                        }
                        if (glyph != null)
                        {
                            drawGlyph(Mixmode, X + glyph.Offset, Y + glyph.BaseLine, glyph.Width, glyph.Height, glyph.FontData, color, fgcolor);
                            if ((Flags & 0x20) != 0)
                            {
                                x += Options.e;
                            }
                        }
                    }
                    continue;
Label_0339:
                    glyph = Cache.getFont(Font, GlyphIndices[sourceIndex + num11] & 0xff);
                    if ((Flags & 0x20) == 0)
                    {
                        num5 = GlyphIndices[sourceIndex + ++num11] & 0xff;
                        if ((num5 & 0x80) != 0)
                        {
                            if ((Flags & 4) != 0)
                            {
                                int num15 = twosComplement16((GlyphIndices[(sourceIndex + num11) + 1] & 0xff) | ((GlyphIndices[(sourceIndex + num11) + 2] & 0xff) << 8));
                                y     += num15;
                                num11 += 2;
                            }
                            else
                            {
                                int num16 = twosComplement16((GlyphIndices[(sourceIndex + num11) + 1] & 0xff) | ((GlyphIndices[(sourceIndex + num11) + 2] & 0xff) << 8));
                                x     += num16;
                                num11 += 2;
                            }
                        }
                        else if ((Flags & 4) != 0)
                        {
                            y += num5;
                        }
                        else
                        {
                            x += num5;
                        }
                    }
                    if (glyph != null)
                    {
                        int offset = glyph.Offset;
                        drawGlyph(Mixmode, x + ((short)glyph.Offset), y + ((short)glyph.BaseLine), glyph.Width, glyph.Height, glyph.FontData, color, fgcolor);
                        if ((Flags & 0x20) != 0)
                        {
                            x += glyph.Width;
                        }
                    }
                    num11++;
                }
            }
            finally
            {
                Options.Exit();
            }
        }