fxgxa: dump g3a icons with half blocks

This commit is contained in:
Lephenixnoir 2025-05-09 01:39:07 +02:00
parent ce0784f765
commit 1db7bb209e
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
3 changed files with 31 additions and 2 deletions

View file

@ -258,10 +258,10 @@ void dump_g3a(struct g3a const *g3a, size_t size)
field(header->filename, 324); field(header->filename, 324);
printf("\nUnselected program icon:\n\n"); 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"); 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"); printf("\n");
} }

View file

@ -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) */ /* 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); 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 */ #endif /* FX_FXGXA */

View file

@ -172,3 +172,30 @@ void icon_print_16(uint16_t const *rgb16be, int width, int height)
free(rgb24); 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);
}