21 Commits
Author SHA1 Message Date
David Mann 50fd48a706 Merge #16533 into the merge queue batch
fix(paint): Color replacement reads and writes through the document's CMYK profile (#11918)
2026-11-25 13:28:30 +01:00
David Mann 601548579c Merge #16558 into the merge queue batch
fix(retouch): Content-Aware patch fills from surroundings instead of pasting the source (#12118)
2026-11-25 13:28:28 +01:00
David Mann b8eea8463d Merge #15990 into the merge queue batch
Fill and Stroke grey the modes the document can't use (#14647)
2026-11-25 13:28:25 +01:00
David Mann ec236094ca Merge #16638 into the merge queue batch
fix(tools): a pattern from an Indexed image keeps painting (#13071)
2026-11-25 13:28:24 +01:00
hnoerenberg 5068320297 fix(paint): blend Color replacement on the CMYK channels of the document
In a CMYK/8 document the Color mode no longer takes the pixel through the RGB
blend space. It follows the rule ISO 32000-1 11.3.5.3 gives for a non-separable
blend in a CMYK space, which is what the issue's four numbers come from: C, M and
Y complemented, blended like RGB - Color is SetLum(source, L(backdrop)) with
ClipColor pulling the result back into gamut towards grey, the step that keeps the
lightness of the BOTTOM layer - complemented back, K from the backdrop. Hue,
Saturation and Luminosity in CMYK, and CMYK/16, keep the RGB blend: the issue
leaves them unmeasured. RGB, Grayscale and Lab documents are untouched, and the
tolerance match still reads the pixels as RGB.

The foreground's inks come from the pick when it was picked as CMYK
(ReplaceSettings::color_inks, the pair a Brush stroke already carries, #4196 and
#4344), and from its RGB through the document's CMYK profile otherwise: the
profile plumbing of this branch is what turns the picked colour into the
document's channels.

Measured with the tests added by the previous commit (40 px hard tip, pure blue
foreground, Mode Color, one click each, the issue's document converted to CMYK/8;
the table is C89 M71 Y0 K1 / C42 M34 Y0 K0 / C55 M44 Y0 K0 / C91 M72 Y0 K4):

- Coated FOGRA39, the CMYK space those numbers were measured in: C89.41 M70.59 Y0
  K1.18, C41.18 M32.55 Y0 K0, C55.69 M43.53 Y0 K0.39, C91.37 M71.76 Y0.78 K5.10 -
  every ink within 1.5 percentage points.
- No profile at all, the backdrop filled with the inks the reference measured and
  the foreground picked as C93.33 M74.60 Y0 K0: C89.02 M71.37 Y0 K0.78, C42.75
  M34.12 Y0 K0, C55.69 M44.71 Y0 K0, C90.59 M72.55 Y0 K4.31 - within 0.8.
- PhotoCraft's own default working space (the built-in coated profile), which is
  not FOGRA39: C74.90 M77.25 Y0 K0, C34.51 M35.69 Y0 K0, C41.18 M42.75 Y0 K0,
  C76.86 M79.22 Y0 K0. That space renders pure blue as C96.86 M100 Y0 K0 and a
  Color blend takes its hue from the foreground, so the result's C and M follow
  that ratio rather than the table's 89 : 71, and it makes no K from these four
  colours, so the table's K1 and K4 cannot appear there either.
2026-11-25 01:41:31 +01:00
hnoerenberg b8d89b3a28 test(engine-paint): ask the CMYK Color click for the ink table of #11918
The Color mode of Color Replacement in a CMYK document has to keep the lightness
of the pixel it lands on. The issue's table is the measurement of that: on its
test document converted to CMYK/8, one click each with a pure blue foreground and
Mode Color, the reference application stores

| click | inks |
|---|---|
| red stripe | C89 M71 Y0 K1 |
| green stripe | C42 M34 Y0 K0 |
| pink stripe | C55 M44 Y0 K0 |
| block 0 | C91 M72 Y0 K4 |

within 3 percentage points per ink. The tests now ask for those four rows instead
of the inks today's RGB round trip stores, in a document converted with Coated
FOGRA39 - the CMYK space those numbers were measured in.

The other tests of the file follow the same ruling: a fixture that needs no
profile at all (the backdrop filled with the inks the reference measured for those
four pixels, the foreground picked as C93.33 M74.60 Y0 K0), a lightness test that
compares the ink-space luminosity of the pixel before and after the click, and the
profile-plumbing test re-derived from the ink-channel rule. Hue, Saturation and
Luminosity in CMYK, CMYK/16 and RGB documents stay on their existing pins: the
issue leaves them unmeasured.

Seen red on this head before the blend change: 5 of 11 failed
(the_four_clicks_land_on_the_issue_s_ink_table_in_the_space_it_was_measured_in
stores C74.90 where the table asks for C89, the_color_blend_follows_the_ink_rule_
without_a_profile stores C96.08, the_color_click_in_the_working_colour_space_
blends_on_the_ink_channels stores C96.08 M100, the_color_click_keeps_the_pixel_s_
lightness moves the pixel's lightness to the foreground's, and
color_blend_in_cmyk_converts_through_the_documents_cmyk_profile keeps the
RGB-round-trip inks). The 6 passing tests pin today's output and pass both ways.
2026-11-25 01:16:45 +01:00
hnoerenberg ddfeabd6a9 Merge upstream/main into fix/content-aware-patch-fill-12118
# Conflicts:
#	crates/engine-paint/src/cmd/retouch_cmds/patch_content_aware_fill_tests.rs
2026-11-24 20:16:10 +01:00
RickiNano 123c88f0b0 Merge remote-tracking branch 'origin/main' into fix/fill-mode-by-document-14647
fill_ui.rs: main (#13421) seeds the Fill dialog's colour inks and gives defaults() the picked CMYK; this PR's
rows(app, ...) call stays so the Mode row reads the document. main's new reset test builds its rows with an app.
2026-11-24 13:17:11 +01:00
hnoerenberg ca431fde00 test(tools): pin the Indexed pattern row this change lets go, and name its follow-up
#12887 measured a second half of the rule the reference application holds: it refuses an Indexed pattern from another image, whose colours are not in the document's colour table, and paints only the one carrying that table. Tracking the source mode and not the table lets that case paint. Pin it exactly as it behaves now - the tile's red and green land in a document whose table holds neither - so the follow-up (#16642) is met with a test that says which way the behaviour has to go, and record the same thing where the field is documented: how a repeat definition of pixels already in the library picks its source, and that the PSD raw-block comparison now covers the new field. An index written before the source member still loads the whole pattern with no source, which the library test now strips the member to prove.
2026-11-24 12:21:44 +01:00
hnoerenberg 3c6e332fc5 fix(tools): a pattern from an Indexed image keeps painting (#13071)
In an Indexed Color document the Pattern Stamp refused every pattern. That stopped the strokes that worked before: a pattern Edit > Define Pattern had taken from an Indexed image carries the document's own colours, which is the case the reference application paints. The refusal now asks the pattern's recorded source mode, so an RGB, Grayscale, CMYK or Lab pattern - and one read from a file, whose source is not known - is still refused with the same words, while an Indexed-source stroke lays the tile's own samples and adds one History step. The command, the live aligned stroke, the live Impressionist stroke and the canvas press check all ask the same rule.
2026-11-24 11:22:25 +01:00
hnoerenberg 818a4a010d feat(doc): patterns record the colour mode they were defined from
Edit > Define Pattern composites the area in the document's pixel format, which stores an Indexed Color document expanded to RGB. Nothing on Pattern said where the tile came from, so a pattern taken from an Indexed image was indistinguishable from an RGB one, and a tool that cares about the difference had nothing to read.

The new field names the source mode. The pixels, the id and what the pattern library lists stay as they were. A pattern read from a file records no source: a .pat or PSD block says what its pixels are, not which document they came from. The library index and .pcraft carry the field, so a defined pattern keeps its source across a restart or a save; files written before it read as no source.
2026-11-24 11:22:16 +01:00
RickiNano 1010ca8c39 Merge remote-tracking branch 'origin/main' into fix/fill-mode-by-document-14647
main moved fill_cmds to photocraft-engine-paint. Edit > Stroke stays in core and
also refuses greyed modes, so greyed_modes and check_mode_available move to core's
pixel_fill, which both commands share; fill_cmds re-exports greyed_modes for the
dialogs.
2026-11-24 08:53:12 +01:00
hnoerenberg d7b2d33265 test(engine-paint): keep the CMYK Color Replacement tests with the moved command code
upstream/main moved the painting commands (brush_cmds and its Color Replacement entry points) from photocraft-engine-core to photocraft-engine-paint (engine-split step 8). The merge followed the rename and put the test module declaration in engine-paint's brush_cmds.rs, so the file has to sit next to it: cargo check -p photocraft-engine-paint --all-targets failed with "couldn't find file crates/engine-paint/src/cmd/color_replacement_cmyk_tests.rs" before this move.
2026-11-24 05:44:22 +01:00
hnoerenberg d66e704ae2 Merge upstream/main into fix/cmyk-color-blend-11918 2026-11-24 05:34:35 +01:00
superplay2021 15c984ab59 Merge latest main and preserve CMYK through the paint engine split 2026-11-24 00:10:22 +02:00
aiongg f226fdc42d Merge remote-tracking branch 'upstream/main' into engine-split-step7
# Conflicts:
#	crates/engine-core/src/cmd/mode_cmds.rs
2026-11-23 19:41:31 +00:00
aiongg cbb670962b Engine split step 7: the History Brush format checks' tests move with them to paint's history_source 2026-11-23 15:28:07 +00:00
aiongg 8301a166df Engine split step 7: each engine crate lists its own incomplete-docs commands (handed to the install; core's param_check reads the installed set) 2026-11-23 15:23:10 +00:00
aiongg 9277ac1673 Engine split step 7: hand fixes for the moved tests (test-local copies, flate2 dev-dependency, unused imports, dead test helpers) 2026-11-23 15:08:36 +00:00
aiongg 850e73c5fb Engine split step 7: the paint crate (installs per crate, registry order from command_ids.txt, helpers moved down, paint-only helpers moved up, live-stroke traits, admit hook, tooling) 2026-11-23 14:16:34 +00:00
aiongg 1086d71fd9 Engine split step 7: engine_cut.py and its paint split (paint modules to crates/engine-paint/src) 2026-11-23 14:06:43 +00:00