From 447b41fc3e2dfdce9db6d3ea3c24ec88fea7db0c Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Tue, 30 Jan 2024 13:04:26 +0100 Subject: [PATCH] If uneven rows, make last one default background For this to work, I had to turn the character upside-down, to be able to have a foreground color in the first pixel row, and background color in the second pixel row. So it's now an "unicode upper half block". --- src/pixels.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pixels.cpp b/src/pixels.cpp index 2a89548..8ee5fa1 100644 --- a/src/pixels.cpp +++ b/src/pixels.cpp @@ -22,9 +22,13 @@ void write_image(std::ostream& os, FILE* in) { } for (int x = 0; x < info.width; ++x) { if (info.depth == 3) { // assume RGB, 1 byte per sample - os << sc::io::truecolorb(t1[x][0], t1[x][1], t1[x][2]); - os << sc::io::truecolorf(t2[x][0], t2[x][1], t2[x][2]); - os << u8"\u2584"; // unicode lower half block + os << sc::io::truecolorf(t1[x][0], t1[x][1], t1[x][2]); + if (y < info.height - 1) { + os << sc::io::truecolorb(t2[x][0], t2[x][1], t2[x][2]); + } else { + os << sc::io::defaultb; + } + os << u8"\u2580"; // unicode upper half block } } os << sc::io::reset << '\n';