Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge PR #8083: Write DOMAIN_MIN/DOMAIN_MAX in the .cube writer

aionggaba7e03d6022
diff --cc crates/cms/src/lutfile.rs
index 8c4a087a5,481b8cd89..240aac36f
--- a/crates/cms/src/lutfile.rs
+++ b/crates/cms/src/lutfile.rs
@@@ -308,16 -305,22 +312,32 @@@ pub fn builtin(id: &str) -> Option<LutF
mod tests {
use super::*;
+ #[test]
+ fn cube_title_with_hash_round_trips() {
+ let l = LutFile::from_fn("Look #3", 2, |c| c);
+ assert_eq!(parse_cube(&write_cube(&l)).unwrap().title, "Look #3");
+ let t = "TITLE \"A #b\" # note\nLUT_3D_SIZE 2 # c\n# comment\n";
+ let rows = "0 0 0 # x\n1 0 0\n0 1 0\n1 1 0\n0 0 1\n1 0 1\n0 1 1\n1 1 1\n";
+ let p = parse_cube(&format!("{t}{rows}")).unwrap();
+ assert_eq!(p.title, "A #b");
+ }
+
+ #[test]
+ fn write_cube_keeps_non_default_domain() {
+ let mut l = LutFile::identity(2);
+ l.domain_min = [0.1; 3];
+ l.domain_max = [0.9; 3];
+ let back = parse_cube(&write_cube(&l)).unwrap();
+ assert_eq!(back.domain_min, [0.1; 3]);
+ assert_eq!(back.domain_max, [0.9; 3]);
+ l.domain_min = [0.0, 0.0, 0.5];
+ l.domain_max = [1.0; 3];
+ let back = parse_cube(&write_cube(&l)).unwrap();
+ assert_eq!(back.domain_min, [0.0, 0.0, 0.5]);
+ assert_eq!(back.domain_max, [1.0; 3]);
+ assert!(!write_cube(&LutFile::identity(2)).contains("DOMAIN"));
+ }
+
#[test]
fn cube_domain_is_kept_and_validated() {
let base = "TITLE \"t\"