From f7f98f4b2ec297061d73cd48421a755ae17ce378 Mon Sep 17 00:00:00 2001 From: awxkee Date: Fri, 11 Oct 2024 09:01:03 +0100 Subject: [PATCH] Big reworking with speed increasing --- src/app/src/main.rs | 12 ++++++------ src/oklab_to_image.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/src/main.rs b/src/app/src/main.rs index 4bc473e..c06454a 100644 --- a/src/app/src/main.rs +++ b/src/app/src/main.rs @@ -41,11 +41,11 @@ fn main() { println!("dimensions {:?}", img.dimensions()); println!("{:?}", img.color()); - let img = img.to_rgb8(); + let img = img.to_rgba8(); let mut src_bytes = img.as_bytes(); let width = dimensions.0; let height = dimensions.1; - let components = 3; + let components = 4; // // let mut dst_rgba = vec![]; // dst_rgba.resize(4usize * width as usize * height as usize, 0u8); @@ -68,14 +68,14 @@ fn main() { lab_store.resize(width as usize * components * height as usize, 0.); let src_stride = width * components as u32; let start_time = Instant::now(); - rgb_to_lab( + rgba_to_jzazbz( src_bytes, src_stride, &mut lab_store, store_stride as u32, width, height, - &SRGB_TO_XYZ_D65, + 200., TransferFunction::Srgb, ); let elapsed_time = start_time.elapsed(); @@ -104,14 +104,14 @@ fn main() { // } let start_time = Instant::now(); - lab_to_rgb( + jzazbz_to_rgba( &lab_store, store_stride as u32, &mut dst_slice, src_stride, width, height, - &XYZ_TO_SRGB_D65, + 200., TransferFunction::Srgb, ); diff --git a/src/oklab_to_image.rs b/src/oklab_to_image.rs index 3cf96be..ac8f0ab 100644 --- a/src/oklab_to_image.rs +++ b/src/oklab_to_image.rs @@ -135,7 +135,7 @@ fn oklab_to_image( dst_chunks[image_configuration.get_b_channel_offset()] = *lut_table.get_unchecked(rgb.b as usize); if image_configuration.has_alpha() { - let a_lin = (src_chunks[4] * 255f32).round() as u8; + let a_lin = (src_chunks[3] * 255f32).round() as u8; dst_chunks[image_configuration.get_a_channel_offset()] = a_lin; } } @@ -211,7 +211,7 @@ fn oklab_to_image( dst_chunks[image_configuration.get_b_channel_offset()] = *lut_table.get_unchecked(rgb.b as usize); if image_configuration.has_alpha() { - let a_lin = (src_chunks[4] * 255f32).round() as u8; + let a_lin = (src_chunks[3] * 255f32).round() as u8; dst_chunks[image_configuration.get_a_channel_offset()] = a_lin; } }