mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-06 03:20:26 +00:00
b12abeddc9
- change Option return type for NcResult when appropriate. - make NcDirect constructors return NcResult. - rename NcError::new() to with_msg() and simplify new(). - refactor examples: - rename direct-image.rs to direct-image-c.rs - recreate using rust methods, as direct-image-rust.rs - differentiate more throughly between both styles. - remove the sys namespace on both examples.
37 lines
865 B
Rust
37 lines
865 B
Rust
//! Example 'direct-image'
|
|
//!
|
|
//! Explore image rendering in direct mode
|
|
//!
|
|
//! NOTE: This example uses the C style with functions.
|
|
|
|
use libnotcurses_sys::*;
|
|
use core::ptr::{null, null_mut};
|
|
|
|
fn main() {
|
|
unsafe {
|
|
let ncd = ncdirect_init(null(), null_mut(), 0);
|
|
|
|
render_image(&mut *ncd, NCBLIT_1x1);
|
|
render_image(&mut *ncd, NCBLIT_2x1);
|
|
render_image(&mut *ncd, NCBLIT_BRAILLE);
|
|
|
|
ncdirect_stop(ncd);
|
|
}
|
|
}
|
|
|
|
fn render_image(ncd: &mut NcDirect, blit: NcBlitter) {
|
|
unsafe {
|
|
if ncdirect_render_image(
|
|
ncd,
|
|
cstring!["image-16x16.png"],
|
|
NCALIGN_CENTER,
|
|
blit,
|
|
NCSCALE_NONE,
|
|
) != 0
|
|
{
|
|
panic!("ERROR: ncdirect_render_image(). Make sure you \
|
|
are running this example from the examples folder");
|
|
}
|
|
}
|
|
}
|