Improved in-terminal rendering

This commit is contained in:
augustin64 2022-03-19 15:43:53 +01:00
parent ecdd93b3b3
commit b5284230b9

View File

@ -10,18 +10,12 @@ void print_image(unsigned int width, unsigned int height, FILE* ptr, int start)
fread(buffer, sizeof(buffer), 1, ptr);
int cur;
char tab[] = {' ', '.', ':', '%', '#', '\0'};
for (int i=0; i<height; i++) {
for (int j=0; j<width; j++) {
cur = buffer[start+j+i*width];
if (cur > 150)
printf("0");
else {
if (cur > 100)
printf(".");
else
printf(" ");
}
cur = (int)buffer[start+j+i*width];
printf("%c", tab[cur/52]);
}
printf("\n");
}