コード例 #1
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++;
                }
            }
        }