Skip to content

add option for exact alpha compositing with a background - #34

Open
sgerwk wants to merge 2 commits into
godspeed1989:masterfrom
sgerwk:master
Open

add option for exact alpha compositing with a background#34
sgerwk wants to merge 2 commits into
godspeed1989:masterfrom
sgerwk:master

Conversation

@sgerwk

@sgerwk sgerwk commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

The current implemention of alpha compositing is fast but approximating, by copying the foreground only in the regions where the alpha channel is greater than 0x80. This is fast because it resorts to memory region copying operations and avoids the weighted average of foreground and background color. Yet, if the current terminal background color is black and the image is mostly transparent or black, a black square is shown.

This commit introduces an option -A to allow for exact alpha compositing with a solid background, which can be specified as either "white", "black", "green", a greylevel in the 0-255 interval or an RGB triplet.

sgerwk added 2 commits April 11, 2026 20:36
The current implemention of alpha compositing is fast but approximating, by
copying the foreground only in the regions where the alpha channel is greater
than 0x80. This is fast because it resorts to memory region copying operations
and avoids the weighted average of foreground and background color. Yet, if the
current terminal background color is black and the image is mostly transparent
or black, a black square is shown.

This commit introduces an option -A to allow for exact alpha compositing with a
solid background, which can be specified as either "white", "black", "green", a
greylevel in the 0-255 interval or an RGB triplet.
This commit adds two backgrounds for transparent images, in addition to the
solid one: the noise background is randomly grey, the checkerboard:size
background alternates between light and dark squares of the given size (default
20).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant