Exemple #1
0
        private static void processFontCache(RdpPacket data, int extraFlags)
        {
            int font      = 0;
            int num2      = 0;
            int character = 0;
            int offset    = 0;
            int baseline  = 0;
            int width     = 0;
            int height    = 0;
            int count     = 0;

            byte[] buffer = null;
            int    num9   = (extraFlags >> 4) & 15;

            if ((num9 & 2) != 0)
            {
                font = extraFlags & 15;
                num2 = extraFlags >> 8;
            }
            else
            {
                font = data.ReadByte();
                num2 = data.ReadByte();
            }

            for (int i = 0; i < num2; i++)
            {
                if ((num9 & 2) != 0)
                {
                    character = data.ReadByte();
                    offset    = data.ReadEncodedSigned16();
                    baseline  = data.ReadEncodedSigned16();
                    width     = data.ReadEncodedUnsigned16();
                    height    = data.ReadEncodedUnsigned16();
                }
                else
                {
                    character = data.ReadLittleEndian16();
                    offset    = data.ReadLittleEndian16();
                    baseline  = data.ReadLittleEndian16();
                    width     = data.ReadLittleEndian16();
                    height    = data.ReadLittleEndian16();
                }

                count  = ((height * ((width + 7) / 8)) + 3) & -4;
                buffer = new byte[count];
                data.Read(buffer, 0, count);
                Glyph glyph = new Glyph(font, character, offset, baseline, width, height, buffer);
                Cache.putFont(glyph);
            }
        }
Exemple #2
0
        private static void process_bmpcache3(RdpPacket data, int flags)
        {
            ulong num3 = 0L;
            int   num  = flags & 7;

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

            int num2 = data.ReadEncodedUnsigned16();

            byte[] buffer = new byte[8];
            data.Read(buffer, 0, buffer.Length);
            num3 = BitConverter.ToUInt64(buffer, 0);
            process_bmpdata(data, flags, num, num2, num3);
        }
Exemple #3
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++;
                }
            }
        }