Skip to content

Commit

Permalink
Big reworking with speed increasing
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Oct 11, 2024
1 parent 049519e commit f7f98f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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,
);

Expand Down
4 changes: 2 additions & 2 deletions src/oklab_to_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn oklab_to_image<const CHANNELS_CONFIGURATION: u8, const TARGET: u8>(
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;
}
}
Expand Down Expand Up @@ -211,7 +211,7 @@ fn oklab_to_image<const CHANNELS_CONFIGURATION: u8, const TARGET: u8>(
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;
}
}
Expand Down

0 comments on commit f7f98f4

Please sign in to comment.