1
0
mirror of https://github.com/2martens/uni.git synced 2026-05-06 11:26:25 +02:00

[ES] Finished 6.1 but explode functionality

Signed-óff-by: Jim Martens <github@2martens.de>
This commit is contained in:
2015-07-06 18:59:35 +02:00
parent 2e1aaa41c5
commit ecf84eced8

View File

@ -361,6 +361,7 @@ const char* readString(File file)
}
else {
result[i] = '\0';
break; // allows for multiple calls of the method for iterative reading
}
}
@ -374,6 +375,21 @@ const char* readString(File file)
}
}
/**
* Explodes the string into an integer array.
*
* @param const int* input
* @param int length
*/
const int* explodeString(const char* input, int length)
{
int result[length] = {};
// TODO do some magic
return result;
}
/**
* Handles the command.
*
@ -428,7 +444,24 @@ void showFile(String fileName)
printString(0, 0, text, readStringLength);
}
else {
// TODO handle image file
const char* dimensions = readString(file);
int dimensionsLength = readStringLength;
const char* pixels = readString(file);
int pixelsLength = readStringLength;
// parse dimensions and pixels
// TODO is there some kind of explode? - that is exactly what we need
const int* dimensionsInt = explodeString(dimensions, dimensionsLength);
const int* pixelsInt = explodeString(pixels, pixelsLength);
// calculate x and y start positions
int rows = dimensionsInt[0];
int cols = dimensionsInt[1];
int x = (48 - rows) / 2;
int y = (84 - cols) / 2;
printImage(x, y, rows, cols, pixelsInt);
}
// TODO Closing the file?
}
}