Merge pull request #26 from hadisfr/master

Some improvements
This commit is contained in:
Stefan Haustein 2018-08-03 17:17:57 +02:00 committed by GitHub
commit 681b2d468b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 104 additions and 8 deletions

94
.gitignore vendored Normal file
View file

@ -0,0 +1,94 @@
###C++###
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
tiv
###Java###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
###Linux###
*~
# KDE directory preferences
.directory
###OSX###
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

View file

@ -9,9 +9,9 @@ For each 4x8 pixel cell of the (potentially downscaled) image:
1. Find the color channel (R, G or B) that has the biggest range of values for the current cell 1. Find the color channel (R, G or B) that has the biggest range of values for the current cell
2. Split this range in the middle and create a corresponding bitmap for the cell 2. Split this range in the middle and create a corresponding bitmap for the cell
4. Compare the bitmap to the assumed bitmaps for various unicode block graphics characters 4. Compare the bitmap to the assumed bitmaps for various unicode block graphics characters
5. Re-calculate the foregound and background colors for the chosen character. 5. Re-calculate the foreground and background colors for the chosen character.
See the difference by disabling this optimization using the `-0` option. Or just take a look at the comparsion image at the end of this text. See the difference by disabling this optimization using the `-0` option. Or just take a look at the comparison image at the end of this text.
## Installation ## Installation
@ -42,7 +42,7 @@ If multiple images match the filename spec, thumbnails are shown.
## Comparison to Using Half-Block Characters Only ## Comparison to Using Half-Block Characters Only
The top image was generated with the character optization diabled via the `-0` option. The top image was generated with the character optimization disabled via the `-0` option.
![Comparison](http://i.imgur.com/OzdCeh6.png) ![Comparison](http://i.imgur.com/OzdCeh6.png)

View file

@ -1,10 +1,12 @@
CXX=g++
default: tiv default: tiv
tiv.o: tiv.cpp CImg.h tiv.o: tiv.cpp CImg.h
g++ -std=c++17 -Wall -fpermissive -fexceptions -O2 -c tiv.cpp -o tiv.o $(CXX) -std=c++17 -Wall -fpermissive -fexceptions -O2 -c tiv.cpp -o tiv.o
tiv : tiv.o tiv : tiv.o
g++ tiv.o -o tiv -lstdc++fs -pthread -s $(CXX) tiv.o -o tiv -lstdc++fs -pthread -s
install: tiv install: tiv
cp tiv /usr/local/bin/tiv cp tiv /usr/local/bin/tiv

View file

@ -362,14 +362,14 @@ void emitCodepoint(int codepoint) {
std::cout << (char) (0x80 | ((codepoint >> 6) & 0x3f)); std::cout << (char) (0x80 | ((codepoint >> 6) & 0x3f));
std::cout << (char) (0x80 | (codepoint & 0x3f)); std::cout << (char) (0x80 | (codepoint & 0x3f));
} else { } else {
std::cout << "ERROR"; std::cerr << "ERROR";
} }
} }
void emit_image(const cimg_library::CImg<unsigned char> & image, int flags) { void emit_image(const cimg_library::CImg<unsigned char> & image, int flags) {
for (int y = 0; y < image.height() - 8; y += 8) { for (int y = 0; y <= image.height() - 8; y += 8) {
for (int x = 0; x < image.width() - 4; x += 4) { for (int x = 0; x <= image.width() - 4; x += 4) {
CharData charData = flags & FLAG_NOOPT CharData charData = flags & FLAG_NOOPT
? getCharData(image, x, y, 0x2584, 0x0000ffff) ? getCharData(image, x, y, 0x2584, 0x0000ffff)
: getCharData(image, x, y); : getCharData(image, x, y);