Compare commits

...

2 commits

Author SHA1 Message Date
Lephenixnoir
83859aa406
fxconv: fix libimg conversion for non-alpha images (deprecated) 2025-06-28 18:35:44 +02:00
Lephenixnoir
1db7bb209e
fxgxa: dump g3a icons with half blocks 2025-05-09 01:39:07 +02:00
4 changed files with 32 additions and 2 deletions

View file

@ -926,6 +926,7 @@ def convert_libimg_cg(input, params):
# Crop image to key "area"
area = Area(params.get("area", {}), img)
img = img.crop(area.tuple())
img = img.convert("RGBA")
# Encode the image into 16-bit format and force the alpha to 0x0001
format = CgProfile.find("rgb565a")

View file

@ -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");
}

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) */
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 */

View file

@ -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);
}