bwm 0.1.0

Image watermarking over borrowed RGB/RGBA buffers
Documentation
use bwm::{
    embed_text, extract_text, ImageBufferRef, PixelFormat, WatermarkConfig, WatermarkKey,
    WatermarkStrength,
};

fn main() -> Result<(), bwm::WatermarkError> {
    let width = 384usize;
    let height = 384usize;
    let stride = width * 3;
    let mut image = vec![0u8; stride * height];

    for y in 0..height {
        for x in 0..width {
            let offset = (y * stride) + x * 3;
            image[offset] = (48 + ((x * 5 + y * 3) % 150)) as u8;
            image[offset + 1] = (58 + ((x * 2 + y * 7) % 145)) as u8;
            image[offset + 2] = (68 + ((x * 11 + y * 13) % 135)) as u8;
        }
    }

    let mut config = WatermarkConfig::new(WatermarkKey::from_bytes([7u8; 32]));
    config.strength = WatermarkStrength::High;

    let input = ImageBufferRef::new(
        &image,
        width as u32,
        height as u32,
        stride,
        PixelFormat::Rgb8,
    );
    let watermarked = embed_text(input, "hello watermark", &config)?;
    let recovered = extract_text(watermarked.as_ref(), &config)?;

    println!("{recovered}");
    Ok(())
}