add option for exact alpha compositing with a background - #34
Open
sgerwk wants to merge 2 commits into
Open
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.