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
- 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.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
ironrdp-graphics/src/rle.rs for full implementation.
Decompression
- 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
- 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 inironrdp-graphics/src/rdp6/:
Decoder
ironrdp-graphics/src/rdp6/bitmap_stream/decoder.rs.
Encoder
IronRDP also provides an encoder for server-side implementations: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
ironrdp-graphics/src/lib.rs:23-37.
RFX Tile Structure
RemoteFX divides the screen into 64×64 pixel tiles. Each tile is encoded independently:ironrdp-pdu/src/codecs/rfx/ for PDU structures.
Quantization Factors
Quantization quality is controlled by theQuant structure:
- Lossless: All factors = 6
- High quality: 6-8 range
- Medium quality: 8-10 range
- Low quality: 10-12 range
Entropy Algorithms
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
- 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:- Computer Configuration → Administrative Templates → Windows Components → Remote Desktop Services → Remote Desktop Session Host → Remote Session Environment
- Enable “RemoteFX for Windows Server 2008 R2”
- Enable “Enable RemoteFX encoding for RemoteFX clients”
- Enable “Limit maximum color depth” → Set to 32-bit
- Reboot
README.md:46-65.
Additional Graphics Utilities
Image Processing
Utilities for bitmap manipulation:ironrdp-graphics/src/image_processing.rs.
Rectangle Processing
Optimizations for rectangular bitmap operations:ironrdp-graphics/src/rectangle_processing.rs.
Pointer (Cursor) Handling
ironrdp-graphics/src/pointer.rs.
Differential Encoding
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:ironrdp-graphics/src/zgfx/.
Bulk vs. Bitmap Compression
- Bulk compression: Compresses entire PDUs (any data type)
- Bitmap compression: Codec-specific to bitmap data
Configuration
Bulk compression is negotiated separately: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 returnResult types:
Testing Codecs
IronRDP includes extensive codec tests: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
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

