23 {0, 0x00, 0x00, 0x00},
24 {1, 0xff, 0x00, 0x00},
25 {2, 0x00, 0xff, 0x00},
26 {3, 0xff, 0xff, 0x00},
27 {4, 0x00, 0x00, 0xff},
28 {5, 0xff, 0x00, 0xff},
29 {6, 0x00, 0xff, 0xff},
30 {7, 0xff, 0xff, 0xff},
37 diff += red > base.
red ? red - base.
red : base.
red - red;
39 diff += blue > base.
blue ? blue - base.
blue : base.
blue - blue;
44static unsigned get_color(
unsigned red,
unsigned green,
unsigned blue) {
46 unsigned diff = UINT_MAX;
47 for (
size_t i = 0; i <
sizeof(
COLORS) /
sizeof(
COLORS[0]); ++i) {
58static const unsigned BPP = 4;
64 assert(color_depth == 3 || color_depth == 24);
66 for (
unsigned y = 0; y < job->
height; y += 2) {
67 for (
unsigned x = 0; x < job->
width; ++x) {
77 if (color_depth == 3) {
78 unsigned fg =
get_color(red, green, blue);
81 assert(color_depth == 24);
82 gvprintf(job,
"\033[38;2;%u;%u;%um", red, green, blue);
99 if (color_depth == 3) {
100 unsigned bg =
get_color(red, green, blue);
103 assert(color_depth == 24);
104 gvprintf(job,
"\033[48;2;%u;%u;%um", red, green, blue);
126 const double r_linear = red / 255.0;
127 const double g_linear = green / 255.0;
128 const double b_linear = blue / 255.0;
130 const double y_linear =
131 0.2126 * r_linear + 0.7152 * g_linear + 0.0722 * b_linear;
132 return (
unsigned)(y_linear * 255.999);
142 const char **tiles) {
143 assert(y_stride > 0);
144 assert(x_stride > 0);
145 assert(tiles !=
NULL);
146 for (
unsigned i = 0; i < y_stride; ++i) {
147 for (
unsigned j = 0; j < x_stride; ++j) {
148 assert(tiles[i * x_stride + j] !=
NULL &&
"missing or not enough tiles");
154 for (
unsigned y = 0; y < job->
height; y += y_stride) {
155 for (
unsigned x = 0; x < job->
width; x += x_stride) {
159 for (
unsigned y_offset = 0;
160 y + y_offset < job->
height && y_offset < y_stride; ++y_offset) {
161 for (
unsigned x_offset = 0;
162 x + x_offset < job->
width && x_offset < x_stride; ++x_offset) {
165 (y + y_offset) * job->
width *
BPP + (x + x_offset) *
BPP;
176 const unsigned pixel = gray >= 240;
178 index |= pixel << (y_offset * x_stride + x_offset);
182 gvputs(job, tiles[index]);
191 const char *tiles[] = {
" ",
"▘",
"▝",
"▀",
"▖",
"▍",
"▞",
"▛",
192 "▗",
"▚",
"▐",
"▜",
"▃",
"▙",
"▟",
"█"};
193 const unsigned y_stride = 2;
194 const unsigned x_stride = 2;
195 assert(
sizeof(tiles) /
sizeof(tiles[0]) == 1 << (y_stride * x_stride));
202 const char *tiles[] = {
" ",
"🬀",
"🬁",
"🬂",
"🬃",
"🬄",
"🬅",
"🬆",
"🬇",
"🬈",
"🬉",
203 "🬊",
"🬋",
"🬌",
"🬍",
"🬎",
"🬏",
"🬐",
"🬑",
"🬒",
"🬓",
"▌",
204 "🬔",
"🬕",
"🬖",
"🬗",
"🬘",
"🬙",
"🬚",
"🬛",
"🬜",
"🬝",
"🬞",
205 "🬟",
"🬠",
"🬡",
"🬢",
"🬣",
"🬤",
"🬥",
"🬦",
"🬧",
"▐",
"🬨",
206 "🬩",
"🬪",
"🬫",
"🬬",
"🬭",
"🬮",
"🬯",
"🬰",
"🬱",
"🬲",
"🬳",
207 "🬴",
"🬵",
"🬶",
"🬷",
"🬸",
"🬹",
"🬺",
"🬻",
"█"};
208 const unsigned y_stride = 3;
209 const unsigned x_stride = 2;
210 assert(
sizeof(tiles) /
sizeof(tiles[0]) == 1 << (y_stride * x_stride));
217 const char *tiles[] = {
218 " ",
"⠁",
"⠈",
"⠉",
"⠂",
"⠃",
"⠊",
"⠋",
"⠐",
"⠑",
"⠘",
"⠙",
"⠒",
"⠓",
"⠚",
219 "⠛",
"⠄",
"⠅",
"⠌",
"⠍",
"⠆",
"⠇",
"⠎",
"⠏",
"⠔",
"⠕",
"⠜",
"⠝",
"⠖",
"⠗",
220 "⠞",
"⠟",
"⠠",
"⠡",
"⠨",
"⠩",
"⠢",
"⠣",
"⠪",
"⠫",
"⠰",
"⠱",
"⠸",
"⠹",
"⠲",
221 "⠳",
"⠺",
"⠻",
"⠤",
"⠥",
"⠬",
"⠭",
"⠦",
"⠧",
"⠮",
"⠯",
"⠴",
"⠵",
"⠼",
"⠽",
222 "⠶",
"⠷",
"⠾",
"⠿",
"⡀",
"⡁",
"⡈",
"⡉",
"⡂",
"⡃",
"⡊",
"⡋",
"⡐",
"⡑",
"⡘",
223 "⡙",
"⡒",
"⡓",
"⡚",
"⡛",
"⡄",
"⡅",
"⡌",
"⡍",
"⡆",
"⡇",
"⡎",
"⡏",
"⡔",
"⡕",
224 "⡜",
"⡝",
"⡖",
"⡗",
"⡞",
"⡟",
"⡠",
"⡡",
"⡨",
"⡩",
"⡢",
"⡣",
"⡪",
"⡫",
"⡰",
225 "⡱",
"⡸",
"⡹",
"⡲",
"⡳",
"⡺",
"⡻",
"⡤",
"⡥",
"⡬",
"⡭",
"⡦",
"⡧",
"⡮",
"⡯",
226 "⡴",
"⡵",
"⡼",
"⡽",
"⡶",
"⡷",
"⡾",
"⡿",
"⢀",
"⢁",
"⢈",
"⢉",
"⢂",
"⢃",
"⢊",
227 "⢋",
"⢐",
"⢑",
"⢘",
"⢙",
"⢒",
"⢓",
"⢚",
"⢛",
"⢄",
"⢅",
"⢌",
"⢍",
"⢆",
"⢇",
228 "⢎",
"⢏",
"⢔",
"⢕",
"⢜",
"⢝",
"⢖",
"⢗",
"⢞",
"⢟",
"⢠",
"⢡",
"⢨",
"⢩",
"⢢",
229 "⢣",
"⢪",
"⢫",
"⢰",
"⢱",
"⢸",
"⢹",
"⢲",
"⢳",
"⢺",
"⢻",
"⢤",
"⢥",
"⢬",
"⢭",
230 "⢦",
"⢧",
"⢮",
"⢯",
"⢴",
"⢵",
"⢼",
"⢽",
"⢶",
"⢷",
"⢾",
"⢿",
"⣀",
"⣁",
"⣈",
231 "⣉",
"⣂",
"⣃",
"⣊",
"⣋",
"⣐",
"⣑",
"⣘",
"⣙",
"⣒",
"⣓",
"⣚",
"⣛",
"⣄",
"⣅",
232 "⣌",
"⣍",
"⣆",
"⣇",
"⣎",
"⣏",
"⣔",
"⣕",
"⣜",
"⣝",
"⣖",
"⣗",
"⣞",
"⣟",
"⣠",
233 "⣡",
"⣨",
"⣩",
"⣢",
"⣣",
"⣪",
"⣫",
"⣰",
"⣱",
"⣸",
"⣹",
"⣲",
"⣳",
"⣺",
"⣻",
234 "⣤",
"⣥",
"⣬",
"⣭",
"⣦",
"⣧",
"⣮",
"⣯",
"⣴",
"⣵",
"⣼",
"⣽",
"⣶",
"⣷",
"⣾",
236 const unsigned y_stride = 4;
237 const unsigned x_stride = 2;
238 assert(
sizeof(tiles) /
sizeof(tiles[0]) == 1 << (y_stride * x_stride));
281#define GVPLUGIN_VT_API __declspec(dllexport)
283#define GVPLUGIN_VT_API
swig_ptr_object_handlers offset
int gvputc(GVJ_t *job, int c)
int gvputs(GVJ_t *job, const char *s)
void gvprintf(GVJ_t *job, const char *format,...)
static void process(GVJ_t *job, int color_depth)
static void process6up(GVJ_t *job)
draw a 6-pixels-per-character monochrome image
static gvplugin_installed_t device_types[]
static gvdevice_engine_t engine8up
static gvdevice_features_t device_features
static void process8up(GVJ_t *job)
draw a 8-pixels-per-character monochrome image
static unsigned rgb_to_grayscale(unsigned red, unsigned green, unsigned blue)
convert an RGB color to grayscale
static gvdevice_engine_t engine24
static const color_t COLORS[]
ANSI 3-bit colors.
static void process4up(GVJ_t *job)
draw a 4-pixels-per-character monochrome image
static gvdevice_engine_t engine3
static void process24(GVJ_t *job)
static void process3(GVJ_t *job)
static gvdevice_engine_t engine4up
static void processNup(GVJ_t *job, unsigned y_stride, unsigned x_stride, const char **tiles)
static unsigned distance(const color_t base, unsigned red, unsigned green, unsigned blue)
a metric of “closeness” to a given color
GVPLUGIN_VT_API gvplugin_library_t gvplugin_vt_LTX_library
static const unsigned BPP
static gvplugin_api_t apis[]
static gvdevice_engine_t engine6up
static unsigned get_color(unsigned red, unsigned green, unsigned blue)
find closest ANSI color
unsigned char * imagedata
location of imagedata
void(* format)(GVJ_t *firstjob)