On Friday, April 30, 2021 at 9:35:36 PM UTC+2 Albrecht Schlosser wrote:
A missing piece of Fl_Window::capture_rectangle(), compared to
fl_read_image() would be that fl_read_image() can create an alpha
channel in case the user wants one. IIRC this would be a constant for
all pixels.
In the docs of fl_capture_window_part() you write: "The image depth may
differ between platforms". What exactly does this mean? Are there
platforms (macOS?) where you can "capture transparency" from an existing
window? Or what else does it mean?
GL windows return depth-3 images on all platforms.
Other windows return depth-4 on macOS and depth-3 on X11 and Windows.
Because the capture can mix GL and non-GL windows, depth conversions
are performed by the function when necessary.
I kept the depth-4 on macOS because this preserves the rounded angles of the window
when the image is drawn: off-window pixels are fully transparent. There's no benefit
for most pixels, because FLTK doesn't (yet) draw with transparency.
If this (alpha channel on certain platforms) does not preclude it, we
could also add an optional 5th parameter 'alpha' to return an image with
a preset alpha channel. Maybe. I don't know the details, this should be
discussed further.
What is the use of a constant transparency value across all pixels of an image?
If there's one, it's certainly possible to apply it when drawing that image.