aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jonas <himself@jonasgunz.de> 2019-02-03 23:25:30 +0100
committerGravatar jonas <himself@jonasgunz.de> 2019-02-03 23:25:30 +0100
commit9d7f9525e89cb4e218c5bf5e529900fa6dc0fccc (patch)
tree6a14b1239236220872ca16f940e15c5b7ac723d9
parent4b79b5c799a63d0402b71985c29b3af73f18e925 (diff)
downloadAsciiMap-9d7f9525e89cb4e218c5bf5e529900fa6dc0fccc.tar.gz
Does now what it should.
Need a better map[] though
-rw-r--r--main.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/main.c b/main.c
index 2ada96a..531e4ca 100644
--- a/main.c
+++ b/main.c
@@ -22,7 +22,7 @@
#define CHAR_SIZE_X 10 //How many pixels should form one ASCII char?
#define CHAR_SIZE_Y (2 * CHAR_SIZE_X)
-const char map[] = {' ', '.', ',', '-', '~', ':', ';', '!', '/','?' , '%', '$', '#'};
+const char map[] = {' ', '.', ',', '-', '~', ':', ';', '!', '/','?', '%', '$', '#'};
//Routine for flipping bytes
uint32_t flip(unsigned char* _v, int _c);
@@ -166,16 +166,19 @@ int main(int argc, char *argv[])
{
for(int y = 0; y < size_y; y++)
{
- char b = 0;
- //Shit is seriously Fucked up around here
- //(Brain)Cells at work
- for(int row = y * CHAR_SIZE_Y; row < (y + 1) * CHAR_SIZE_Y; row ++)
+ char b[CHAR_SIZE_X][CHAR_SIZE_Y];
+
+ for(int r = 0; r < CHAR_SIZE_Y; r++)
{
- //x * CHAR_SIZE_X
- char d[2] = {avg(CHAR_SIZE_X, bitmap_buff[row]), b};
- b = avg(2, d);
+ int row = y * CHAR_SIZE_Y + r;
+ for(int c = 0; c < CHAR_SIZE_X; c++)
+ {
+ int col = x * CHAR_SIZE_X + c;
+ b[c][r] = avg(3, (char*)&bitmap_buff[row][col]);
+ }
}
- ascii_buff[x][y] = calc_char(b);
+
+ ascii_buff[x][y] = calc_char(avg(CHAR_SIZE_X * CHAR_SIZE_Y, &b));
}
}
@@ -235,6 +238,7 @@ char avg(int argc, char *argv)
for(int i = 0; i < argc; i++)
sum += (uint64_t)argv[i];
+
ret = (char)(sum / argc);
return ret;
@@ -242,6 +246,6 @@ char avg(int argc, char *argv)
char calc_char(uint8_t _c)
{
- float c = (float)_c / 255.0;
+ float c = (float)(_c) / 255.0;
return map [(int)(sizeof(map) * c)];
}