wtrenderlib 0.1.0

Dependency-free terminal rendering primitives for RGB and RGBA frames
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use crate::{OwnedFrame, PixelFormat, Result};

pub fn decode(path: impl AsRef<std::path::Path>) -> Result<OwnedFrame> {
    let image = image::ImageReader::open(path)
        .map_err(|error| crate::Error::Unsupported(error.to_string()))?
        .decode()
        .map_err(|error| crate::Error::Unsupported(error.to_string()))?
        .to_rgba8();
    let width = image.width() as usize;
    let height = image.height() as usize;
    OwnedFrame::new(image.into_raw(), width, height, PixelFormat::Rgba8)
}