The TS_UPDATE_BITMAP_PDU_DATA structure contains one or more rectangular clippings taken from the server-side screen frame buffer (see [T128] section 8.17).
file:///C:/ts_dev/TestSuites/MS-RDPBCGR/TestSuite/Src/TD/latest_XMLS_16may/RDPBCGR/ _rfc_ms-rdpbcgr2_1_8_1_1_3_1_2.xml
Inheritance: RdpbcgrSlowPathUpdatePdu
        /// <summary>
        /// Parse TS_UPDATE_BITMAP
        /// </summary>
        /// <param name="updateData">update data (decompressed if were compressed)</param>
        /// <param name="shareDataHeader">share data header</param>
        /// <returns>TS_UPDATE_BITMAP</returns>
        private TS_UPDATE_BITMAP ParseTsUpdateBitmapPduData(
            byte[] updateData,
            TS_SHAREDATAHEADER shareDataHeader)
        {
            // index of update data
            int index = 0;
            TS_UPDATE_BITMAP pduData = new TS_UPDATE_BITMAP();

            // TS_UPDATE_BITMAP: shareDataHeader
            pduData.shareDataHeader = shareDataHeader;

            // TS_UPDATE_BITMAP: bitmapData
            pduData.bitmapData = ParseTsUpdateBitmapData(updateData, ref index);

            // Check if data length exceeded expectation
            VerifyDataLength(updateData.Length, index, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED);
            return pduData;
        }
        private byte[] EncodeBitmap(TS_UPDATE_BITMAP bitmapData)
        {
            List<byte> totalBuffer = new List<byte>();

            RdpbcgrEncoder.EncodeStructure(totalBuffer, bitmapData.shareDataHeader);

            List<byte> buffer = new List<byte>();

            RdpbcgrEncoder.EncodeStructure(buffer, (ushort)bitmapData.bitmapData.updateType);
            RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapData.numberRectangles);
            if (bitmapData.bitmapData.rectangles != null)
            {
                for (int i = 0; i < bitmapData.bitmapData.rectangles.Length; ++i)
                {
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapData.rectangles[i].destLeft);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapData.rectangles[i].destTop);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapData.rectangles[i].destRight);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapData.rectangles[i].destBottom);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapData.rectangles[i].width);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapData.rectangles[i].height);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapData.rectangles[i].bitsPerPixel);
                    RdpbcgrEncoder.EncodeStructure(buffer, (short)bitmapData.bitmapData.rectangles[i].Flags);
                    RdpbcgrEncoder.EncodeStructure(buffer, bitmapData.bitmapData.rectangles[i].bitmapLength);
                    RdpbcgrEncoder.EncodeStructure(
                        buffer, (short)bitmapData.bitmapData.rectangles[i].bitmapComprHdr.cbCompFirstRowSize);
                    RdpbcgrEncoder.EncodeStructure(
                        buffer, bitmapData.bitmapData.rectangles[i].bitmapComprHdr.cbCompMainBodySize);
                    RdpbcgrEncoder.EncodeStructure(
                        buffer, bitmapData.bitmapData.rectangles[i].bitmapComprHdr.cbScanWidth);
                    RdpbcgrEncoder.EncodeStructure(
                        buffer, bitmapData.bitmapData.rectangles[i].bitmapComprHdr.cbUncompressedSize);
                    RdpbcgrEncoder.EncodeBytes(buffer, bitmapData.bitmapData.rectangles[i].bitmapDataStream);
                }
            }

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