From f785ecf9c1eab817e6e6bc8f954e662d4a66fb1f Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Sat, 27 Jan 2024 17:08:48 +0100 Subject: [PATCH] Fix truecolor support detection --- src/pixels.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pixels.cpp b/src/pixels.cpp index b0d7cb0..7dda8ce 100644 --- a/src/pixels.cpp +++ b/src/pixels.cpp @@ -9,9 +9,12 @@ static inline int t2p(int val) { } static void write(std::ostream& os, FILE* in) { - char* tc = getenv("TRUECOLOR"); - std::string truecolor {tc ? tc : ""}; - bool has_truecolor = truecolor.size() > 0; + char* tc = getenv("COLORTERM"); + std::string colorterm {tc ? tc : ""}; + bool has_truecolor = colorterm.size() > 0; + if (has_truecolor) { + has_truecolor = colorterm == "truecolor" || colorterm == "24bit"; + } struct pam info; pnm_readpaminit(in, &info, PAM_STRUCT_SIZE(tuple_type)); std::unique_ptr row1 {pnm_allocpamrow(&info), pm_freerow};