Uses true color detection from updated libscterm

This commit is contained in:
Bob Polis 2024-01-28 23:03:41 +01:00
parent f785ecf9c1
commit 0eaf0973d9

View File

@ -1,20 +1,16 @@
#include <memory>
#include <cmath>
#include <libscterm.hpp>
#include <netpbm/pam.h>
#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<tuple, void(*)(void*)> row1 {pnm_allocpamrow(&info), pm_freerow};