mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-24 09:57:08 -06:00
Write DOMAIN_MIN/DOMAIN_MAX in the .cube writer
Found while testing crates/cms/src/lutfile.rs:227 (write_cube) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
872748fb5b
commit
67314ff606
@@ -230,6 +230,10 @@ pub fn write_cube(l: &LutFile) -> String {
|
||||
s.push_str(&format!("TITLE \"{}\"\n", l.title.replace('"', "'")));
|
||||
}
|
||||
s.push_str(&format!("LUT_3D_SIZE {}\n", l.size));
|
||||
if l.domain_min != [0.0; 3] || l.domain_max != [1.0; 3] {
|
||||
s.push_str(&format!("DOMAIN_MIN {} {} {}\n", l.domain_min[0], l.domain_min[1], l.domain_min[2]));
|
||||
s.push_str(&format!("DOMAIN_MAX {} {} {}\n", l.domain_max[0], l.domain_max[1], l.domain_max[2]));
|
||||
}
|
||||
for c in l.data.as_chunks::<3>().0 {
|
||||
s.push_str(&format!("{:.6} {:.6} {:.6}\n", c[0], c[1], c[2]));
|
||||
}
|
||||
@@ -301,6 +305,22 @@ pub fn builtin(id: &str) -> Option<LutFile> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[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\"
|
||||
|
||||
Reference in New Issue
Block a user