26 {0, 0x00, 0x00, 0x00},
27 {1, 0xff, 0x00, 0x00},
28 {2, 0x00, 0xff, 0x00},
29 {3, 0xff, 0xff, 0x00},
30 {4, 0x00, 0x00, 0xff},
31 {5, 0xff, 0x00, 0xff},
32 {6, 0x00, 0xff, 0xff},
33 {7, 0xff, 0xff, 0xff},
40 diff += red > base.
red ? red - base.
red : base.
red - red;
42 diff += blue > base.
blue ? blue - base.
blue : base.
blue - blue;
47static unsigned get_color(
unsigned red,
unsigned green,
unsigned blue) {
49 unsigned diff = UINT_MAX;
50 for (
size_t i = 0; i <
sizeof(
COLORS) /
sizeof(
COLORS[0]); ++i) {
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) {
73 unsigned red = data[offset + 2];
74 unsigned green = data[offset + 1];
75 unsigned blue = data[offset];
78 if (color_depth == 3) {
79 unsigned fg =
get_color(red, green, blue);
82 assert(color_depth == 24);
83 gvprintf(job,
"\033[38;2;%u;%u;%um", red, green, blue);
95 red = data[offset + 2];
96 green = data[offset + 1];
101 if (color_depth == 3) {
102 unsigned bg =
get_color(red, green, blue);
105 assert(color_depth == 24);
106 gvprintf(job,
"\033[48;2;%u;%u;%um", red, green, blue);
128 const double r_linear = red / 255.0;
129 const double g_linear = green / 255.0;
130 const double b_linear = blue / 255.0;
132 const double y_linear =
133 0.2126 * r_linear + 0.7152 * g_linear + 0.0722 * b_linear;
134 return (
unsigned)(y_linear * 255.999);
144 const char **tiles) {
145 assert(y_stride > 0);
146 assert(x_stride > 0);
147 assert(tiles !=
NULL);
148 for (
unsigned i = 0; i < y_stride; ++i) {
149 for (
unsigned j = 0; j < x_stride; ++j) {
150 assert(tiles[i * x_stride + j] !=
NULL &&
"missing or not enough tiles");
156 for (
unsigned y = 0; y < job->
height; y += y_stride) {
157 for (
unsigned x = 0; x < job->
width; x += x_stride) {
161 for (
unsigned y_offset = 0;
162 y + y_offset < job->
height && y_offset < y_stride; ++y_offset) {
163 for (
unsigned x_offset = 0;
164 x + x_offset < job->
width && x_offset < x_stride; ++x_offset) {
166 const unsigned offset =
169 const unsigned red = data[offset + 2];
170 const unsigned green = data[offset + 1];
171 const unsigned blue = data[offset];
179 const unsigned pixel = gray >= 240;
181 index |= pixel << (y_offset * x_stride + x_offset);
185 gvputs(job, tiles[index]);
194 const char *tiles[] = {
" ",
"▘",
"▝",
"▀",
"▖",
"▍",
"▞",
"▛",
195 "▗",
"▚",
"▐",
"▜",
"▃",
"▙",
"▟",
"█"};
196 const unsigned y_stride = 2;
197 const unsigned x_stride = 2;
198 assert(
sizeof(tiles) /
sizeof(tiles[0]) == 1 << (y_stride * x_stride));
205 const char *tiles[] = {
" ",
"🬀",
"🬁",
"🬂",
"🬃",
"🬄",
"🬅",
"🬆",
"🬇",
"🬈",
"🬉",
206 "🬊",
"🬋",
"🬌",
"🬍",
"🬎",
"🬏",
"🬐",
"🬑",
"🬒",
"🬓",
"▌",
207 "🬔",
"🬕",
"🬖",
"🬗",
"🬘",
"🬙",
"🬚",
"🬛",
"🬜",
"🬝",
"🬞",
208 "🬟",
"🬠",
"🬡",
"🬢",
"🬣",
"🬤",
"🬥",
"🬦",
"🬧",
"▐",
"🬨",
209 "🬩",
"🬪",
"🬫",
"🬬",
"🬭",
"🬮",
"🬯",
"🬰",
"🬱",
"🬲",
"🬳",
210 "🬴",
"🬵",
"🬶",
"🬷",
"🬸",
"🬹",
"🬺",
"🬻",
"█"};
211 const unsigned y_stride = 3;
212 const unsigned x_stride = 2;
213 assert(
sizeof(tiles) /
sizeof(tiles[0]) == 1 << (y_stride * x_stride));
219 const unsigned y_stride = 4;
220 const unsigned x_stride = 2;
221 assert(256 == 1 << (y_stride * x_stride));
228 const char *tiles[] = {
229 " ",
"⠁",
"⠈",
"⠉",
"⠂",
"⠃",
"⠊",
"⠋",
"⠐",
"⠑",
"⠘",
"⠙",
"⠒",
"⠓",
"⠚",
230 "⠛",
"⠄",
"⠅",
"⠌",
"⠍",
"⠆",
"⠇",
"⠎",
"⠏",
"⠔",
"⠕",
"⠜",
"⠝",
"⠖",
"⠗",
231 "⠞",
"⠟",
"⠠",
"⠡",
"⠨",
"⠩",
"⠢",
"⠣",
"⠪",
"⠫",
"⠰",
"⠱",
"⠸",
"⠹",
"⠲",
232 "⠳",
"⠺",
"⠻",
"⠤",
"⠥",
"⠬",
"⠭",
"⠦",
"⠧",
"⠮",
"⠯",
"⠴",
"⠵",
"⠼",
"⠽",
233 "⠶",
"⠷",
"⠾",
"⠿",
"⡀",
"⡁",
"⡈",
"⡉",
"⡂",
"⡃",
"⡊",
"⡋",
"⡐",
"⡑",
"⡘",
234 "⡙",
"⡒",
"⡓",
"⡚",
"⡛",
"⡄",
"⡅",
"⡌",
"⡍",
"⡆",
"⡇",
"⡎",
"⡏",
"⡔",
"⡕",
235 "⡜",
"⡝",
"⡖",
"⡗",
"⡞",
"⡟",
"⡠",
"⡡",
"⡨",
"⡩",
"⡢",
"⡣",
"⡪",
"⡫",
"⡰",
236 "⡱",
"⡸",
"⡹",
"⡲",
"⡳",
"⡺",
"⡻",
"⡤",
"⡥",
"⡬",
"⡭",
"⡦",
"⡧",
"⡮",
"⡯",
237 "⡴",
"⡵",
"⡼",
"⡽",
"⡶",
"⡷",
"⡾",
"⡿",
"⢀",
"⢁",
"⢈",
"⢉",
"⢂",
"⢃",
"⢊",
238 "⢋",
"⢐",
"⢑",
"⢘",
"⢙",
"⢒",
"⢓",
"⢚",
"⢛",
"⢄",
"⢅",
"⢌",
"⢍",
"⢆",
"⢇",
239 "⢎",
"⢏",
"⢔",
"⢕",
"⢜",
"⢝",
"⢖",
"⢗",
"⢞",
"⢟",
"⢠",
"⢡",
"⢨",
"⢩",
"⢢",
240 "⢣",
"⢪",
"⢫",
"⢰",
"⢱",
"⢸",
"⢹",
"⢲",
"⢳",
"⢺",
"⢻",
"⢤",
"⢥",
"⢬",
"⢭",
241 "⢦",
"⢧",
"⢮",
"⢯",
"⢴",
"⢵",
"⢼",
"⢽",
"⢶",
"⢷",
"⢾",
"⢿",
"⣀",
"⣁",
"⣈",
242 "⣉",
"⣂",
"⣃",
"⣊",
"⣋",
"⣐",
"⣑",
"⣘",
"⣙",
"⣒",
"⣓",
"⣚",
"⣛",
"⣄",
"⣅",
243 "⣌",
"⣍",
"⣆",
"⣇",
"⣎",
"⣏",
"⣔",
"⣕",
"⣜",
"⣝",
"⣖",
"⣗",
"⣞",
"⣟",
"⣠",
244 "⣡",
"⣨",
"⣩",
"⣢",
"⣣",
"⣪",
"⣫",
"⣰",
"⣱",
"⣸",
"⣹",
"⣲",
"⣳",
"⣺",
"⣻",
245 "⣤",
"⣥",
"⣬",
"⣭",
"⣦",
"⣧",
"⣮",
"⣯",
"⣴",
"⣵",
"⣼",
"⣽",
"⣶",
"⣷",
"⣾",
253 const char *tiles[] = {
254 " ",
"",
"",
"🮂",
"",
"▘",
"",
"",
"",
255 "",
"▝",
"",
"",
"",
"",
"▀",
"",
"",
256 "",
"",
"",
"",
"",
"",
"",
"",
"",
257 "",
"",
"",
"",
"",
"",
"",
"",
"",
258 "",
"",
"",
"",
"",
"",
"",
"",
"",
259 "",
"",
"",
"",
"",
"",
"",
"",
"",
260 "",
"",
"",
"",
"",
"",
"",
"",
"",
261 "🮅",
"",
"",
"",
"",
"",
"",
"",
"",
262 "",
"",
"",
"",
"",
"",
"",
"",
"▖",
263 "",
"",
"",
"",
"▌",
"",
"",
"",
"",
264 "▞",
"",
"",
"",
"",
"▛",
"",
"",
"",
265 "",
"",
"",
"",
"",
"",
"",
"",
"",
266 "",
"",
"",
"",
"",
"",
"",
"",
"",
267 "",
"",
"",
"",
"",
"",
"",
"",
"",
268 "",
"",
"",
"",
"",
"",
"",
"",
"",
269 "",
"",
"",
"",
"",
"",
"",
"",
"",
270 "",
"",
"",
"",
"",
"",
"",
"",
"",
271 "",
"",
"",
"",
"",
"",
"",
"▗",
"",
272 "",
"",
"",
"▚",
"",
"",
"",
"",
"▐",
273 "",
"",
"",
"",
"▜",
"",
"",
"",
"",
274 "",
"",
"",
"",
"",
"",
"",
"",
"",
275 "",
"",
"",
"▂",
"",
"",
"",
"",
"",
276 "",
"",
"",
"",
"",
"",
"",
"",
"",
277 "",
"",
"",
"",
"",
"",
"",
"",
"",
278 "",
"",
"",
"",
"",
"",
"",
"",
"",
279 "",
"",
"",
"",
"",
"",
"",
"",
"",
280 "",
"",
"",
"",
"",
"",
"▄",
"",
"",
281 "",
"",
"▙",
"",
"",
"",
"",
"▟",
"",
340#define GVPLUGIN_VT_API __declspec(dllexport)
342#define GVPLUGIN_VT_API
Arithmetic helper functions.
int gvputc(GVJ_t *job, int c)
int gvputs(GVJ_t *job, const char *s)
void gvprintf(GVJ_t *job, const char *format,...)
static gvdevice_engine_t engine8up2
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 void process8up2(GVJ_t *job)
draw a 8-pixels-per-character monochrome image with octant characters
static void process8up(GVJ_t *job, const char **tiles)
draw a 8-pixels-per-character monochrome image
static gvdevice_features_t device_features
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 engine8up1
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 void process8up1(GVJ_t *job)
draw a 8-pixels-per-character monochrome image with Braille characters
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 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)