Compare commits

..

5 Commits

Author SHA1 Message Date
Stefan Haustein 1fbf057fcc Revert "Persistence options"
This reverts commit aef2fbccdc.
2019-03-23 22:33:10 +01:00
Stefan Haustein d4348138df Revert "Constant standard output stream"
This reverts commit 543cebef37.
2019-03-23 22:33:10 +01:00
Stefan Haustein 0f40406ddd Revert "null values"
This reverts commit 9717adc840.
2019-03-23 22:33:10 +01:00
Stefan Haustein 763aa3e638 Revert "null values"
This reverts commit 28e9f5e40e.
2019-03-23 22:33:10 +01:00
Stefan Haustein e5306c9aca Revert "null values"
This reverts commit 3e57ebb80c.
2019-03-23 22:33:10 +01:00
2 changed files with 9 additions and 25 deletions

View File

@ -15,7 +15,6 @@ See the difference by disabling this optimization using the `-0` option. Or just
## News
- 2019-03-26: Exciting week: @Cableo has fixed output redirection, @boretom has added cross-compilation support to the build file and @AlanDeSmet has fixed tall thumbnails and greyscale images.
- 2019-01-14: Install via snap: `sudo snap install --edge tiv`
## Installation
@ -32,8 +31,6 @@ See the difference by disabling this optimization using the `-0` option. Or just
make
sudo make install
Note: On MacOS, you'll need to install GCC because of this issue: https://stackoverflow.com/q/42633477. Find some more details here: https://github.com/stefanhaustein/TerminalImageViewer/issues/36
## Usage
tiv [options] <filename(s)>
@ -68,4 +65,3 @@ If multiple images match the filename spec, thumbnails are shown.
The top image was generated with the character optimization disabled via the `-0` option.
![Comparison](https://i.imgur.com/OzdCeh6.png)

View File

@ -195,7 +195,8 @@ CharData getCharData(const cimg_library::CImg<unsigned char> & image, int x0, in
int count2 = iter->first;
long max_count_color_1 = iter->second;
long max_count_color_2 = max_count_color_1;
if ((++iter) != color_per_count.rend()) {
if (iter != color_per_count.rend()) {
++iter;
count2 += iter->first;
max_count_color_2 = iter->second;
}
@ -329,7 +330,7 @@ void emit_color(int flags, int r, int g, int b) {
int gq = COLOR_STEPS[gi];
int bq = COLOR_STEPS[bi];
int gray = static_cast<int>(std::round(r * 0.2989f + g * 0.5870f + b * 0.1140f));
int gray = std::round(r * 0.2989f + g * 0.5870f + b * 0.1140f);
int gri = best_index(gray, GRAYSCALE_STEPS, GRAYSCALE_STEP_COUNT);
int grq = GRAYSCALE_STEPS[gri];
@ -439,24 +440,11 @@ cimg_library::CImg<unsigned char> load_rgb_CImg(const char * const filename) {
}
int main(int argc, char* argv[]) {
int maxWidth = 80;
int maxHeight = 24;
bool sizeDetectionSuccessful = true;
struct winsize w;
int ioStatus = ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
// If redirecting STDOUT to one file ( col or row == 0, or the previous ioctl call's failed )
if (ioStatus != 0 || (w.ws_col | w.ws_row) == 0) {
ioStatus = ioctl(STDIN_FILENO, TIOCGWINSZ, &w);
if (ioStatus != 0 || (w.ws_col | w.ws_row) == 0) {
std::cerr << "Warning: failed to determine most reasonable size, defaulting to 80x24" << std::endl;
sizeDetectionSuccessful = false;
}
}
if (sizeDetectionSuccessful)
{
maxWidth = w.ws_col * 4;
maxHeight = w.ws_row * 8;
}
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
int maxWidth = w.ws_col * 4;
int maxHeight = w.ws_row * 8;
int flags = 0;
Mode mode = AUTO;
int columns = 3;
@ -535,7 +523,7 @@ int main(int argc, char* argv[]) {
std::string name = file_names[index++];
try {
cimg_library::CImg<unsigned char> original = load_rgb_CImg(name.c_str());
auto cut = name.find_last_of("/");
unsigned int cut = name.find_last_of("/");
sb += cut == std::string::npos ? name : name.substr(cut + 1);
size newSize = size(original).fitted_within(maxThumbSize);
original.resize(newSize.width, newSize.height, 1, -100, 5);
@ -548,7 +536,7 @@ int main(int argc, char* argv[]) {
// Probably no image; ignore.
}
}
if (count) emit_image(image, flags);
emit_image(image, flags);
std::cout << sb << std::endl << std::endl;
}
}