2021-06-03 12:25:20 +00:00
|
|
|
|
use libnotcurses_sys::*;
|
|
|
|
|
|
|
|
|
|
const W: u32 = 32;
|
|
|
|
|
const H: u32 = 32;
|
|
|
|
|
|
|
|
|
|
fn main() {
|
2021-06-03 14:12:30 +00:00
|
|
|
|
let nc = NcDirect::new().expect("couldn’t create ncdirect");
|
2021-06-03 12:25:20 +00:00
|
|
|
|
nc.check_pixel_support()
|
|
|
|
|
.expect("failed to check for sixel support");
|
|
|
|
|
|
|
|
|
|
// create a purple rectangle
|
|
|
|
|
let mut buffer = Vec::<u8>::with_capacity(H as usize * W as usize * 4);
|
|
|
|
|
#[allow(unused_parens)]
|
|
|
|
|
for _byte in (0..={ H * W }) {
|
|
|
|
|
buffer.push(190);
|
|
|
|
|
buffer.push(20);
|
|
|
|
|
buffer.push(80);
|
|
|
|
|
buffer.push(255);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-03 16:07:42 +00:00
|
|
|
|
let vframe1 = NcDirectF::from_bgra(&buffer, H, W * 4, W).expect("couldn’t create visual");
|
|
|
|
|
let v = vframe1.ncdirectf_render(nc, NCBLIT_PIXEL, NCSCALE_NONE, 0, 0).expect("failed to render image to sixels");
|
|
|
|
|
nc.raster_frame(v, NCALIGN_LEFT).expect("failed to print sixels");
|
|
|
|
|
vframe1.ncdirectf_free();
|
2021-06-03 12:25:20 +00:00
|
|
|
|
nc.stop().expect("failed to destroy ncdirect context");
|
2021-06-03 16:07:42 +00:00
|
|
|
|
println!();
|
2021-06-03 12:25:20 +00:00
|
|
|
|
}
|