Exemple #1
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);
                    }
                }
            }
        }
Exemple #2
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++;
                }
            }
        }
Exemple #3
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++;
                }
            }
        }
Exemple #4
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);
                    }
                }
            }
        }