Skip to main content

Crate blurhash_core

Crate blurhash_core 

Source
Expand description

§blurhash-core

Fast BlurHash encoding and decoding in pure Rust.

BlurHash is a compact representation of a placeholder for an image. This crate provides high-performance encoding and decoding with precomputed lookup tables and cache-friendly memory access patterns.

§Quick Start

use blurhash_core::{encode, decode};

// Encode: image pixels -> BlurHash string
let pixels = vec![128u8; 4 * 4 * 3]; // 4x4 gray image
let hash = encode(&pixels, 4, 4, 4, 3).unwrap();

// Decode: BlurHash string -> image pixels
let decoded = decode(&hash, 32, 32, 1.0).unwrap();
assert_eq!(decoded.len(), 32 * 32 * 3);

Re-exports§

pub use color::linear_to_srgb;
pub use color::linear_to_srgb_f32;
pub use color::sign_pow;
pub use color::sign_pow_f32;
pub use color::srgb_to_linear;
pub use color::srgb_to_linear_f32;
pub use error::BlurhashError;

Modules§

base83
Base83 encoding and decoding used by the BlurHash algorithm.
color
Color space conversion utilities for sRGB and linear RGB.
error
Error types for BlurHash encoding and decoding.

Functions§

components
Extract the number of X and Y components from a BlurHash string.
decode
Decode a BlurHash string into a flat RGB byte array.
encode
Encode an RGB image into a BlurHash string.