Merge branch 'split/makronix-2026-11-22' into main
The 404 commits of the local Makronix tree's ext/src/mcde subtree (tree2694129d, the fork's6a620b12is the common base) onto the fork's own 411. Conflicts, all three resolved to this branch because the fork is the newer side and the split would only have brought the older text back: - programs/dtsystemsettings/panes.c: the split lacks the Dock pane (bc84289d's re-indent included). - programs/dtsystemsettings/main.c: the split still calls MakeStartupDisk, which345c5410removed ("no call to the removed Startup Disk pane"). - programs/dttoolbox/dttoolbox.msg: the split still says "No ToolChest menu",bc84289dmade message 2 match message 1's spelling. Carried over from the split: dtphoto (1280 -> 13908 lines), dtpaint (997 -> 3108), Mcde/Thumb.h and McdeThumb.c, printers.c, the de_DE catalogs. Test: git merge-base main origin/split = 9b8e5b12; per-file three-way diff before resolving (only the fork's own text was dropped); no conflict markers left (git grep -I -E '^(<<<<<<<|>>>>>>>|=======$)'); merge index carries dtphoto.c and dtpaint.c from the split side.
This commit is contained in:
commit
8677a22d84
14 files changed
+15703
-449
No files matched your search
@@ -69,10 +69,193 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
|
||||
catalog. dtphoto (`dtphoto.msg`, 5 messages: the toolbox title, the two
|
||||
status lines and the open/save errors) keeps its menus as the reference's
|
||||
(`dtphoto.menu`, docs/reference/photoshop-ui.csv) -- they are the look of
|
||||
the program, not its sentences. dtpaint builds its menus in code and its
|
||||
labels are catalogued (`dtpaint.msg`, 23 messages); the program has no
|
||||
render table, so its German strings avoid umlauts (a UTF-8 `ü` came out
|
||||
as two latin-1 characters under the core font, measured 2026-11-16).
|
||||
the program, not its sentences. dtphoto reads and saves through one
|
||||
8-bit RGB buffer (`SetImageRGB`, `GetImageRGB`) and converts colours
|
||||
through the visual's masks on TrueColor, or in one XQueryColors/
|
||||
XAllocColor per *distinct* colour otherwise -- never one X round trip per
|
||||
pixel. Measured 2026-11-22 on Xvfb 1280x1024x24, a 1024x768 24-bit BMP
|
||||
with 589,824 distinct colours: `dtphoto -selftest A B` 20.3 s before the
|
||||
change, 0.046 s after; the round trip is byte-identical (2,359,350 bytes,
|
||||
0 differing) and the selftest now compares every pixel, not a sample
|
||||
(`/tmp/dtptest`). The same reader takes 8-bit BMP (uncompressed and
|
||||
RLE8) and the first image of an ICO (1/4/8/24/32 bpp, alpha 0 composited
|
||||
on the document's background, a PNG-compressed icon refused), as dtpaint
|
||||
does; depth 8 (PseudoColor) is exact for 4 and 65536-colour documents
|
||||
alike. A document with more colours than the 256-cell colormap holds
|
||||
loses the excess, as any 8-bit picture must.
|
||||
The toolbox is wired end to end since 2026-11-22: selection is a bit
|
||||
mask, not a rectangle, so the lasso, the magic wand (colour flood,
|
||||
tolerance in colour distance), Select > Inverse and Edit > Clear all
|
||||
work on the same thing, and a command paints only inside the mask.
|
||||
Move drags the masked pixels; it snapshots the picture and the mask at
|
||||
the press and rebuilds from that snapshot on every motion event, because
|
||||
a rebuild from the last frame walks the pixels twice as far, and the
|
||||
release must not recompute the offset (a drag that ends on the frame
|
||||
gives a position outside the canvas, which moved the picture back).
|
||||
Crop drags a rectangle and crops to it on release. Type opens a prompt
|
||||
and draws one line with the GC font over an undo snapshot.
|
||||
`dtphoto -movetest|-croptest|-typetest|-selecttest|-retouchtest` are the
|
||||
headless proofs (no display needed beyond Xvfb): exact pixel sets for
|
||||
wand/inverse/lasso/clear, a 10x10 block moved (10,5) with its mask and a
|
||||
background hole left behind, a crop to 20x30 that keeps only blue, a
|
||||
text line with dark pixels and an untouched corner, and all six
|
||||
retouching tools (blur, sharpen, smudge, dodge, burn, sponge) moving the
|
||||
pixel values in the expected direction. All six run green on depth 24
|
||||
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, that no path is
|
||||
claimed twice and that a path nobody knows stays CMD_NONE (206 paths,
|
||||
0 doubled, measured 2026-11-22). The table ends at its NULL entry so
|
||||
the test walks it without knowing the length. `DTPHOTO_CMDS=1` prints
|
||||
what the loaded menu file bound: 206 of 206, none on CMD_NONE. Every
|
||||
menu path in `dtphoto.menu` resolves, so a bound entry is a wired one.
|
||||
The test also reads `dtphoto.menu` itself and counts the entries that
|
||||
resolve to no command (206 items, 0 unbound, measured 2026-11-22): the
|
||||
table checked against itself can be green while a line in the menu file
|
||||
does nothing. Counter-check: `Select/Grow` on CMD_NONE makes the test
|
||||
print "1 unbound" and FAIL, so the count is not decoration.
|
||||
`Window > Show Commands` lists the command table itself (206 rows), not
|
||||
a hand-kept list, so the palette cannot drift from what the menu binds.
|
||||
`XmLoc` is the one place that casts a catalogue string for
|
||||
`XmStringCreateLocalized`: `Tr` promises `const` because its English
|
||||
fallback is a literal, and the widget asks for `char *`. Without it six
|
||||
dialogs warned; with it the file builds without a single warning.
|
||||
The View switches are read, not just flipped: `SnapX`/`SnapY` pull a
|
||||
marquee or crop drag onto the grid or a guide, `DrawGuides` paints the
|
||||
grid, the guides and the rulers on the canvas (not into the picture),
|
||||
and `-viewtest` checks the snapping arithmetic while `-drawtest`
|
||||
counts the pixels the decorations add on a real pixmap. A flag that
|
||||
only toggles itself is a menu entry that does nothing, which is why
|
||||
both tests exist.
|
||||
`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". `-filtertest` covers the other 43
|
||||
filters -- the gaussian, motion, radial and smart blurs, unsharp and
|
||||
high pass, find edges, emboss, trace contour, facet, fragment, median,
|
||||
offset, clouds, crystallize, pointillize, color halftone, mezzotint,
|
||||
diffuse, extrude, tiles, wind, deinterlace, NTSC colours, dust and
|
||||
scratches, the nine distortions and the whole Image mode family -- and
|
||||
asks for a *property* rather than a change: grayscale leaves r == g ==
|
||||
b, bitmap only 0 and 255, indexed 4 only the ladder 0/85/170/255,
|
||||
offset is a permutation of the picture (same sum and sum of squares),
|
||||
equalize never narrows the range, and inverting twice returns the
|
||||
picture. Two of those are judged against what the display can hold and
|
||||
not against the bytes put in: on a 256-cell PseudoColor map the second
|
||||
inversion drifts 42/255 on a 576-colour picture, which is the map's
|
||||
limit, so the involution is checked on a four-colour picture where the
|
||||
floor is 0, and grayscale is allowed the 10/255 the nearest-cell search
|
||||
costs. The filtertest prints the floor it measured (0 on TrueColor,
|
||||
30 on PseudoColor here) instead of carrying a hand-picked tolerance.
|
||||
The same run covers the colour-model and layer entry points that used
|
||||
to sit outside every test: CMYK Preview must not flatten the picture
|
||||
to one colour, Gamut Warning paints a saturated ink in the warning
|
||||
grey 128 and leaves a printable pixel alone (checked on a picture built
|
||||
for it -- pure red beside neutral grey -- because the structure picture
|
||||
holds no colour at the edge of the gamut), the 5x5 Custom kernel with a
|
||||
single 1 in the middle is the identity, Perspective at 0% is the
|
||||
identity and at 50% reads the top-left from inside the picture, a 90
|
||||
degree Affine rotation is a permutation (same sum and sum of squares)
|
||||
and the identity matrix changes nothing, and Drop Shadow leaves the
|
||||
picture's own pixels alone. All twelve run green on depth 24 and
|
||||
depth 8.
|
||||
`OpAffine` maps around (w-1)/2, not w/2: with the half-open centre a
|
||||
90-degree turn of a 24-wide picture lost a whole row to the background
|
||||
(552 of 576 pixels hit), which `-filtertest` caught as "not a
|
||||
permutation" before the fix. Every sampler that maps by inverse
|
||||
mapping needs the same centre, or an edge falls off.
|
||||
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.
|
||||
The Select menu's morphology works on an exact euclidean distance field
|
||||
(two passes, then the distance to the nearest selected and the nearest
|
||||
unselected pixel), so Expand, Contract, Border, Smooth, Grow, Similar
|
||||
and Feather are arithmetic, not guesses. Feather needed a second
|
||||
layer: one bit per pixel cannot carry a soft edge, so `selCover` holds
|
||||
0-255 beside the bit mask and every consumer -- `OpPerPixel`, the
|
||||
gradient, `PaintMask` -- mixes by that coverage instead of cutting at
|
||||
the bit. `-selmodtest` checks the numbers (a 5x5 block contracted by 1
|
||||
loses its four corners and nothing else, a 2 px band from Border, Grow
|
||||
taking the neighbouring colour and Similar the whole picture).
|
||||
`Window > Show Options` opens the Options box, which is where the
|
||||
tool parameters live: pencil and eraser radius, the wand's tolerance
|
||||
(which Grow/Similar read too), the retouch radius and strength, and the
|
||||
gradient as linear or radial. Every field writes straight into the
|
||||
variable the event handler reads, so there is no second copy, and each
|
||||
edit says `dtphoto: options <name>=<value>` on stderr. The box is built
|
||||
by a fixed row list, and a row returns the FIELD, not its label: a text
|
||||
field is taller than its label, so attaching the next row to the label
|
||||
stacked the fields on top of each other and the tolerance field was
|
||||
unreachable (measured 2026-11-22, the click landed in the eraser field).
|
||||
`DTPHOTO_OPTIONS=1` opens the box at startup, which is how the test
|
||||
reaches it without a mouse.
|
||||
Painting is clipped to the selection, as in the original: the pencil
|
||||
(a hard square tip of 2r+1), the brush (a round one) and the eraser all
|
||||
go through `PaintTip`, which reads the box around the dab once, mixes by
|
||||
the coverage and writes it back. Before that the pencil drew its tip
|
||||
over the whole picture whatever the mask said, and the pencil ignored
|
||||
its radius entirely (one XDrawPoint). `-optest` proves both: a tip laid
|
||||
across the edge of a 2 px selection changes only those two columns, and
|
||||
the wand at tolerance 0 takes one pixel where tolerance 100 takes six.
|
||||
dtpaint builds its menus in code and its labels are catalogued
|
||||
(`dtpaint.msg`, 51 messages from 1-53, 52 unused: menus, the
|
||||
tool/file/error/discard/attributes/colour/print dialogs, Help and About);
|
||||
the program has no render table, so its
|
||||
German strings avoid umlauts (a UTF-8 `ü` came out as two latin-1
|
||||
characters under the core font, measured 2026-11-16; the German copy
|
||||
transliterates ae/oe/ue throughout, re-measured 2026-11-21). Its canvas
|
||||
is a drawing area of exactly the image size inside a scrolled window (a
|
||||
click outside the image must never reach XGetImage -- the picker crashed
|
||||
there), undo is one snapshot taken before every image-changing operation
|
||||
and refreshed after a load, and Open/Save/Invert convert colours through
|
||||
the visual's masks on TrueColor (or in batches otherwise), never one X
|
||||
round trip per pixel (measured 2026-11-21: open 18.3 s -> 0.02 s, invert
|
||||
14.9 s -> 0.05 s, save 6.3 s -> 0.23 s on a 1024x768 BMP; PseudoColor
|
||||
measured 2026-11-22 on Xvfb depth 8: 4-colour BMP round trip exact,
|
||||
selftest PASS -- a picture with more colours than the 256-cell colormap
|
||||
holds loses the excess, as any 8-bit paint must). D3/D4 are built
|
||||
(2026-11-22): the airbrush sprays, Text fills a background box and draws
|
||||
the GC font, Curve is a two-phase quadratic and Polygon closes on a right
|
||||
or double click; rectangular and free-form selection draw an XOR marquee,
|
||||
move their pixels and clear through Edit > Clear Selection (Del), and
|
||||
Select All is Ctrl+A; the magnifier and View > Normal/Large Size zoom
|
||||
1x/2x/4x/8x; Attributes resizes the document (a document operation, no
|
||||
undo across it); Edit Colors sets the foreground from three RGB scales;
|
||||
BMP 8-bit (uncompressed and RLE8) and the first image of an ICO
|
||||
(1/4/8/24/32 bpp, alpha 0 composited on the background; PNG-compressed
|
||||
icons refused) go through the program's own reader; PNG, JPEG, GIF and
|
||||
XPM come from `McdeThumbRead` (libDtSvc), so the program carries no
|
||||
second decoder. Saving writes the format the name ends in, `.png` and
|
||||
`.bmp` through `McdeThumbWrite`, anything else as 24-bit BMP. Measured
|
||||
2026-11-22 on Xvfb depth 24: a 40x30 PNG written back is 1200 of 1200
|
||||
pixels identical, a GIF 0 of 1200 different, JPEG q100 at most 3 steps
|
||||
per channel; on depth 8 a 32-colour picture comes back exact and the
|
||||
1200-colour ramp is off by the colormap (mean 28.6 of 255), which is the
|
||||
visual, not the reader. `test_thumb` writes a 13x7 ramp and reads it
|
||||
back pixel for pixel, and turns red when the writer's rows are flipped or
|
||||
its channels swapped. Print spools the
|
||||
current image through `mcde_sys_print_file` (lp; MCDE_PRINT_COMMAND fakes
|
||||
the tool in tests) and removes the temporary file when the job ends.
|
||||
McdeSys has a catalog too (`lib/McdeSys/mcdesys.msg`, `lib/McdeSys/
|
||||
text.c`, `mcde_sys_msg`): common.c's tool errors ask it for their sentence
|
||||
(messages 1-9: not there, cannot start, failed with status, no pipe, no
|
||||
@@ -104,7 +287,10 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
|
||||
test `test_thumb`) is the miniature: PNG, JPEG, GIF, BMP and XPM read with
|
||||
libpng, libjpeg and C99, scaled with a box filter and cached in
|
||||
`~/.dt/thumbs/<64|128|256>/` -- the one picture reader for dtfile and the
|
||||
programs that show pictures, no gdk-pixbuf, no program per picture.
|
||||
programs that show pictures, no gdk-pixbuf, no program per picture. Since
|
||||
2026-11-22 it writes too: `McdeThumbWrite` (PNG through libpng's simplified
|
||||
API, BMP in C99, the ending decides), so an editor saves without a second
|
||||
encoder.
|
||||
- Programs of its own: `dtbar` (top bar and global menu, protocol
|
||||
`include/Mcde/GlobalMenu.h`), `dtkeys`, `dtthemesync`, `dtappscan`,
|
||||
`dtsystemsettings` (panes by category, McdeSys only), `dtdiskutility`,
|
||||
|
||||
@@ -732,6 +732,11 @@ int mcde_sys_printers(McdeSysPrinter *list, size_t max);
|
||||
/* the default queue for new jobs (root: needs the administrator) */
|
||||
int mcde_sys_printer_default(const char *name);
|
||||
|
||||
/* Spool PATH to PRINTER (NULL or "" = the default queue) with lp(1), as a
|
||||
* job for the event loop (mcde_sys_job_fd/_finish/_cancel). MCDE_PRINT_COMMAND
|
||||
* names the tool instead, for tests with a fake lp. */
|
||||
McdeSysJob *mcde_sys_print_file(const char *path, const char *printer);
|
||||
|
||||
/* a queue for URI with the driverless model (lpadmin -p NAME -E -v URI -m
|
||||
* everywhere); root, a name without spaces or slashes, an ipp:// URI */
|
||||
int mcde_sys_printer_add(const char *name, const char *uri);
|
||||
|
||||
@@ -51,6 +51,14 @@ void McdeThumbFree(McdeThumbImage *image);
|
||||
int McdeThumbScale(const unsigned char *src, int sw, int sh, int maxw,
|
||||
int maxh, unsigned char **dst, int *w, int *h);
|
||||
|
||||
/* IMAGE (8-bit RGB) written to PATH. The format comes from the name's
|
||||
* ending: .png and .bmp are written, anything else is refused. A picture
|
||||
* written here is read back by McdeThumbRead() pixel for pixel, which is
|
||||
* what the test checks. 0 on success, -1 on a bad argument, an unknown
|
||||
* ending or a write error. */
|
||||
int McdeThumbWrite(const char *path, const unsigned char *rgb, int w,
|
||||
int h);
|
||||
|
||||
/* IMAGE on SCREEN as a pixmap of the screen's depth; the size is the
|
||||
* picture's, in pixels. 0 on success, -1 when the picture cannot be read or
|
||||
* the visual is not one this module writes (PseudoColor is not). */
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
@@ -908,6 +909,15 @@ bad:
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* BMP: BI_RGB, 8 and 24 and 32 bits */
|
||||
|
||||
static void
|
||||
Le32Put(unsigned char *p, unsigned long v)
|
||||
{
|
||||
p[0] = (unsigned char) (v & 0xff);
|
||||
p[1] = (unsigned char) ((v >> 8) & 0xff);
|
||||
p[2] = (unsigned char) ((v >> 16) & 0xff);
|
||||
p[3] = (unsigned char) ((v >> 24) & 0xff);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
Le32(const unsigned char *p)
|
||||
{
|
||||
@@ -1551,3 +1561,114 @@ McdeThumbScale(const unsigned char *src, int sw, int sh, int maxw, int maxh,
|
||||
return -1;
|
||||
return ScaleTo(src, sw, sh, maxw, maxh, dst, w, h);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* writing a picture, the reverse of the readers above */
|
||||
|
||||
/* the ending of PATH, lower case, without the dot; NULL when there is none */
|
||||
static const char *
|
||||
Ending(const char *path)
|
||||
{
|
||||
const char *dot = strrchr(path, '.');
|
||||
|
||||
if (dot == NULL || dot[1] == '\0')
|
||||
return NULL;
|
||||
return dot + 1;
|
||||
}
|
||||
|
||||
static int
|
||||
SameEnding(const char *path, const char *want)
|
||||
{
|
||||
const char *e = Ending(path);
|
||||
size_t i;
|
||||
|
||||
if (e == NULL)
|
||||
return 0;
|
||||
for (i = 0; want[i] != '\0'; i++)
|
||||
if (tolower((unsigned char) e[i]) != want[i])
|
||||
return 0;
|
||||
return e[i] == '\0';
|
||||
}
|
||||
|
||||
static int
|
||||
WritePng(const char *path, const unsigned char *rgb, int w, int h)
|
||||
{
|
||||
png_image img;
|
||||
|
||||
memset(&img, 0, sizeof img);
|
||||
img.version = PNG_IMAGE_VERSION;
|
||||
img.width = (png_uint_32) w;
|
||||
img.height = (png_uint_32) h;
|
||||
img.format = PNG_FORMAT_RGB;
|
||||
if (!png_image_write_to_file(&img, path, 0, rgb, 0, NULL)) {
|
||||
png_image_free(&img);
|
||||
return -1;
|
||||
}
|
||||
png_image_free(&img);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
WriteBmp(const char *path, const unsigned char *rgb, int w, int h)
|
||||
{
|
||||
FILE *fp;
|
||||
unsigned char hdr[54], *line;
|
||||
long row = ((long) w * 3 + 3) & ~3L;
|
||||
long size = row * (long) h;
|
||||
int x, y;
|
||||
|
||||
if ((fp = fopen(path, "wb")) == NULL)
|
||||
return -1;
|
||||
memset(hdr, 0, sizeof hdr);
|
||||
hdr[0] = 'B';
|
||||
hdr[1] = 'M';
|
||||
Le32Put(hdr + 2, 54L + size);
|
||||
Le32Put(hdr + 10, 54);
|
||||
Le32Put(hdr + 14, 40);
|
||||
Le32Put(hdr + 18, (unsigned long) w);
|
||||
Le32Put(hdr + 22, (unsigned long) h);
|
||||
hdr[26] = 1; /* planes */
|
||||
hdr[28] = 24; /* bits per pixel */
|
||||
Le32Put(hdr + 34, (unsigned long) size);
|
||||
Le32Put(hdr + 38, 2835); /* 72 dpi, as the original writes it */
|
||||
Le32Put(hdr + 42, 2835);
|
||||
if (fwrite(hdr, 1, sizeof hdr, fp) != sizeof hdr) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
if ((line = malloc((size_t) row)) == NULL) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
for (y = h - 1; y >= 0; y--) {
|
||||
const unsigned char *s = rgb + (size_t) y * (size_t) w * 3;
|
||||
|
||||
memset(line, 0, (size_t) row);
|
||||
for (x = 0; x < w; x++) {
|
||||
line[x * 3] = s[x * 3 + 2]; /* BMP is BGR */
|
||||
line[x * 3 + 1] = s[x * 3 + 1];
|
||||
line[x * 3 + 2] = s[x * 3];
|
||||
}
|
||||
if (fwrite(line, 1, (size_t) row, fp) != (size_t) row) {
|
||||
free(line);
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
free(line);
|
||||
return fclose(fp) == 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
int
|
||||
McdeThumbWrite(const char *path, const unsigned char *rgb, int w, int h)
|
||||
{
|
||||
if (path == NULL || rgb == NULL || w <= 0 || h <= 0 ||
|
||||
w > MAX_WIDTH || h > MAX_HEIGHT ||
|
||||
(long) w * (long) h > MAX_PIXELS)
|
||||
return -1;
|
||||
if (SameEnding(path, "png"))
|
||||
return WritePng(path, rgb, w, h);
|
||||
if (SameEnding(path, "bmp"))
|
||||
return WriteBmp(path, rgb, w, h);
|
||||
return -1;
|
||||
}
|
||||
@@ -308,6 +308,104 @@ TestFormats(const char *dir)
|
||||
McdeThumbFree(&image);
|
||||
}
|
||||
|
||||
/*
|
||||
* A picture in which every pixel is unique: red = x * 8 + 8, green = y * 8 +
|
||||
* 8, blue = 128. A writer that flips the rows, swaps the channels or drops
|
||||
* the alpha cannot pass this.
|
||||
*/
|
||||
static void
|
||||
Ramp(unsigned char *rgb, int w, int h)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
for (y = 0; y < h; y++)
|
||||
for (x = 0; x < w; x++) {
|
||||
unsigned char *p = rgb + ((size_t) y * w + x) * 3;
|
||||
|
||||
p[0] = (unsigned char) (x * 8 + 8);
|
||||
p[1] = (unsigned char) (y * 8 + 8);
|
||||
p[2] = 128;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The writer: PNG and BMP are written from one RGB buffer and read back with
|
||||
* the reader above. Every pixel has to come back unchanged, and an ending
|
||||
* the writer does not know has to be refused -- not written as something else.
|
||||
*/
|
||||
static void
|
||||
TestWrite(const char *dir)
|
||||
{
|
||||
unsigned char rgb[13 * 7 * 3];
|
||||
char path[PATH_MAX];
|
||||
McdeThumbImage image;
|
||||
int x, y, bad;
|
||||
|
||||
Ramp(rgb, 13, 7);
|
||||
|
||||
snprintf(path, sizeof path, "%s/write.png", dir);
|
||||
CHECK(McdeThumbWrite(path, rgb, 13, 7) == 0);
|
||||
memset(&image, 0, sizeof image);
|
||||
CHECK(McdeThumbRead(path, 0, 0, &image) == 0);
|
||||
CHECK(image.width == 13 && image.height == 7);
|
||||
if (image.width == 13 && image.height == 7) {
|
||||
for (bad = 0, y = 0; y < 7; y++)
|
||||
for (x = 0; x < 13; x++) {
|
||||
const unsigned char *p = image.rgb +
|
||||
((size_t) y * 13 + x) * 3;
|
||||
const unsigned char *q = rgb +
|
||||
((size_t) y * 13 + x) * 3;
|
||||
|
||||
if (p[0] != q[0] || p[1] != q[1] ||
|
||||
p[2] != q[2])
|
||||
bad++;
|
||||
}
|
||||
if (bad != 0)
|
||||
fprintf(stderr, "FAIL line %d: png round trip, "
|
||||
"%d of 91 pixels differ\n", __LINE__, bad);
|
||||
CHECK(bad == 0);
|
||||
}
|
||||
McdeThumbFree(&image);
|
||||
|
||||
snprintf(path, sizeof path, "%s/write.bmp", dir);
|
||||
CHECK(McdeThumbWrite(path, rgb, 13, 7) == 0);
|
||||
memset(&image, 0, sizeof image);
|
||||
CHECK(McdeThumbRead(path, 0, 0, &image) == 0);
|
||||
CHECK(image.width == 13 && image.height == 7);
|
||||
if (image.width == 13 && image.height == 7) {
|
||||
for (bad = 0, y = 0; y < 7; y++)
|
||||
for (x = 0; x < 13; x++) {
|
||||
const unsigned char *p = image.rgb +
|
||||
((size_t) y * 13 + x) * 3;
|
||||
const unsigned char *q = rgb +
|
||||
((size_t) y * 13 + x) * 3;
|
||||
|
||||
if (p[0] != q[0] || p[1] != q[1] ||
|
||||
p[2] != q[2])
|
||||
bad++;
|
||||
}
|
||||
if (bad != 0)
|
||||
fprintf(stderr, "FAIL line %d: bmp round trip, "
|
||||
"%d of 91 pixels differ\n", __LINE__, bad);
|
||||
CHECK(bad == 0);
|
||||
}
|
||||
McdeThumbFree(&image);
|
||||
|
||||
/* the ending decides, in either case; an unknown one is refused */
|
||||
snprintf(path, sizeof path, "%s/write.PNG", dir);
|
||||
CHECK(McdeThumbWrite(path, rgb, 13, 7) == 0);
|
||||
CHECK(McdeThumbRead(path, 0, 0, &image) == 0);
|
||||
McdeThumbFree(&image);
|
||||
snprintf(path, sizeof path, "%s/write.tiff", dir);
|
||||
CHECK(McdeThumbWrite(path, rgb, 13, 7) != 0);
|
||||
snprintf(path, sizeof path, "%s/noending", dir);
|
||||
CHECK(McdeThumbWrite(path, rgb, 13, 7) != 0);
|
||||
/* and a picture of nothing is not written at all */
|
||||
snprintf(path, sizeof path, "%s/write2.png", dir);
|
||||
CHECK(McdeThumbWrite(path, rgb, 0, 7) != 0);
|
||||
CHECK(access(path, F_OK) != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
TestScale(void)
|
||||
{
|
||||
@@ -454,6 +552,7 @@ main(void)
|
||||
return 1;
|
||||
}
|
||||
TestFormats(dir);
|
||||
TestWrite(dir);
|
||||
TestScale();
|
||||
TestLimits(dir);
|
||||
TestCache(dir);
|
||||
|
||||
@@ -142,6 +142,39 @@ mcde_sys_printer_default(const char *name)
|
||||
return MCDE_SYS_OK;
|
||||
}
|
||||
|
||||
McdeSysJob *
|
||||
mcde_sys_print_file(const char *path, const char *printer)
|
||||
{
|
||||
static const char *const where[] = { "/usr/bin/lp",
|
||||
"/usr/local/bin/lp", "/usr/sbin/lp", MCDE_PKG_PREFIX "/bin/lp",
|
||||
NULL };
|
||||
const char *lp = getenv("MCDE_PRINT_COMMAND");
|
||||
char *argv[5];
|
||||
int n = 0;
|
||||
|
||||
if (path == NULL || path[0] == '\0' || access(path, R_OK) != 0) {
|
||||
(void) mcde_sys_fail(MCDE_SYS_ENOTSUP,
|
||||
mcde_sys_msg(MSG_NOT_THERE, "%s is not there."),
|
||||
path != NULL ? path : "");
|
||||
return NULL;
|
||||
}
|
||||
if (lp == NULL)
|
||||
lp = Tool(where);
|
||||
if (lp == NULL) {
|
||||
(void) mcde_sys_fail(MCDE_SYS_ENOTSUP,
|
||||
mcde_sys_msg(MSG_NOT_THERE, "%s is not there."), "lp");
|
||||
return NULL;
|
||||
}
|
||||
argv[n++] = (char *) lp;
|
||||
if (printer != NULL && printer[0] != '\0') {
|
||||
argv[n++] = (char *) "-d";
|
||||
argv[n++] = (char *) printer;
|
||||
}
|
||||
argv[n++] = (char *) path;
|
||||
argv[n] = NULL;
|
||||
return mcde_sys_job_start(argv, NULL);
|
||||
}
|
||||
|
||||
/* the checks every name and URI pass before they reach a command line */
|
||||
static int
|
||||
NameOk(const char *name)
|
||||
|
||||
@@ -5,7 +5,7 @@ bin_PROGRAMS = dtpaint
|
||||
dtpaint_CPPFLAGS = -I$(top_srcdir)/include \
|
||||
-DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\"
|
||||
|
||||
dtpaint_LDADD = $(DTCLIENTLIBS) $(XTOOLLIB)
|
||||
dtpaint_LDADD = $(LIBMCDESYS) $(DTCLIENTLIBS) $(XTOOLLIB)
|
||||
|
||||
if SOLARIS
|
||||
dtpaint_LDADD += -lintl
|
||||
|
||||
+2372
-261
File diff suppressed because it is too large.
Load diff
@@ -25,3 +25,32 @@ $set 1
|
||||
21 About dtpaint...
|
||||
22 About dtpaint
|
||||
23 For Help, click Help Topics on the Help Menu.
|
||||
24 untitled
|
||||
25 dtpaint - MCDE
|
||||
26 Cannot open %s.
|
||||
27 Cannot save %s.
|
||||
28 Save changes to "%s"?
|
||||
29 Discard
|
||||
30 Keep
|
||||
31 Open
|
||||
32 Save As
|
||||
33 Help Topics
|
||||
34 Pick a tool on the left and a colour below it, then draw on the canvas. The left button draws with the foreground colour, the right button with the background colour. Ctrl+Z undoes the last step.
|
||||
35 Normal Size
|
||||
36 Large Size
|
||||
37 Text:
|
||||
38 Select All
|
||||
39 Attributes...
|
||||
40 Width:
|
||||
41 Height:
|
||||
42 Width and height must be between 1 and 4096.
|
||||
43 Attributes
|
||||
44 Edit Colors
|
||||
45 Red:
|
||||
46 Green:
|
||||
47 Blue:
|
||||
48 OK
|
||||
49 Cancel
|
||||
50 No printer is set up.
|
||||
51 Print
|
||||
53 Print...
|
||||
@@ -5,7 +5,7 @@ bin_PROGRAMS = dtphoto
|
||||
dtphoto_CPPFLAGS = -I$(top_srcdir)/include \
|
||||
-DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\"
|
||||
|
||||
dtphoto_LDADD = $(DTCLIENTLIBS) $(XTOOLLIB)
|
||||
dtphoto_LDADD = $(LIBMCDESYS) $(DTCLIENTLIBS) $(XTOOLLIB)
|
||||
|
||||
if SOLARIS
|
||||
dtphoto_LDADD += -lintl
|
||||
|
||||
+12804
-176
File diff suppressed because it is too large.
Load diff
@@ -7,3 +7,6 @@ $set 1
|
||||
3 Doc: %dK/%dK
|
||||
4 The picture could not be opened.
|
||||
5 The picture could not be saved.
|
||||
6 Tool Options
|
||||
7 Nothing could be placed.
|
||||
8 The picture could not be exported.
|
||||
@@ -1,4 +1,5 @@
|
||||
$ MCDE dtpaint message catalog, German.
|
||||
$ MCDE dtpaint message catalog, German. The core font has no UTF-8 rendition,
|
||||
$ so umlauts are transliterated (ae/oe/ue), as in the other MCDE catalogs.
|
||||
$
|
||||
$set 1
|
||||
|
||||
@@ -9,11 +10,11 @@ $set 1
|
||||
5 Farben
|
||||
6 Hilfe
|
||||
7 Neu
|
||||
8 Öffnen...
|
||||
8 Oeffnen...
|
||||
9 Speichern
|
||||
10 Speichern unter...
|
||||
11 Beenden
|
||||
12 Rückgängig
|
||||
12 Rueckgaengig
|
||||
13 Auswahl aufheben
|
||||
14 Werkzeuge
|
||||
15 Farbpalette
|
||||
@@ -22,6 +23,35 @@ $set 1
|
||||
18 Farben umkehren
|
||||
19 Bild leeren
|
||||
20 Farben bearbeiten...
|
||||
21 Über dtpaint...
|
||||
22 Über dtpaint
|
||||
21 Ueber dtpaint...
|
||||
22 Ueber dtpaint
|
||||
23 Hilfe: Hilfe-Themen im Hilfe-Menue.
|
||||
24 unbenannt
|
||||
25 dtpaint - MCDE
|
||||
26 %s kann nicht geoeffnet werden.
|
||||
27 %s kann nicht gespeichert werden.
|
||||
28 Aenderungen an "%s" speichern?
|
||||
29 Verwerfen
|
||||
30 Behalten
|
||||
31 Oeffnen
|
||||
32 Speichern unter
|
||||
33 Hilfe-Themen
|
||||
34 Waehlen Sie links ein Werkzeug und darunter eine Farbe, dann zeichnen Sie auf der Flaeche. Die linke Taste zeichnet mit der Vordergrundfarbe, die rechte mit der Hintergrundfarbe. Strg+Z macht den letzten Schritt rueckgaengig.
|
||||
35 Normale Groesse
|
||||
36 Grosse Darstellung
|
||||
37 Text:
|
||||
38 Alles auswaehlen
|
||||
39 Attribute...
|
||||
40 Breite:
|
||||
41 Hoehe:
|
||||
42 Breite und Hoehe muessen zwischen 1 und 4096 liegen.
|
||||
43 Attribute
|
||||
44 Farben bearbeiten
|
||||
45 Rot:
|
||||
46 Gruen:
|
||||
47 Blau:
|
||||
48 OK
|
||||
49 Abbrechen
|
||||
50 Es ist kein Drucker eingerichtet.
|
||||
51 Drucken
|
||||
53 Drucken...
|
||||
@@ -7,3 +7,4 @@ $set 1
|
||||
3 Dok: %dK/%dK
|
||||
4 Das Bild konnte nicht geöffnet werden.
|
||||
5 Das Bild konnte nicht gespeichert werden.
|
||||
6 Werkzeugoptionen
|
||||
Reference in new issue
Block a user