#include <stdio.h>
#include <windows.h> // WinApi header
int main()
{
HANDLE hConsole;
int w, h, k;
FILE *f = fopen("c.bmp", "rb");
fseek(f, 0x12, 0);
fread(&w, sizeof(w), 1, f);
fread(&h, sizeof(h), 1, f);
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// you can loop k higher to see more color choices
for(int y = 0; y < h; y++)
{
fseek(f, 0x36+(h-y-1)*w*4, 0);
for(int x = 0; x < w; x++)
{
int color, r, g, b;
fread(&color, sizeof(color), 1, f);
r = color & 0xFF;
g = (color>>8) & 0xFF;
b = (color>>16) & 0xFF;
r >>= 7;
g >>= 7;
b >>= 7;
int k = b<<2 | g<<1 | r;
SetConsoleTextAttribute(hConsole, k);
printf("Ы");
}
printf("\n");
}
getchar(); // wait
return 0;
}
|