diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..19e7396 --- /dev/null +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index 3e4327a..c291d92 100644 --- a/README.md +++ b/README.md @@ -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 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 -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 @@ -42,7 +42,7 @@ If multiple images match the filename spec, thumbnails are shown. ## 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) diff --git a/src/main/cpp/Makefile b/src/main/cpp/Makefile index e3b7754..8169697 100644 --- a/src/main/cpp/Makefile +++ b/src/main/cpp/Makefile @@ -1,10 +1,12 @@ +CXX=g++ + default: tiv 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 - g++ tiv.o -o tiv -lstdc++fs -pthread -s + $(CXX) tiv.o -o tiv -lstdc++fs -pthread -s install: tiv cp tiv /usr/local/bin/tiv diff --git a/src/main/cpp/tiv.cpp b/src/main/cpp/tiv.cpp index 783723c..d63897a 100644 --- a/src/main/cpp/tiv.cpp +++ b/src/main/cpp/tiv.cpp @@ -362,14 +362,14 @@ void emitCodepoint(int codepoint) { std::cout << (char) (0x80 | ((codepoint >> 6) & 0x3f)); std::cout << (char) (0x80 | (codepoint & 0x3f)); } else { - std::cout << "ERROR"; + std::cerr << "ERROR"; } } void emit_image(const cimg_library::CImg & image, int flags) { - for (int y = 0; y < image.height() - 8; y += 8) { - for (int x = 0; x < image.width() - 4; x += 4) { + for (int y = 0; y <= image.height() - 8; y += 8) { + for (int x = 0; x <= image.width() - 4; x += 4) { CharData charData = flags & FLAG_NOOPT ? getCharData(image, x, y, 0x2584, 0x0000ffff) : getCharData(image, x, y);