pub fn render(image: &DynamicImage, view: &View) -> Result<String>Expand description
Renders a portion of an image to an ANSI string using half-block characters.
This function maps the source image pixels to terminal cells based on the provided View. It calculates the average color for the top and bottom half of each character cell to determine the foreground and background colors.
§Arguments
image- The source DynamicImage to render.view- The View configuration defining the source region and target dimensions.
§Errors
Returns an error if writing to the output string fails (though this is unlikely with String).
§Examples
use hdim_render::{render, View};
use image::DynamicImage;
let img = DynamicImage::new_rgba8(100, 100);
let view = View {
source_x: 0,
source_y: 0,
source_width: 100,
source_height: 100,
target_width: 50,
target_height: 25,
};
let output = render(&img, &view).unwrap();
println!("{}", output);