Skip to main content
RDP supports multiple bitmap compression codecs to optimize graphics performance over varying network conditions. IronRDP implements the most widely-used codecs, prioritizing security and correctness.

Supported Codecs

IronRDP supports four primary bitmap codecs: From README.md:13-18.

Codec Negotiation

Codecs are negotiated during capabilities exchange via the Bitmap Capability Set.

Client Advertisement

The client specifies:
  • Preferred color depth: 15, 16, 24, or 32 bits per pixel
  • Supported codecs: List of codec GUIDs and capabilities
  • Lossy compression: Whether lossy codecs are acceptable

Server Response

Server selects codecs from client’s advertised list and includes them in the Demand Active PDU.
See ironrdp-pdu/src/rdp/capability_sets/bitmap.rs.

Uncompressed Bitmaps

Raw bitmap data sent without compression.

Format

  • Pixel Format: RGB triplets or RGBX quadruplets
  • Byte Order: Platform-dependent (typically little-endian)
  • Scanline Order: Bottom-to-top (standard bitmap orientation)

Use Cases

  • Very simple images where compression overhead exceeds benefit
  • Regions smaller than ~100 pixels
  • Already-compressed image data (e.g., screenshots of compressed content)

Processing

No decompression needed — directly blit to framebuffer:

RLE (Run-Length Encoding)

Interleaved RLE provides lossless compression for bitmap data.

Algorithm

RLE encodes consecutive identical pixels using run-length codes:
  • Literal runs: Verbatim pixel data (1-255 pixels)
  • Repeat runs: Single color repeated N times
  • Special codes: Background color, foreground color, mixed runs

Code Structure

See ironrdp-graphics/src/rle.rs for full implementation.

Decompression

The decompressor maintains:
  • Foreground color: Current pen color
  • Background color: Current background color
  • Output buffer: Reconstructed bitmap

Performance

RLE excels at:
  • Text and UI elements (large solid color regions)
  • Simple graphics with few color transitions
  • Low-color-depth images
RLE struggles with:
  • Photographs and gradients
  • High-frequency color changes
  • Noisy or dithered images

RDP 6.0 Bitmap Compression

RDP 6.0 introduces an improved lossless codec.

Implementation

Implemented in ironrdp-graphics/src/rdp6/:

Decoder

See ironrdp-graphics/src/rdp6/bitmap_stream/decoder.rs.

Encoder

IronRDP also provides an encoder for server-side implementations:
See ironrdp-graphics/src/rdp6/bitmap_stream/encoder.rs.

Algorithm Details

RDP 6.0 codec uses:
  • Delta encoding: Encodes differences from previous scanline
  • Color caching: Reuses frequently-occurring colors
  • Advanced RLE: Extended run-length codes

Use Cases

  • General-purpose lossless compression
  • Better than classic RLE for complex images
  • Still efficient for text and UI

RemoteFX (RFX)

RemoteFX is RDP’s advanced codec using wavelet-based compression.

Architecture

RemoteFX processing pipeline:

Complete RFX Encoding

See ironrdp-graphics/src/lib.rs:23-37.

RFX Tile Structure

RemoteFX divides the screen into 64×64 pixel tiles. Each tile is encoded independently:
See ironrdp-pdu/src/codecs/rfx/ for PDU structures.

Quantization Factors

Quantization quality is controlled by the Quant structure:
Higher values = more quantization = lower quality + better compression. Typical values:
  • Lossless: All factors = 6
  • High quality: 6-8 range
  • Medium quality: 8-10 range
  • Low quality: 10-12 range

Entropy Algorithms

RLGR3 provides better compression and is recommended.

Use Cases

RemoteFX excels at:
  • High-resolution displays: 1920×1080 and above
  • Complex graphics: Photographs, video frames
  • Acceptable quality loss: Slight artifacts OK for performance
  • Hardware acceleration: GPU-accelerated encoding/decoding
RemoteFX limitations:
  • Requires RDP 7.0+ (Windows 7/Server 2008 R2 or later)
  • Higher CPU cost than RLE
  • Lossy compression (though minimal at high quality settings)

Enabling RemoteFX on Server

Windows Server configuration:
Or via Group Policy (gpedit.msc):
  1. Computer Configuration → Administrative Templates → Windows Components → Remote Desktop Services → Remote Desktop Session Host → Remote Session Environment
  2. Enable “RemoteFX for Windows Server 2008 R2”
  3. Enable “Enable RemoteFX encoding for RemoteFX clients”
  4. Enable “Limit maximum color depth” → Set to 32-bit
  5. Reboot
See README.md:46-65.

Additional Graphics Utilities

Image Processing

Utilities for bitmap manipulation:
See ironrdp-graphics/src/image_processing.rs.

Rectangle Processing

Optimizations for rectangular bitmap operations:
See ironrdp-graphics/src/rectangle_processing.rs.

Pointer (Cursor) Handling

See ironrdp-graphics/src/pointer.rs.

Differential Encoding

See ironrdp-graphics/src/diff.rs.

Bulk Compression (ZGFX)

RDP also supports bulk compression of PDU payloads using ZGFX (not a graphics codec).

ZGFX Algorithm

ZGFX is a variant of DEFLATE optimized for RDP:
See ironrdp-graphics/src/zgfx/.

Bulk vs. Bitmap Compression

  • Bulk compression: Compresses entire PDUs (any data type)
  • Bitmap compression: Codec-specific to bitmap data
They are orthogonal — bulk compression can be applied to compressed bitmaps.

Configuration

Bulk compression is negotiated separately:
See Protocol Overview for bulk compression details.

Codec Selection Strategy

Choose codecs based on use case:

Performance Considerations

Optimization Tips:
  • Profile your use case: Measure actual compression ratios and CPU usage
  • Tune quantization: Balance quality vs. bandwidth for RemoteFX
  • Enable hardware acceleration: Use GPU for RFX encoding/decoding when available
  • Monitor network conditions: Dynamically adjust codec quality
  • Leverage caching: RDP supports various caching mechanisms to reduce retransmissions
  • Consider tile size: 64×64 is optimal for most cases, but adjustable

Error Handling

Codec operations return Result types:
Handle errors gracefully:

Testing Codecs

IronRDP includes extensive codec tests:
See crates/ironrdp-graphics/ for test fixtures.

Future Codecs

RDP 10+ introduces new codecs:
  • AVC/H.264: Video codec support
  • HEVC/H.265: Next-gen video compression
  • AV1: Modern, royalty-free codec
These are planned for future IronRDP releases.

References

  • Graphics Crate: crates/ironrdp-graphics/
  • RFX PDU Structures: crates/ironrdp-pdu/src/codecs/rfx/
  • Bitmap Capability Sets: crates/ironrdp-pdu/src/rdp/capability_sets/bitmap.rs
  • MS-RDPRFX: RemoteFX Codec specification
  • MS-RDPEGDI: Graphics Device Interface extension
  • MS-RDPBCGR § 3.1.9: Bitmap compression algorithms