Partager via


2.2.2.2.1.2.7 Cache Brush (CACHE_BRUSH_ORDER)

The Cache Brush Secondary Drawing Order is used by the server to instruct the client to store a brush in a particular Brush Cache entry. Support for brush caching is specified in the Brush Cache Capability Set (see [MS-RDPBCGR] section 2.2.7.1.7).


0


1


2


3


4


5


6


7


8


9

1
0


1


2


3


4


5


6


7


8


9

2
0


1


2


3


4


5


6


7


8


9

3
0


1

header

...

cacheEntry

iBitmapFormat

cx

cy

Style

iBytes

brushData (variable)

...

header (6 bytes): Secondary Order Header, as defined in section 2.2.2.2.1.2.1.1. The embedded orderType field MUST be set to TS_CACHE_BRUSH (0x07).

cacheEntry (1 byte): An 8-bit, unsigned integer. The entry in a specified Brush Cache where the brush data MUST be stored. This value MUST be in the range 0 to 63 (inclusive).

iBitmapFormat (1 byte): An 8-bit, unsigned integer. The color depth of the brush bitmap data. This field MUST be one of the following values.

Value

Meaning

BMF_1BPP

0x01

1 bit per pixel

BMF_8BPP

0x03

8 bits per pixel

BMF_16BPP

0x04

15 or 16 bits per pixel

BMF_24BPP

0x05

24 bits per pixel

BMF_32BPP

0x06

32 bits per pixel

cx (1 byte): An 8-bit, unsigned integer. The width of the brush bitmap.

cy (1 byte): An 8-bit, unsigned integer. The height of the brush bitmap.

Style (1 byte): An 8-bit, unsigned integer. This field is not used, and SHOULD<4> be set to 0x00.

iBytes (1 byte): An 8-bit, unsigned integer. The size of the brushData field in bytes.

brushData (variable): A variable-sized byte array containing binary brush data that represents an 8-by-8-pixel bitmap image. There are 64 pixels in a brush bitmap, and the space used to represent each pixel depends on the color depth of the brush bitmap and the number of colors used. The size of the brushData field in bytes is given by the iBytes field.

In general, most brushes only use two colors (mono format), and the majority of the remaining ones use four colors or fewer.

For mono format brushes (iBitmapFormat is BMF_1BPP), brushData contains 8 bytes of 1-bit-per-pixel data, each byte corresponding to a row of pixels in the brush. The rows are encoded in reverse order; that is, the pixels in the bottom row of the brush are encoded in the first byte of the brushData field, and the pixels in the top row are encoded in the eighth byte.

For color brushes, a compression algorithm is used. If the data is compressed, the iBytes field is 20 for 256-color (iBitmapFormat is BMF_8BPP), 24 for 16-bit color (iBitmapFormat is BMF_16BPP), 28 for 24-bit color (iBitmapFormat is BMF_24BPP), and 32 for 32-bit color (iBitmapFormat is BMF_32BPP). The compression algorithm reduces brush data size by storing each brush pixel as a 2-bit index (four possible values) into a translation table containing four entries. This equates to 2 bytes per brush bitmap line (16 bytes in total) followed by the translation table contents. This layout for four-color brushes conforms to the Compressed Color Brush (section 2.2.2.2.1.2.7.1) structure.

For brushes using more than four colors, the data is simply copied uncompressed into the brushData at the appropriate color depth.