notcurses/rust/examples/direct-image-rust.rs
joseLuís 129e208438 [rust] refactor Notcurses & NcDirect wrapping approach
- remove `Nc` & `NcD` wrappers, to move them to notcurses-rs library.
- update the summary header format for Notcurses and NcDirect
- update docs and examples
2021-05-05 19:33:00 +02:00

29 lines
754 B
Rust

//! Example 'direct-image'
//!
//! Explore image rendering in direct mode
//!
//! NOTE: This example uses the Rust style with methods.
use libnotcurses_sys::*;
fn main() -> NcResult<()> {
let mut dm = NcDirect::new()?;
render_image(&mut dm, NCBLIT_1x1)?;
render_image(&mut dm, NCBLIT_2x1)?;
render_image(&mut dm, NCBLIT_BRAILLE)?;
Ok(())
}
fn render_image(dm: &mut NcDirect, blit: NcBlitter) -> NcResult<()> {
if let Err(nc_error) = dm.render_image("image-16x16.png", NCALIGN_CENTER, blit, NCSCALE_NONE) {
return Err(NcError::with_msg(
nc_error.int,
"ERROR: dmirect_render_image(). Make sure you \
are running this example from the examples folder",
));
}
Ok(())
}