2.2.2 NSCodec Compressed Bitmap Stream (NSCODEC_BITMAP_STREAM)

The NSCODEC_BITMAP_STREAM structure contains a stream of bitmap data compressed using NSCodec bitmap compression techniques (section 3.1.8). The bitmap data is represented using the AYCoCg color space ([MS-RDPEGDI] section 3.1.9.1.2).

NSCodec compressed bitmap data is sent encapsulated in a Set Surface Bits Surface Command ([MS-RDPBCGR] section 2.2.9.2.1) when sending a bitmap image that MUST NOT be cached, or in the Cache Bitmap - Revision 3 ([MS-RDPEGDI] section 2.2.2.2.1.2.8) Secondary Drawing Order when sending a bitmap image that MUST be cached (bitmap caching is discussed in [MS-RDPEGDI] section 3.1.1.1.1). In all these cases, the data is encapsulated inside an Extended Bitmap Data ([MS-RDPBCGR] section 2.2.9.2.1.1) structure.

The width and height of the compressed bitmap are obtained from the width and height fields of the encapsulating Extended Bitmap Data structure.


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

LumaPlaneByteCount

OrangeChromaPlaneByteCount

GreenChromaPlaneByteCount

AlphaPlaneByteCount

ColorLossLevel

ChromaSubsamplingLevel

Reserved

LumaPlane (variable)

...

OrangeChromaPlane (variable)

...

GreenChromaPlane (variable)

...

AlphaPlane (variable)

...

LumaPlaneByteCount (4 bytes): A 32-bit, unsigned integer that contains the number of bytes used by the LumaPlane field. This value MUST be greater than zero.

OrangeChromaPlaneByteCount (4 bytes): A 32-bit, unsigned integer that contains the number of bytes used by the OrangeChromaPlane field. This value MUST be greater than zero.

GreenChromaPlaneByteCount (4 bytes): A 32-bit, unsigned integer that contains the number of bytes used by the GreenChromaPlane field. This value MUST be greater than zero.

AlphaPlaneByteCount (4 bytes): A 32-bit, unsigned integer that contains the number of bytes used by the AlphaPlane field.

ColorLossLevel (1 byte): An 8-bit, unsigned integer that indicates the Color Loss Level ([MS-RDPEGDI] section 3.1.9.1.4) that was applied to the chroma values of this packet. This value MUST be in the range 1 to 7 (inclusive).

ChromaSubsamplingLevel (1 byte): An 8-bit, unsigned integer that indicates whether chroma subsampling is being used ([MS-RDPEGDI] section 3.1.9.1.3).

Value

Meaning

FALSE

0x00

Chroma subsampling is not being used.

TRUE

0x01

Chroma subsampling is being used.

Reserved (2 bytes): A 16-bit field. Reserved for future use.

LumaPlane (variable): A variable-length array of bytes that contains the luma plane data.

The LumaPlaneByteCount field is used to determine whether the data is in raw format, or if it has been RLE (2) compressed. If LumaPlaneByteCount is equal to the expected raw size of the luma plane, the data is in raw format. If LumaPlaneByteCount is smaller than the expected size, the data has been RLE compressed. LumaPlaneByteCount MUST NOT be larger than the expected size of the luma plane.

If chroma subsampling is not being used, the expected raw size of the luma plane is calculated as follows (input to the calculation is the raw image width and height).

 LumaPlaneWidth = ImageWidth
 LumaPlaneHeight = ImageHeight
 LumaPlaneByteCount = ImageWidth * ImageHeight

If chroma subsampling is being used, the expected raw size of the luma plane is calculated as follows.

 LumaPlaneWidth = ROUND_UP_TO_NEAREST_MULTIPLE_OF_8(ImageWidth)
 LumaPlaneHeight = ImageHeight
 LumaPlaneByteCount = LumaPlaneWidth * ImageHeight

If the luma channel has been RLE compressed, this field contains an NSCodec RLE Segments (section 2.2.2.1) structure. Otherwise, it contains the raw bytes of the color plane.

OrangeChromaPlane (variable): A variable-length array of bytes that contains the orange chroma plane.

The OrangeChromaPlaneByteCount field is used to determine whether the data is in raw format or has been RLE compressed. If OrangeChromaPlaneByteCount is equal to the expected raw size of the chroma plane, the data is in raw format. If OrangeChromaPlaneByteCount is smaller than the expected size, the data has been RLE compressed. OrangeChromaPlaneByteCount MUST NOT be larger than the expected size of the chroma plane.

If chroma subsampling is not being used, the expected raw size of the orange chroma plane is calculated as follows (input to the calculation is the raw image width and height).

 ChromaPlaneWidth = ImageWidth
 ChromaPlaneHeight = ImageHeight
 ChromaPlaneByteCount = ImageWidth * ImageHeight

If chroma subsampling is being used, the expected raw size of the orange chroma plane is calculated as follows.

 ChromaPlaneWidth = ROUND_UP_TO_NEAREST_MULTIPLE_OF_8(ImageWidth) / 2
 ChromaPlaneHeight = ROUND_UP_TO_NEAREST_MULTIPLE_OF_2(ImageHeight) / 2
 ChromaPlaneByteCount = ChromaPlaneWidth * ChromaPlaneHeight

If the orange chroma channel has been RLE compressed, this field contains an NSCodec RLE Segments (section 2.2.2.1) structure. Otherwise, it contains the raw bytes of the color plane.

Depending on the values of the ColorLossLevel and ChromaSubsamplingLevel fields, the orange chroma plane can be transformed by color loss reduction ([MS-RDPEGDI] section 3.1.9.1.4) and chroma subsampling ([MS-RDPEGDI] section 3.1.9.1.3).

GreenChromaPlane (variable): A variable-length array of bytes that contains the green chroma plane.

The GreenChromaPlaneByteCount field is used to determine whether the data is in raw format or has been RLE compressed. If GreenChromaPlaneByteCount is equal to the expected raw size of the chroma plane, the data is in raw format. If GreenChromaPlaneByteCount is smaller than the expected size, the data has been RLE compressed. GreenChromaPlaneByteCount MUST NOT be larger than the expected size of the chroma plane.

If chroma subsampling is not being used, the expected raw size of the green chroma plane is calculated as follows (input to the calculation is the raw image width and height).

 ChromaPlaneWidth = ImageWidth
 ChromaPlaneHeight = ImageHeight
 ChromaPlaneByteCount = ImageWidth * ImageHeight

If chroma subsampling is being used, the expected raw size of the green chroma plane is calculated as follows.

 ChromaPlaneWidth = ROUND_UP_TO_NEAREST_MULTIPLE_OF_8(ImageWidth) / 2
 ChromaPlaneHeight = ROUND_UP_TO_NEAREST_MULTIPLE_OF_2(ImageHeight) / 2
 ChromaPlaneByteCount = ChromaPlaneWidth * ChromaPlaneHeight

If the green chroma channel has been RLE compressed, this field contains an NSCodec RLE Segments (section 2.2.2.1) structure. Otherwise, it contains the raw bytes of the color plane.

Depending on the values of the ColorLossLevel and ChromaSubsamplingLevel fields, the green chroma plane can be transformed by color loss reduction ([MS-RDPEGDI] section 3.1.9.1.4) and chroma subsampling ([MS-RDPEGDI] section 3.1.9.1.3).

AlphaPlane (variable): A variable-length array of bytes that contains the alpha plane. This field MUST NOT be present if AlphaPlaneByteCount equals 0.

If the AlphaPlaneByteCount field is greater than zero, it MUST be used to determine whether the AlphaPlane data is in raw format or has been RLE compressed. If AlphaPlaneByteCount is equal to the expected raw size of the Alpha plane, the data is in raw format. If AlphaPlaneByteCount is smaller than the expected size, the data has been RLE compressed. AlphaPlaneByteCount MUST NOT be larger than the expected size of the alpha plane.

The expected raw size of the alpha plane is calculated as follows (input to the calculation is the raw image width and height).

 AlphaPlaneWidth = ImageWidth
 AlphaPlaneHeight = ImageHeight
 AlphaPlaneByteCount = ImageWidth * ImageHeight

If the alpha channel has been RLE compressed, this field contains an NSCodec RLE Segments (section 2.2.2.1) structure. Otherwise, it contains the raw bytes of the color plane.