2020-12-25 16:40:37 +00:00
|
|
|
//! Example 'direct-image'
|
|
|
|
//!
|
|
|
|
//! Explore image rendering in direct mode
|
|
|
|
//!
|
|
|
|
//! NOTE: This example uses the Rust style with methods.
|
|
|
|
|
|
|
|
use libnotcurses_sys::*;
|
|
|
|
|
|
|
|
fn main() -> NcResult<()> {
|
2021-05-05 17:33:00 +00:00
|
|
|
let mut dm = NcDirect::new()?;
|
2020-12-25 16:40:37 +00:00
|
|
|
|
2021-01-02 21:50:48 +00:00
|
|
|
render_image(&mut dm, NCBLIT_1x1)?;
|
|
|
|
render_image(&mut dm, NCBLIT_2x1)?;
|
|
|
|
render_image(&mut dm, NCBLIT_BRAILLE)?;
|
2020-12-25 16:40:37 +00:00
|
|
|
|
2021-01-02 18:45:15 +00:00
|
|
|
Ok(())
|
2020-12-25 16:40:37 +00:00
|
|
|
}
|
|
|
|
|
2021-05-05 17:33:00 +00:00
|
|
|
fn render_image(dm: &mut NcDirect, blit: NcBlitter) -> NcResult<()> {
|
2021-01-02 21:50:48 +00:00
|
|
|
if let Err(nc_error) = dm.render_image("image-16x16.png", NCALIGN_CENTER, blit, NCSCALE_NONE) {
|
2021-01-02 18:45:15 +00:00
|
|
|
return Err(NcError::with_msg(
|
|
|
|
nc_error.int,
|
2021-01-02 21:50:48 +00:00
|
|
|
"ERROR: dmirect_render_image(). Make sure you \
|
2021-01-02 18:45:15 +00:00
|
|
|
are running this example from the examples folder",
|
|
|
|
));
|
2020-12-25 16:40:37 +00:00
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|