From 07c8591bfc13fb91662c36dad4a007e973fd2e82 Mon Sep 17 00:00:00 2001 From: conglinyizhi Date: Sat, 7 Dec 2024 11:11:33 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(main):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=9B=BE=E5=83=8F=E5=A4=84=E7=90=86=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9RGB=E6=95=B0=E6=8D=AE=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0FLTK=E5=9B=BE=E5=83=8F=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index ffcab73..e08cd5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ use fltk::{ prelude::{GroupExt, WidgetBase, WidgetExt}, window::Window, }; +use image::Rgb; use rscam::{Camera, Config}; fn main() { @@ -55,15 +56,20 @@ fn main() { let start = Instant::now(); let img = image::load_from_memory(&data).unwrap(); let l_data = img.to_luma8(); - let rgb_data = img.to_rgb8(); + let mut rgb_data = img.to_rgb8(); if w == 0 { w = l_data.width() as i32; h = l_data.height() as i32; } + for tmp_x in 0..30 { + for tmp_y in 0..60 { + rgb_data.put_pixel(tmp_x, tmp_y, Rgb([102, 204, 255])); + } + } let fltk_l_image = - RgbImage::new(&l_data.as_raw(), w, h, ColorDepth::L8).unwrap(); + RgbImage::new(l_data.as_raw(), w, h, ColorDepth::L8).unwrap(); let fltk_rgb_image = - RgbImage::new(&rgb_data.as_raw(), w, h, ColorDepth::Rgb8).unwrap(); + RgbImage::new(rgb_data.as_raw(), w, h, ColorDepth::Rgb8).unwrap(); camera_frame.set_image(Some(fltk_l_image)); color_frame.set_image(Some(fltk_rgb_image)); camera_frame.redraw();