From ff39e658c3b4490254a4416335fa293fb549a8ef Mon Sep 17 00:00:00 2001 From: "h@di" Date: Fri, 3 Aug 2018 16:07:44 +0430 Subject: [PATCH 1/5] Add gitignore --- .gitignore | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .gitignore 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 From f2d933472325af6911b7cccf7b88334ce4d1d253 Mon Sep 17 00:00:00 2001 From: "h@di" Date: Fri, 3 Aug 2018 16:47:38 +0430 Subject: [PATCH 2/5] Fix typos --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) From e7bde92fe7fd4509d3c3ae99a21b588b5e364f06 Mon Sep 17 00:00:00 2001 From: "h@di" Date: Fri, 3 Aug 2018 16:47:53 +0430 Subject: [PATCH 3/5] Parameterize makefile's compiler --- src/main/cpp/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/cpp/Makefile b/src/main/cpp/Makefile index e3b7754..eb89e2d 100644 --- a/src/main/cpp/Makefile +++ b/src/main/cpp/Makefile @@ -1,10 +1,12 @@ +CXX=g++-8 + 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 From f28e0b01296dd399aac8453126d513ec06714151 Mon Sep 17 00:00:00 2001 From: "h@di" Date: Fri, 3 Aug 2018 17:25:32 +0430 Subject: [PATCH 4/5] Change error output stream to stderr --- src/main/cpp/Makefile | 2 +- src/main/cpp/tiv.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/cpp/Makefile b/src/main/cpp/Makefile index eb89e2d..8169697 100644 --- a/src/main/cpp/Makefile +++ b/src/main/cpp/Makefile @@ -1,4 +1,4 @@ -CXX=g++-8 +CXX=g++ default: tiv diff --git a/src/main/cpp/tiv.cpp b/src/main/cpp/tiv.cpp index 783723c..8a04581 100644 --- a/src/main/cpp/tiv.cpp +++ b/src/main/cpp/tiv.cpp @@ -362,7 +362,7 @@ void emitCodepoint(int codepoint) { std::cout << (char) (0x80 | ((codepoint >> 6) & 0x3f)); std::cout << (char) (0x80 | (codepoint & 0x3f)); } else { - std::cout << "ERROR"; + std::cerr << "ERROR"; } } From 3e5a20c5047db227e4b6851bf0db90807d9d100e Mon Sep 17 00:00:00 2001 From: "h@di" Date: Fri, 3 Aug 2018 17:51:09 +0430 Subject: [PATCH 5/5] Fix bug of not processing last row & column of buckets Fix #25 --- src/main/cpp/tiv.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/cpp/tiv.cpp b/src/main/cpp/tiv.cpp index 8a04581..d63897a 100644 --- a/src/main/cpp/tiv.cpp +++ b/src/main/cpp/tiv.cpp @@ -368,8 +368,8 @@ void emitCodepoint(int codepoint) { 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);