From 0eaf0973d984515c542dda27d7b8d7b4a59f5405 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Sun, 28 Jan 2024 23:03:41 +0100 Subject: [PATCH] Uses true color detection from updated libscterm --- src/pixels.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/pixels.cpp b/src/pixels.cpp index 7dda8ce..5e808c8 100644 --- a/src/pixels.cpp +++ b/src/pixels.cpp @@ -1,20 +1,16 @@ #include +#include #include #include #include "pixels.hpp" // truecolor to palette color (216-color) static inline int t2p(int val) { - return .5 + 5 * val / 255.0; + return round(5 * val / 255.0); } static void write(std::ostream& os, FILE* in) { - char* tc = getenv("COLORTERM"); - std::string colorterm {tc ? tc : ""}; - bool has_truecolor = colorterm.size() > 0; - if (has_truecolor) { - has_truecolor = colorterm == "truecolor" || colorterm == "24bit"; - } + bool has_truecolor = sc::term::has_truecolor(); struct pam info; pnm_readpaminit(in, &info, PAM_STRUCT_SIZE(tuple_type)); std::unique_ptr row1 {pnm_allocpamrow(&info), pm_freerow};