mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-09 12:32:52 +00:00
M11: 6.2.10 checks a calibrated blending space's white point values
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
This commit is contained in:
1 parent
ffa5c23f7d
commit
14f8c2c64c
2 files changed
+7
-3
No files matched your search
@@ -657,6 +657,9 @@ fn a_blending_space_is_device_independent_and_an_intent_has_a_profile() {
|
||||
("CalRGB without its dictionary", "/CS [/CalRGB]".to_owned(), vec![]),
|
||||
("CalGray without a white point", "/CS [/CalGray << >>]".to_owned(), vec![]),
|
||||
("CalRGB with a short white point", "/CS [/CalRGB << /WhitePoint [0.9505 1] >>]".to_owned(), vec![]),
|
||||
("CalRGB with a zero white point", "/CS [/CalRGB << /WhitePoint [0 0 0] >>]".to_owned(), vec![]),
|
||||
("CalGray with a white point whose Y isn't 1", "/CS [/CalGray << /WhitePoint [0.9505 0.5 1.089] >>]".to_owned(), vec![]),
|
||||
("CalRGB with a non-number in its white point", "/CS [/CalRGB << /WhitePoint [0.9505 1 /Z 1.089] >>]".to_owned(), vec![]),
|
||||
("Lab", "/CS [/Lab << /WhitePoint [0.9505 1 1.089] >>]".to_owned(), vec![]),
|
||||
(
|
||||
"Separation",
|
||||
|
||||
@@ -90,12 +90,13 @@ pub(crate) fn page_names_blending_space(doc: &Document, page: &Dict) -> bool {
|
||||
/// gray, RGB or CMYK to match.
|
||||
fn independent_blending_space(doc: &Document, a: &[Object]) -> Option<i64> {
|
||||
let family = a.first().map(|f| doc.resolve(f));
|
||||
// A CalGray or CalRGB space needs its dictionary, with the required `/WhitePoint` of three
|
||||
// numbers (ISO 32000-1 Tables 63 and 64).
|
||||
// A CalGray or CalRGB space needs its dictionary, with the required `/WhitePoint` [X Y Z]: X
|
||||
// and Z positive, Y 1 (ISO 32000-1 Tables 63 and 64).
|
||||
let calibrated = || {
|
||||
let params = a.get(1).map(|p| doc.resolve(p));
|
||||
let white = params.as_deref().and_then(Object::as_dict).and_then(|d| d.get(b"WhitePoint")).map(|w| doc.resolve(w));
|
||||
white.as_deref().and_then(Object::as_array).is_some_and(|w| w.len() == 3 && w.iter().all(|v| doc.resolve(v).as_f64().is_some()))
|
||||
let values: Option<Vec<f64>> = white.as_deref().and_then(Object::as_array).and_then(|w| w.iter().map(|v| doc.resolve(v).as_f64()).collect());
|
||||
matches!(values.as_deref(), Some(&[x, y, z]) if x > 0.0 && y == 1.0 && z > 0.0)
|
||||
};
|
||||
match family.as_deref().and_then(Object::as_name)? {
|
||||
b"CalGray" => calibrated().then_some(1),
|
||||
|
||||
Reference in new issue
Block a user