Motif 2.3.8, lib/Xm/Png.c: an RGB PNG (no alpha) loses red and green on a 24/32-bit screen.
Source: /home/lotherk/src/distfiles/motif-2.3.8.tar.gz (the archive pkgsrc x11/motif builds), read 2026-11-11.

Measured: a 1200x900 RGB PNG (8 and 16 bit) as dtwm backdrop through XmGetPixmap shows only its
blue channel, centred and scaled alike (build/mcde-shots/slide-3.png); JPEG is right.

Why: for depth > 16 the shifts are msb(mask) - 7, so RShift = 16, GShift = 8, BShift = 0 for
masks ff0000/00ff00/0000ff; the RGB branch shifts the 8-bit value RIGHT by them (red >> 16 = 0).
The RGBA branch shifts left (red << RShift) and is right.

-- Png.c:290-297
        RShift = 15 - png_msb(RMask);
        GShift = 15 - png_msb(GMask);
        BShift = 15 - png_msb(BMask);
    } else if (screen->root_depth > 16) {
        RShift = png_msb(RMask) - 7;
        GShift = png_msb(GMask) - 7;
        BShift = png_msb(BMask) - 7;
    }
-- Png.c:301-325 (the RGB branch)
            src = image_data + row * image_rowbytes;
            dest = ximage->data + row * ximage_rowbytes;
            if (image_channels == 3) {
                for (i = ximage->width; i > 0; --i) {
                    red = *src++;
                    green = *src++;
                    blue = *src++;
#ifdef NO_24BIT_MASKS
                    pixel = (red << RShift) |
                        (green << GShift) | (blue << BShift);
                    /* recall that we set ximage->byte_order = MSBFirst above */
                    /* GRR BUG:  this assumes bpp == 32, but may be 24: */
                    *dest++ = (char) ((pixel >> 24) & 0xff);
                    *dest++ = (char) ((pixel >> 16) & 0xff);
                    *dest++ = (char) ((pixel >> 8) & 0xff);
                    *dest++ = (char) (pixel & 0xff);
#else
                    red = (RShift < 0) ? red << (-RShift) : red >> RShift;
                    green =
                        (GShift <
                         0) ? green << (-GShift) : green >> GShift;
                    blue =
                        (BShift < 0) ? blue << (-BShift) : blue >> BShift;
                    pixel =
                        (red & RMask) | (green & GMask) | (blue & BMask);
-- Png.c:345-352 (the RGBA branch, correct)
                        green = bg_green;
                        blue = bg_blue;
                    } else {
                        /* this macro (from png.h) composites the foreground
                         * and background values and puts the result into the
                         * first argument */
                        png_composite(red, r, a, bg_red);
                        png_composite(green, g, a, bg_green);

What MCDE does about it (2026-11-11): it does not read PNG through Motif.  libDtSvc's
McdeImageGetPixmap (ext/src/mcde/lib/DtSvc/DtUtil2/McdeImage.c) reads PNG with libpng's
simplified interface and packs it by the visual's masks; dtwm and dtsystemsettings use it.
Measured: the same RGB PNG shows its colours as backdrop and as thumbnail
(build/mcde-shots/slide-3.png, desk-2.png).  pkgsrc's x11/motif is unchanged.
