diff --git a/Cargo.lock b/Cargo.lock index 04ca3ff..a5db915 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,7 +163,7 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "colorutils-rs" -version = "0.2.2" +version = "0.2.3" dependencies = [ "half", ] diff --git a/Cargo.toml b/Cargo.toml index 27c685b..fa94949 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ workspace = { members = ["src/app"] } [package] name = "colorutils-rs" -version = "0.2.2" +version = "0.2.3" edition = "2021" description = "Hig performance utilities for color format handling and conversion." readme = "README.md" diff --git a/src/app/src/main.rs b/src/app/src/main.rs index a8e7f89..7eacd53 100644 --- a/src/app/src/main.rs +++ b/src/app/src/main.rs @@ -46,26 +46,26 @@ fn main() { println!("dimensions {:?}", img.dimensions()); println!("{:?}", img.color()); - let src_bytes = img.as_bytes(); + 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); - // let rgba = &rgb_to_rgba( - // &src_bytes, - // 3u32 * width, - // &mut dst_rgba, - // 4u32 * width, - // width, - // height, - // 255, - // ); - // src_bytes = rgba; + rgb_to_rgba( + &src_bytes, + 3u32 * width, + &mut dst_rgba, + 4u32 * width, + width, + height, + 255, + ); + src_bytes = &dst_rgba; let mut xyz: Vec = vec![]; - xyz.resize(3 * width as usize * height as usize, 0f32); + xyz.resize(4 * width as usize * height as usize, 0f32); let mut a_plane: Vec = vec![]; a_plane.resize(width as usize * height as usize, 0f32); @@ -82,15 +82,7 @@ fn main() { // width, // height, // ); - rgb_to_lab( - src_bytes, - width * components, - &mut xyz, - width * 3 * std::mem::size_of::() as u32, - width, - height, - ); - // rgb_to_linear( + // rgba_to_linear( // src_bytes, // width * components, // &mut xyz, @@ -99,6 +91,15 @@ fn main() { // height, // TransferFunction::Srgb, // ); + rgba_to_linear( + src_bytes, + width * components, + &mut xyz, + width * 4 * std::mem::size_of::() as u32, + width, + height, + TransferFunction::Srgb, + ); let elapsed_time = start_time.elapsed(); // Print the elapsed time in milliseconds println!("sRGB to XYZ: {:.2?}", elapsed_time); @@ -117,13 +118,14 @@ fn main() { // height, // ); - lab_to_srgb( + linear_to_rgba( &xyz, - width * 3 * std::mem::size_of::() as u32, + width * 4 * std::mem::size_of::() as u32, &mut dst_bytes, width * components, width, height, + TransferFunction::Srgb, ); // linear_to_rgb( diff --git a/src/image_to_linear.rs b/src/image_to_linear.rs index b945488..8ae045a 100644 --- a/src/image_to_linear.rs +++ b/src/image_to_linear.rs @@ -157,7 +157,7 @@ pub fn rgba_to_linear( height: u32, transfer_function: TransferFunction, ) { - channels_to_linear::<{ ImageConfiguration::Rgba as u8 }, false>( + channels_to_linear::<{ ImageConfiguration::Rgba as u8 }, true>( src, src_stride, dst, diff --git a/src/linear_to_image.rs b/src/linear_to_image.rs index 7a10463..cb83743 100644 --- a/src/linear_to_image.rs +++ b/src/linear_to_image.rs @@ -156,7 +156,7 @@ pub fn linear_to_rgba( height: u32, transfer_function: TransferFunction, ) { - linear_to_gamma_channels::<{ ImageConfiguration::Rgba as u8 }, false>( + linear_to_gamma_channels::<{ ImageConfiguration::Rgba as u8 }, true>( src, src_stride, dst,