feat(main): 将图像处理从 RGB8 转换为 Luma8 格式,提升性能

This commit is contained in:
conglinyizhi 2024-12-07 10:12:15 +08:00
parent 33f0924adb
commit 478eaf29be
1 changed files with 2 additions and 2 deletions

View File

@ -44,13 +44,13 @@ fn main() {
Ok(data) => { Ok(data) => {
let start = Instant::now(); let start = Instant::now();
let img = image::load_from_memory(&data).unwrap(); let img = image::load_from_memory(&data).unwrap();
let rgb_data = img.to_rgb8(); let rgb_data = img.to_luma8();
if w == 0 { if w == 0 {
w = rgb_data.width() as i32; w = rgb_data.width() as i32;
h = rgb_data.height() as i32; h = rgb_data.height() as i32;
} }
let fltk_image = let fltk_image =
RgbImage::new(&rgb_data.as_raw(), w, h, ColorDepth::Rgb8).unwrap(); RgbImage::new(&rgb_data.as_raw(), w, h, ColorDepth::L8).unwrap();
frame.set_image(Some(fltk_image)); frame.set_image(Some(fltk_image));
frame.redraw(); frame.redraw();
let duration = start.elapsed(); let duration = start.elapsed();