| Crates.io | rfb-encodings |
| lib.rs | rfb-encodings |
| version | 0.1.6 |
| created_at | 2025-10-23 21:56:46.886708+00 |
| updated_at | 2025-12-18 02:48:58.432963+00 |
| description | RFB (Remote Framebuffer) protocol encoding implementations for VNC |
| homepage | |
| repository | https://github.com/dustinmcafee/rfb-encodings |
| max_upload_size | |
| id | 1897733 |
| size | 418,580 |
RFB (Remote Framebuffer) protocol encoding implementations for VNC.
Support this project:
Bitcoin (BTC)
3QVD3H1ryqyxhuf8hNTTuBXSbczNuAKaM8
Ethereum (ETH)
0xaFE28A1Dd57660610Ef46C05EfAA363356e98DC7
Solana (SOL)
6uWx4wuHERBpNxyWjeQKrMLBVte91aBzkHaJb8rhw4rn
Monero (XMR)
8C5aCs7Api3WE67GMw54AhQKnJsCg6CVffCuPxUcaKoiMrnaicyvDch8M2CXTm1DJqhpHKxtLvum9Thw4yHn8zeu7sj8qmC
This crate provides encoding implementations for the VNC/RFB protocol, including all standard encodings defined in RFC 6143. It can be used to build VNC servers, clients, proxies, or recorders.
| Encoding | ID | Description | Wire Format Match | Testing Status |
|---|---|---|---|---|
| Raw | 0 | Uncompressed pixels | ✅ 100% | ✅ Golden + Round-trip |
| RRE | 2 | Rise-and-Run-length | ✅ 100% | ✅ Smoke |
| CoRRE | 4 | Compact RRE | ✅ 100% | ✅ Smoke |
| Hextile | 5 | 16x16 tile-based | ✅ 100% | ✅ Smoke |
| Zlib | 6 | Zlib-compressed raw | ✅ 100% | ✅ Golden + Round-trip |
| Tight | 7 | Multi-mode compression | ✅ 100% (all 5 modes) | ✅ Golden |
| ZlibHex | 8 | Zlib-compressed Hextile | ✅ 100% | ✅ Smoke |
| ZRLE | 16 | Zlib Run-Length | ✅ 100% | ✅ Golden + Round-trip |
| ZYWRLE | 17 | Wavelet compression | ✅ 100% | ✅ Smoke |
| TightPng | -260 | PNG-compressed Tight | ✅ 100% | ✅ Golden |
All 10 encodings have automated tests. See Testing for details.
Add this to your Cargo.toml:
[dependencies]
rfb-encodings = "0.1"
use rfb_encodings::{Encoding, TightEncoding, PixelFormat};
// Create encoder
let encoder = TightEncoding;
// Encode RGBA pixel data
let rgba_data: Vec<u8> = vec![/* your pixel data */];
let width = 1920;
let height = 1080;
let quality = 9; // 0-9, higher is better quality
let compression = 6; // 0-9, higher is more compression
let encoded = encoder.encode(&rgba_data, width, height, quality, compression);
For better compression with Tight encoding:
use rfb_encodings::{
encode_tight_rects, SimpleTightCompressor, PixelFormat
};
let mut compressor = SimpleTightCompressor::new(6);
let client_format = PixelFormat::rgba32();
let rectangles = encode_tight_rects(
&rgba_data,
width,
height,
9, // quality
6, // compression
&client_format,
&mut compressor
);
// Returns Vec<(x, y, width, height, encoded_data)>
for (x, y, w, h, data) in rectangles {
// Send rectangle to VNC client
}
turbojpeg - Enable TurboJPEG for hardware-accelerated JPEG compression in Tight encodingdebug-logging - Enable verbose debug logging for troubleshootingEnable features in your Cargo.toml:
[dependencies]
rfb-encodings = { version = "0.1", features = ["turbojpeg", "debug-logging"] }
The turbojpeg feature requires libjpeg-turbo to be installed on your system:
Ubuntu/Debian:
sudo apt-get install libturbojpeg0-dev
macOS:
brew install jpeg-turbo
Windows: Download from libjpeg-turbo.org
This crate is designed to be reusable across different VNC implementations:
encoding modules - Individual encoder implementationsPixelFormat - VNC pixel format definition and utilitiestranslate - Pixel format translation between different color depthsTightStreamCompressor trait - Interface for persistent zlib streamsWhen using the turbojpeg feature, this crate provides FFI bindings to libjpeg-turbo, which must be installed separately on your system. libjpeg-turbo is licensed under a BSD-style license (BSD-3-Clause, IJG, and zlib components).
License Information:
turbojpeg feature.This crate is licensed under the Apache License, Version 2.0. See LICENSE for details.
The turbojpeg feature provides optional bindings to libjpeg-turbo, which is licensed separately. See above for details.
This crate includes comprehensive tests for all 10 encodings:
# First: generate test fixtures (required once)
# Creates deterministic RGBA test images in tests/fixtures/
# - frame_64x64.rgba: 4-quadrant pattern (gradient, solid, checkerboard)
# - frame_100x75.rgba: non-64-aligned image to test ZRLE bug fix
cargo run --bin generate_fixture
# Then: generate golden files for your platform (required once per OS)
# Encodes fixtures and saves output to tests/expected/{linux,macos,windows}/
cargo test --test golden_tests --features generate-golden
# Run all tests
cargo test
| Test Type | Description |
|---|---|
| Golden | Compares encoder output against generated reference files |
| Round-trip | Encodes data, decodes with test decoders, verifies RGB match |
| Smoke | Verifies encoding runs without error and produces output |
--features generate-golden on each platform to create tests/expected/{linux,macos,windows}/Contributions are welcome! Please see CONTRIBUTING.md for guidelines.