Skip to content

Commit a7097fd

Browse files
author
HWR0@Proteus
committed
Update gsconv850.c
implemented termcap (CSI Codes) for the grayscale debug output instead of windows specific extended ASCII Codes Works with WIndows and Linux (compiled with gcc under Linux and MSYS2 under Windows)
1 parent 9b1dae8 commit a7097fd

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

gsconv850/gsconv850.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ void printHelp()
227227
printf(" -c, Clean output, without banner\n");
228228
printf(" -H, Shows essential data from BMP header\n");
229229
printf(" -t, Show table (0 1 2 ) - DEBUG\n");
230-
printf(" -g, Show graphics ( %c%c%c%c) - DEBUG\n", 177, 177, 219, 219);
231-
printf(" -i, Invert graphics (%c%c%c%c ) - DEBUG\n", 219, 219, 177, 177);
230+
printf(" -g, Show graphics (%c[30;40m %c[90;100m %c[37;47m %c[0m) - DEBUG\n", 27, 27, 27, 27);
231+
printf(" -i, Invert graphics (%c[37;47m %c[90;100m %c[30;40m %c[0m) - DEBUG\n", 27,27,27,27);
232232
printf(" -r, Reverse Y order\n");
233233
printf(" -a, Average RGB Pixel to gray, otherwise just the red channel taken\n");
234234
printf(" -s, Remove space between hex values\n");
@@ -294,8 +294,9 @@ void showBMPTable()
294294
void showBMPGraphics(int invColors /*colors inverted?*/)
295295
{
296296
int tmpv = 0;
297-
int gray = 177;
298-
int white = 219; //white = if white is foreground in terminal !
297+
int esc = 27;
298+
//int gray = 177;
299+
//int white = 219; //white = if white is foreground in terminal !
299300

300301
for (int y = 0; y < (fbmp.height); y++)
301302
{
@@ -305,20 +306,20 @@ void showBMPGraphics(int invColors /*colors inverted?*/)
305306
if (invColors)
306307
tmpv = 2 - tmpv;
307308

308-
if (tmpv == 0)
309+
if (tmpv == 0) //black
309310
{
310-
printf(" ");
311+
printf("%c[37;47m ", esc);
311312
}
312-
else if (tmpv == 1)
313+
else if (tmpv == 1) //gray
313314
{
314-
printf("%c%c", gray, gray);
315+
printf("%c[90;100m ", esc);
315316
}
316-
else
317+
else //white
317318
{
318-
printf("%c%c", white, white);
319+
printf("%c[37;47m ", esc);
319320
}
320321
}
321-
printf("\n");
322+
printf("%c[0m\n",esc);
322323
}
323324
}
324325

0 commit comments

Comments
 (0)