[ES] Added printImage function

Signed-óff-by: Jim Martens <github@2martens.de>
This commit is contained in:
Jim Martens 2015-07-06 12:15:12 +02:00
parent 1739c2c3f2
commit 2e1aaa41c5
1 changed files with 27 additions and 0 deletions

View File

@ -313,6 +313,33 @@ int printString(int x, int y, const char* text, int textLength)
return 0;
}
/**
* Prints an image with given parameters.
*
* @param int x
* @param int y
* @param int rows
* @param int cols
* @param const int* pixels
*/
void printImage(int x, int y, int rows, int cols, const int* pixels)
{
int currentX = x;
int currentY = y;
int maxIndex = rows * cols;
for (int i = 0; i < maxIndex; i++) {
if (currentY == cols) {
currentX++;
currentY = y;
}
int pixel = pixels[i];
setPixel(currentX, currentY, pixel);
currentY++;
}
}
/**
* Reads the contents of a text file into a string.
*