stefanhaustein / TerminalImageViewer

Small C++ program to display images in a (modern) terminal using RGB ANSI codes and unicode block graphics characters
Other
1.55k stars 111 forks source link

Transparency support for PNG #77

Open tryadelion opened 4 years ago

tryadelion commented 4 years ago

there seems to be no support for alpha channel on PNG's / Gifs, is that a possibility? atleast on fully transparent rgba(0,0,0,0) pixels.

aaronliu0130 commented 4 years ago

I don't think that is as this project uses unicode half-block characters, and I don't think there is a transparent half block character. If we use unicode invisible characters, we can't really promise on the spacing.

tryadelion commented 4 years ago

how about U+2591 for 0-alpha? it wouldnt look solid, atleast

stefanhaustein commented 4 years ago

We can't access / preserve the terminal background. We could add support for a user-specified "background" color though.... Perhaps default to the common gray/gray checkerboard pattern?

aaronliu0130 commented 4 years ago

how about U+2591 for 0-alpha? it wouldnt look solid, atleast

Yes, that Unicode character sure doesn't work well on my terminal emulator. See the screenshot below. Ignore the cow.

tryadelion commented 4 years ago

@stefanhaustein maybe sth like this? https://stackoverflow.com/questions/43931304/is-it-possible-to-determine-the-background-color-of-the-terminal-in-a-linux-mach

stefanhaustein commented 4 years ago

Not sure how accessible the shell variable would be from cross-platform c++... if not, an explicit command line parameter would still help to pass it over... So I think it makes sense to start with that and then take it from there....

aaronliu0130 commented 4 years ago

Well, usage of system() is considered to be not good, but since we don't have any other options lets just take it from here. I'm not sure if that shell script is cross-terminal though...

tryadelion commented 4 years ago

I can test on some terminals mac and debian, mint and a couple more if necessary