mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-09 19:10:48 +00:00
129e208438
- remove `Nc` & `NcD` wrappers, to move them to notcurses-rs library. - update the summary header format for Notcurses and NcDirect - update docs and examples
29 lines
754 B
Rust
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(())
|
|
}
|