Skip to content

Page.RenderCMYK: pages in the CMYK of the document - #235

Merged
timzifer merged 2 commits into
mainfrom
claude/issue-209
Oct 14, 2026
Merged

timzifer merged 2 commits into
mainfrom
claude/issue-209

Conversation

@timzifer

Copy link
Copy Markdown
Owner

Fixes #209 (cera side; the stilus side is stilus v0.11.0, bumped here).

Page.RenderCMYK(ctx, *image.CMYK, RenderOptions) draws a page in the CMYK of its document (output intent, OpenOptions.CMYKProfile, or SWOP):

  • DeviceCMYK / ICC CMYK keep their values; grey goes on black
  • Separation/DeviceN colorants Cyan, Magenta, Yellow, Black are those inks; other colorants go through their alternate space
  • RGB and CIE colours go through the profile's B2A table where it has one (internal/cmyk now reads B2A0/B2A1, Profile.Ink), else PDF 10.4.2.4 (full GCR/UCR)
  • blend modes blend the inks' complements (LayerShader.Subtractive); the non-separable ones take black from backdrop or source (LayerShader.Black)
  • luminosity soft masks are drawn in the grey of their CMYK colours
  • paper (no ink) where nothing is drawn; overprint is not simulated (True overprint and separation preview #155 next)

How: the page is drawn twice through the RGBA pipeline, through views of the document that project colours as they are read: C, M, Y into R, G, B, then K into all three. Display lists and widget lists are cached per projection (listKey gains proj); colour spaces, shadings, patterns and images are per view as with #186.

Checks

  • Render unchanged: 113 corpus pages at 50 dpi pixel-identical to main
  • RenderCMYK on all 113 pages: no errors, ~2× the time of Render
  • tests: colours, transparency (opacity, Multiply, Hue, Luminosity), luminosity soft mask in CMYK, DeviceCMYK shading and image samples, B2A profile, region/bands

Follow-ups: a CMYK TIFF in cmd/cera needs CMYK output in calamus' TIFF encoder; overprint per colorant (#155).

RenderCMYK draws into an *image.CMYK: DeviceCMYK and ICC CMYK keep their
values, grey goes on black, Separation and DeviceN process colorants on
their inks and other colorants through their alternate, RGB and CIE
colours through the colour-to-ink table (B2A) of the document's CMYK
profile where it has one and else as PDF converts DeviceRGB.

The page is drawn twice through the RGBA pipeline, with colours projected
as views of the document read them: cyan, magenta and yellow in red,
green and blue, then black in all three. Groups composite inks with
stilus v0.11.0's LayerShader.Subtractive and Black; luminosity soft masks
are drawn in the grey of their CMYK colours. Display lists are cached per
projection; Render is unchanged (corpus pixel-identical).

internal/cmyk reads B2A0/B2A1 and converts XYZ to ink (Profile.Ink).

Fixes #209
@timzifer
timzifer merged commit 9e6cfaf into main Oct 14, 2026
38 checks passed
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.

Render to CMYK: a pipeline in the output space

1 participant