diff --git a/fxgxa/dump.c b/fxgxa/dump.c index 5575b6c..a614c81 100644 --- a/fxgxa/dump.c +++ b/fxgxa/dump.c @@ -258,10 +258,10 @@ void dump_g3a(struct g3a const *g3a, size_t size) field(header->filename, 324); printf("\nUnselected program icon:\n\n"); - icon_print_16(header->icon_uns, 92, 64); + icon_print_16_half(header->icon_uns, 92, 64); printf("\nSelected program icon:\n\n"); - icon_print_16(header->icon_sel, 92, 64); + icon_print_16_half(header->icon_sel, 92, 64); printf("\n"); } diff --git a/fxgxa/fxgxa.h b/fxgxa/fxgxa.h index 5a661b0..1db4ec0 100644 --- a/fxgxa/fxgxa.h +++ b/fxgxa/fxgxa.h @@ -194,5 +194,7 @@ void icon_print_1(uint8_t const *mono, int width, int height); /* icon_print_16(): Show a 16-bit image on stdout (RGB ANSI escape codes) */ void icon_print_16(uint16_t const *rgb16be, int width, int height); +/* icon_print_16_half(): Like icon_print_16() with half-block characters */ +void icon_print_16_half(uint16_t const *rgb16be, int width, int height); #endif /* FX_FXGXA */ diff --git a/fxgxa/icon.c b/fxgxa/icon.c index ba99bec..e741fd3 100644 --- a/fxgxa/icon.c +++ b/fxgxa/icon.c @@ -172,3 +172,30 @@ void icon_print_16(uint16_t const *rgb16be, int width, int height) free(rgb24); } + +void icon_print_16_half(uint16_t const *rgb16be, int width, int height) +{ + uint8_t *rgb24 = icon_conv_16to24(rgb16be, width, height); + if(!rgb24) { + fprintf(stderr, "error: %m\n"); + return; + }; + + for(int y2 = 0; y2 < height; y2 += 2) { + for(int x = 0; x < width; x++) { + int inT = 3 * (y2 * width + x); + int rT = rgb24[inT], gT = rgb24[inT+1], bT = rgb24[inT+2]; + + int inB = 3 * ((y2 + 1) * width + x); + int rB = 0, gB = 0, bB = 0; + if(y2 + 1 < height) + rB = rgb24[inB], gB = rgb24[inB+1], bB = rgb24[inB+2]; + + printf("\e[38;2;%d;%d;%dm\e[48;2;%d;%d;%dmâ–€", + rT, gT, bT, rB, gB, bB); + } + printf("\e[0m\n"); + } + + free(rgb24); +}