The TS_FP_UPDATE_BITMAP structure is the fast-path variant of the TS_UPDATE_BITMAP_PDU_DATA structure.
file:///C:/ts_dev/TestSuites/MS-RDPBCGR/TestSuite/Src/TD/latest_XMLS_16may/RDPBCGR/ _rfc_ms-rdpbcgr2_1_8_1_2_1_2.xml
Inheritance: TS_FP_UPDATE
        /// <summary>
        /// Parse TS_FP_UPDATE_BITMAP
        /// </summary>
        /// <param name="updateHeader">update header</param>
        /// <param name="compressionFlags">compression flags</param>
        /// <param name="size">update data size(before decompression)</param>
        /// <param name="updateData">update data(decompressed)</param>
        /// <returns>TS_FP_UPDATE_BITMAP</returns>
        private TS_FP_UPDATE_BITMAP ParseTsFpUpdateBitmap(
            byte updateHeader,
            compressedType_Values compressionFlags,
            UInt16 size,
            byte[] updateData)
        {
            TS_FP_UPDATE_BITMAP bitmap = new TS_FP_UPDATE_BITMAP();

            // TS_FP_UPDATE_BITMAP: updateHeader
            bitmap.updateHeader = updateHeader;

            // TS_FP_UPDATE_BITMAP: compressionFlags
            bitmap.compressionFlags = compressionFlags;

            // TS_FP_UPDATE_BITMAP: size
            bitmap.size = size;

            // TS_FP_UPDATE_BITMAP: bitmapUpdateData
            int index = 0;
            bitmap.bitmapUpdateData = ParseTsUpdateBitmapData(updateData, ref index);

            // Check if data length exceeded expectation
            VerifyDataLength(updateData.Length, index, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED);
            return bitmap;
        }
        public static TS_FP_UPDATE_BITMAP CreateFPUpdateBitmap(ushort left, ushort top, ushort width, ushort height)
        {
            TS_FP_UPDATE_BITMAP bitmap = new TS_FP_UPDATE_BITMAP();
            TS_BITMAP_DATA bdata;

            bitmap.updateHeader = (byte)(((int)updateCode_Values.FASTPATH_UPDATETYPE_BITMAP & 0x0f)
                | (((int)fragmentation_Value.FASTPATH_FRAGMENT_SINGLE) << 4)
                | ((int)compressedType_Values.None << 6));
            bitmap.compressionFlags = compressedType_Values.None;
            bitmap.bitmapUpdateData.updateType = (ushort)updateType_Values.UPDATETYPE_BITMAP;
            bitmap.bitmapUpdateData.numberRectangles = 1;
            bitmap.bitmapUpdateData.rectangles = new TS_BITMAP_DATA[1];

            bdata = CreateBitmapData(left, top, width, height);
            bitmap.bitmapUpdateData.rectangles[0] = bdata;

            //calculate the bitmap.size, which is the size of TS_UPDATE_BITMAP_DATA.bitmapUpdateData.
            bitmap.size = (ushort)(22 + bitmap.bitmapUpdateData.rectangles[0].bitmapLength);
            if (bitmap.bitmapUpdateData.rectangles[0].Flags != TS_BITMAP_DATA_Flags_Values.NO_BITMAP_COMPRESSION_HDR)
            {
                bitmap.size += (ushort)Marshal.SizeOf(bitmap.bitmapUpdateData.rectangles[0].bitmapComprHdr);
            }

            return bitmap;
        }
Exemplo n.º 3
0
        private byte[] EncodeBitmap(TS_FP_UPDATE_BITMAP bitmapData)
        {
            List<byte> totalBuffer = new List<byte>();
            List<byte> buffer = new List<byte>();

            RdpbcgrEncoder.EncodeStructure(buffer, (ushort)bitmapData.bitmapUpdateData.updateType);
            RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapUpdateData.numberRectangles);
            if (bitmapData.bitmapUpdateData.rectangles != null)
            {
                for (int i = 0; i < bitmapData.bitmapUpdateData.rectangles.Length; ++i)
                {
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapUpdateData.rectangles[i].destLeft);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapUpdateData.rectangles[i].destTop);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapUpdateData.rectangles[i].destRight);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapUpdateData.rectangles[i].destBottom);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapUpdateData.rectangles[i].width);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapUpdateData.rectangles[i].height);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapUpdateData.rectangles[i].bitsPerPixel);
                    RdpbcgrEncoder.EncodeStructure(buffer, (ushort)bitmapData.bitmapUpdateData.rectangles[i].Flags);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapUpdateData.rectangles[i].bitmapLength);
                    if ((bitmapData.bitmapUpdateData.rectangles[i].Flags & TS_BITMAP_DATA_Flags_Values.NO_BITMAP_COMPRESSION_HDR)
                        == TS_BITMAP_DATA_Flags_Values.None)
                    {
                        RdpbcgrEncoder.EncodeStructure(
                            buffer, (ushort)bitmapData.bitmapUpdateData.rectangles[i].bitmapComprHdr.cbCompFirstRowSize);
                        RdpbcgrEncoder.EncodeStructure(
                            buffer, bitmapData.bitmapUpdateData.rectangles[i].bitmapComprHdr.cbCompMainBodySize);
                        RdpbcgrEncoder.EncodeStructure(
                            buffer, bitmapData.bitmapUpdateData.rectangles[i].bitmapComprHdr.cbScanWidth);
                        RdpbcgrEncoder.EncodeStructure(
                            buffer, bitmapData.bitmapUpdateData.rectangles[i].bitmapComprHdr.cbUncompressedSize);
                    }
                    if (bitmapData.bitmapUpdateData.rectangles[i].bitmapDataStream != null)
                    {
                        if ((bitmapData.bitmapUpdateData.rectangles[i].Flags & TS_BITMAP_DATA_Flags_Values.BITMAP_COMPRESSION)
                            == TS_BITMAP_DATA_Flags_Values.BITMAP_COMPRESSION)
                        {
                            byte[] temp = serverSessionContext.Compress(bitmapData.compressionFlags, bitmapData.bitmapUpdateData.rectangles[i].bitmapDataStream);
                            bitmapData.bitmapUpdateData.rectangles[i].bitmapDataStream = temp;
                            RdpbcgrEncoder.EncodeBytes(buffer, bitmapData.bitmapUpdateData.rectangles[i].bitmapDataStream);
                        }
                        else
                        {
                            RdpbcgrEncoder.EncodeBytes(buffer, bitmapData.bitmapUpdateData.rectangles[i].bitmapDataStream);
                        }
                    }
                }
            }

            if (bitmapData.compressionFlags != compressedType_Values.None)
            {
                RdpbcgrEncoder.EncodeBytes(
                    totalBuffer, serverSessionContext.Compress(bitmapData.compressionFlags, buffer.ToArray()));
            }
            else
            {
                RdpbcgrEncoder.EncodeBytes(totalBuffer, buffer.ToArray());
            }

            return totalBuffer.ToArray();
        }
        public static TS_FP_UPDATE_BITMAP CreateFPUpdateBitmap(TS_BITMAP_DATA data)
        {
            TS_FP_UPDATE_BITMAP bitmap = new TS_FP_UPDATE_BITMAP();

            bitmap.updateHeader = (byte)(((int)updateCode_Values.FASTPATH_UPDATETYPE_BITMAP & 0x0f)
                | (((int)fragmentation_Value.FASTPATH_FRAGMENT_SINGLE) << 4)
                | ((int)compressedType_Values.None << 6));
            bitmap.compressionFlags = compressedType_Values.None;
            bitmap.bitmapUpdateData.updateType = (ushort)updateType_Values.UPDATETYPE_BITMAP;
            bitmap.bitmapUpdateData.numberRectangles = 1;
            bitmap.bitmapUpdateData.rectangles = new TS_BITMAP_DATA[1];
            bitmap.bitmapUpdateData.rectangles[0] = data;

            bitmap.size = (ushort)(22 + bitmap.bitmapUpdateData.rectangles[0].bitmapLength);
            if (bitmap.bitmapUpdateData.rectangles[0].Flags != TS_BITMAP_DATA_Flags_Values.NO_BITMAP_COMPRESSION_HDR)
            {
                bitmap.size += (ushort)Marshal.SizeOf(bitmap.bitmapUpdateData.rectangles[0].bitmapComprHdr);
            }

            return bitmap;
        }