Skip to content

Commit

Permalink
LCh, bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Jun 17, 2024
1 parent 18f0464 commit 8203988
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ workspace = { members = ["src/app"] }

[package]
name = "colorutils-rs"
version = "0.4.7"
version = "0.4.8"
edition = "2021"
description = "High performance utilities for color format handling and conversion."
readme = "README.md"
Expand Down
8 changes: 5 additions & 3 deletions src/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() {
println!("HSL {:?}", hsl);
println!("Back RGB {:?}", hsl.to_rgb8());

let img = ImageReader::open("./assets/asset.jpg")
let img = ImageReader::open("./assets/beach_horizon.jpg")
.unwrap()
.decode()
.unwrap();
Expand Down Expand Up @@ -58,13 +58,14 @@ fn main() {
lab_store.resize(width as usize * components * height as usize, 0f32);
let src_stride = width * components as u32;
let start_time = Instant::now();
rgb_to_lch(
rgb_to_linear(
src_bytes,
src_stride,
&mut lab_store,
store_stride as u32,
width,
height,
TransferFunction::Srgb,
);
let elapsed_time = start_time.elapsed();
// Print the elapsed time in milliseconds
Expand Down Expand Up @@ -92,13 +93,14 @@ fn main() {
// }

let start_time = Instant::now();
lch_to_rgb(
linear_to_rgb(
&lab_store,
store_stride as u32,
&mut dst_slice,
src_stride,
width,
height,
TransferFunction::Srgb,
);

let elapsed_time = start_time.elapsed();
Expand Down
10 changes: 5 additions & 5 deletions src/linear_to_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ fn linear_to_gamma_channels<const CHANNELS_CONFIGURATION: u8, const USE_ALPHA: b
);

let dst = unsafe { dst_ptr.add(px) };
let transferred = rgb.apply(transfer);
let rgb8 = transferred.to_u8();

unsafe {
dst.write_unaligned((transfer(rgb.r).round() * 255f32) as u8);
dst.add(1)
.write_unaligned((transfer(rgb.g).round() * 255f32) as u8);
dst.add(2)
.write_unaligned((transfer(rgb.b).round() * 255f32) as u8);
dst.write_unaligned(rgb8.r);
dst.add(1).write_unaligned(rgb8.g);
dst.add(2).write_unaligned(rgb8.b);
}

if USE_ALPHA && image_configuration.has_alpha() {
Expand Down

0 comments on commit 8203988

Please sign in to comment.