MCDE dtphoto: the Image and Filter menus carry real operations

Image: Invert, Desaturate, Brightness/Contrast, Flip horizontal/vertical,
Rotate 180/90 CW/90 CCW, Image Size and Canvas Size.  Filter: Blur,
Blur More, Sharpen, Sharpen More, Find Edges, Emboss, Solarize, Add Noise,
Median/Despeckle, Mosaic.  All of them read and write through the same RGB
buffer, so no operation costs an X round trip per pixel.

Two bugs found while wiring them:
 - A per-pixel correction ignored the selection.  Invert, Desaturate,
   Brightness and Solarize changed the whole picture even with a mask.
   They now share OpPerPixel, so a new operation cannot forget the mask.
 - A menu entry was bound by its label, but the reference has "Horizontal"
   in Image > Flip and in Layer > Type.  CommandOf takes the full path now
   ("Image/Flip/Horizontal"), the reader stores it in Item.path.

Verified, depth 24 and depth 8, 16 runs, 0 red:
 - -menutest: 31 paths each resolve to the command the callback switches
   on; an unknown path stays CMD_NONE.
 - -optest against the arithmetic, not "the picture changed": a hard edge
   blurred to 170 (six of nine window pixels white), the same edge
   sharpened clamped to 255 and 0, mosaic cells to their mean (100,30,128),
   noise deterministic and inside the range, mask inside changed and
   outside untouched.
 - -selftest on a 1024x768 24-bit BMP: byte-identical (2,359,350 bytes,
   0 differing).
 - -retouchtest -selecttest -movetest -croptest -typetest still green.
 - DTPHOTO_CMDS=1 reports 37 bound entries, the 11 Filter paths among them.
This commit is contained in:
lotherk committed 2026-11-22 11:05:24 +00:00
1 parent d4790b53d3
commit e0f4867ded
2 files changed
+1257 -31

No files matched your search

+26
View File
@@ -103,6 +103,32 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
and depth 8. Retouching reads a patch around the dab through one
GetImageRGB round trip, not one per pixel; measured 80 ms for a full
1024x768 open/save round trip on a busy host.
The Image and Filter menus carry real operations since 2026-11-22, all
through the same RGB buffer: Image > Adjust (Invert, Desaturate,
Brightness/Contrast), Flip (horizontal, vertical), Rotate (180, 90 CW,
90 CCW, which swaps the document size), Image Size (nearest neighbour,
the aspect kept from the width) and Canvas Size (the picture centred in
the larger canvas, the border in the background colour). Filter >
Blur/Sharpen are 3x3 convolutions (Blur More a gaussian-ish kernel,
Sharpen More the strong laplacian), Stylize has Find Edges, Emboss and
Solarize, Noise has Add Noise (a xorshift seed, so the same run gives
the same bytes) and Median/Despeckle, Pixelate has Mosaic. The border
pixels keep what they had -- a 3x3 window at the edge would fold
outside the picture -- and every per-pixel operation honours the
selection: the first four (invert, desaturate, brightness, solarize)
did not, which is why they now share `OpPerPixel` and a new operation
cannot forget the mask.
A menu entry is bound by its full path, not its label: the reference
has "Horizontal" in Image > Flip and in Layer > Type, and the label
alone cannot tell them apart. `CommandOf` takes "menu/sub/item", the
reader stores it in `Item.path`, and `-menutest` proves every path
resolves to the command the callback switches on (31 paths, measured
2026-11-22). `DTPHOTO_CMDS=1` prints what the loaded menu file bound.
`dtphoto -optest|-menutest` are headless too: the operations are checked
against the arithmetic (a hard edge blurred to 170, the same edge
sharpened clamped to 255 and 0, a mosaic cell to its mean) and not
against "the picture changed". All eight run green on depth 24 and
depth 8.
The zoom magnifier doubles on the left button and halves on the right
(12%-800%), the hand pans the view, and both say what they did on
stderr so a mouse-driven test can read the result.
+1231 -31
View File
File diff suppressed because it is too large. Load diff