From 477797716f492fe0ad7f50736123db148ca7764b Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Thu, 3 Jun 2021 09:07:42 -0700 Subject: [PATCH] =?UTF-8?q?remove=20unsafe=20code=20from=20example=20?= =?UTF-8?q?=E2=80=9Cissue-1716=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that the NcDirectF type and its methods are defined, there is no need to set a bad example. --- rust/examples/issue-1716.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/rust/examples/issue-1716.rs b/rust/examples/issue-1716.rs index eeab4969a..e05dd138a 100644 --- a/rust/examples/issue-1716.rs +++ b/rust/examples/issue-1716.rs @@ -18,16 +18,10 @@ fn main() { buffer.push(255); } - let vframe1 = NcVisual::from_bgra(&buffer, H, W * 4, W).expect("couldn’t create visual"); - // let voptions = NcVisualOptions::fullsize_pixel_without_plane(0, 0, H, W); - - unsafe { - let v = ffi::ncdirectf_render(nc, vframe1, NCBLIT_PIXEL, NCSCALE_NONE, 0, 0); - if !v.is_null() { - ncdirect_raster_frame(nc, v, NCALIGN_LEFT); - } - } - - vframe1.destroy(); + 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(); nc.stop().expect("failed to destroy ncdirect context"); + println!(); }