Files
mcde/include/Mcde/Image.h
T
lotherkandClaude Opus 5.5 f788367833 mcde: read PNG with libpng, not with Motif
Motif 2.3.8 shifts the channels of a PNG without alpha the wrong way and
draws only its blue (docs/reference/motif-png.txt).  libDtSvc gets
McdeImageGetPixmap/McdeImageFreePixmap (Mcde/Image.h): PNG through libpng's
simplified interface (png_image, the background for the alpha), packed by
the visual's masks; every other format still through XmGetPixmap.  dtwm's
backdrops and slideshow and the small pictures of System Settings use it.
dtwm now also frees a backdrop pixmap that is not in Motif's cache (a
scaled copy), which it kept for good before.

configure finds libpng >= 1.6 with pkg-config; the recipe includes
graphics/png's buildlink3.mk (Motif depends on it already); the header is
in the PLIST.

Measured on Xvfb: the RGB PNG that showed only blue (slide-3.png before)
shows its colours as backdrop (build/mcde-shots/slide-3.png) and as a
small picture (desk-2.png).  A 16-bit PNG is not measured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:16:14 +00:00

34 lines
959 B
C

/*
* Mcde/Image.h -- MCDE: a picture file as a pixmap (libDtSvc,
* DtUtil2/McdeImage.c)
*
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
*
* XmGetPixmap(3) for every format Motif reads, except PNG, which libpng
* reads here: Motif 2.3.8 draws a PNG without alpha as its blue channel
* only (lib/Xm/Png.c; docs/reference/motif-png.txt in the Makronix tree).
*/
#ifndef _Mcde_Image_h
#define _Mcde_Image_h
#include <X11/Intrinsic.h>
#ifdef __cplusplus
extern "C" {
#endif
/* PATH as a pixmap of the screen's depth, transparency over BG; FG and BG
* colour a bitmap as XmGetPixmap does. XmUNSPECIFIED_PIXMAP when the file
* cannot be read. */
Pixmap McdeImageGetPixmap(Screen *screen, const char *path, Pixel fg,
Pixel bg);
/* gives back a pixmap of McdeImageGetPixmap, from Motif's cache or not */
void McdeImageFreePixmap(Screen *screen, Pixmap pixmap);
#ifdef __cplusplus
}
#endif
#endif /* _Mcde_Image_h */