notcurses/rust/examples/direct-image-rust.rs
joseLuís eaee89c99f [rust] renamed FullMode & DirectMode to Nc & NcD
- improve pixel-cell example.
- rustfmt
2021-04-17 22:13:43 +02:00

29 lines
744 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 = NcD::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 NcD, 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(())
}