Skip to content

Convert CalGray, CalRGB and Lab colors without white point tints - #579

Merged
Velli20 merged 1 commit into
mainfrom
fix-cie-color-conversion
Oct 18, 2026
Merged

Velli20 merged 1 commit into
mainfrom
fix-cie-color-conversion

Conversation

@Velli20

@Velli20 Velli20 commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Summary

CIE-based color spaces with a non-D65 WhitePoint (e.g. [0.5 1 0.5]) were tinted because XYZ was scaled by the white point and then converted with the fixed D65 matrix.

  • CalGray: the gray level is used directly.
  • CalRGB: gamma + Matrix give XYZ, which is converted through sRGB primaries rescaled so RGB (1,1,1) maps to the space's white point.
  • Lab: converts against a fixed daylight reference white [0.957, 1.0, 1.0889] instead of WhitePoint.

These now match PDFium: a CalGray 0.2 fill is #333333, CalRGB 0.4 0.3 0.2 is navy and Lab 60 40 20 is salmon, where Safe-PDF previously drew green, dark red and olive.

Test plan

  • cargo conformance render on the repro PDF: the CalGray, CalRGB and Lab squares now match PDFium
  • cargo test -p pdf-color-space -p pdf-graphics -p pdf-image
  • cargo clippy --all --workspace, cargo fmt --check

🤖 Generated with Claude Code

CalGray now uses its gray level directly, CalRGB converts XYZ through
sRGB primaries rescaled to the space's white point, and Lab converts
against a fixed daylight reference white. A non-D65 WhitePoint no
longer tints these colors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Velli20
Velli20 merged commit 4c7488c into main Oct 18, 2026
10 checks passed
@Velli20
Velli20 deleted the fix-cie-color-conversion branch October 18, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant